0 people like it.
Like the snippet!
Cannot resolve trait call op_HatDot
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
|
open System
#r "node_modules/fable-core/Fable.Core.dll"
open Fable.Core
open Fable.Core.JsInterop
module Browser = Fable.Import.Browser
#r "node_modules/fable-arch/Fable.Arch.dll"
open Fable.Arch
open Fable.Arch.App.Types
open Fable.Arch.App
open Fable.Arch.Html
#load "node_modules/fable-aether/Aether.fs"
open Aether
open Aether.Operators
type RecordB = {
A: string
B: bool
}
with
static member New = {
A = ""
B = false
}
// Aether
static member A_ : Lens<RecordB, string> = (fun x -> x.A), (fun value x -> { x with A = value })
static member B_ : Lens<RecordB, bool> = (fun x -> x.B), (fun value x -> { x with B = value })
type RecordA = {
RecordB: RecordB
}
with
static member New = {
RecordB = RecordB.New
}
// Aether
static member RecordB_ : Lens<RecordA, RecordB> = (fun x -> x.RecordB), (fun value x -> { x with RecordB = value })
type Action<'model> =
| InputChanged of Id: string * Value: string * Lens<'model, string>
| CheckboxChanged of Id: string * Value: bool * Lens<'model, bool>
with
override x.ToString () =
match x with
| InputChanged (id, value, _) -> sprintf "InputChanged (%s, %s)" id value
| CheckboxChanged (id, value, _) -> sprintf "CheckboxChanged (%s, %b)" id value
open FSharp.Reflection
let makeInput<'model> id (model: 'model) (lens: Lens<'model, string>) =
let value = Optic.get lens model
div [] [
label [] [ Text id ]
input [
property "value" value
onInput (fun e ->
e?preventDefault() |> ignore
let value = unbox<string> e?target?value
InputChanged (id, value, lens)
)
]
]
let makeCheckbox<'model> id (model: 'model) (lens: Lens<'model, bool>) =
let value = Optic.get lens model
div [] [
label [] [ Text id ]
input [
if value then
yield property "checked" "true"
else
()
yield Attributes.property "type" "checkbox"
yield onChange (fun e ->
e?preventDefault() |> ignore
let value = unbox<bool> e?target?``checked``
CheckboxChanged (id, value, lens)
)
]
]
let view (model: RecordA) =
let subModel = Optic.get RecordA.RecordB_ model
div [] [
div [] [
text "Aether test"
]
makeInput<RecordB> "A" subModel RecordB.A_
makeCheckbox<RecordB> "B" subModel RecordB.B_
]
let update (model: RecordA) action =
match action with
| InputChanged (id, value, lens) ->
Optic.set (RecordA.RecordB_ >-> lens) value model
| CheckboxChanged (id, value, lens) ->
Optic.set (RecordA.RecordB_ >-> lens) value model
createSimpleApp RecordA.New view update Virtualdom.createRender
|> withStartNodeSelector "#fable-body"
|> withSubscriber (fun x ->
printfn "Message: %s" (string x.Message)
printfn "Prev: %s" (string x.PreviousState)
printfn "Current: %s" (string x.CurrentState)
)
|> start
|
namespace System
namespace Microsoft.FSharp.Core
module Operators
from Microsoft.FSharp.Core
type RecordB =
{A: string;
B: bool;}
static member A_ : (RecordB -> string) * (string -> RecordB -> RecordB)
static member B_ : (RecordB -> bool) * (bool -> RecordB -> RecordB)
static member New : RecordB
Full name: Script.RecordB
RecordB.A: string
Multiple items
val string : value:'T -> string
Full name: Microsoft.FSharp.Core.Operators.string
--------------------
type string = String
Full name: Microsoft.FSharp.Core.string
RecordB.B: bool
type bool = Boolean
Full name: Microsoft.FSharp.Core.bool
static member RecordB.New : RecordB
Full name: Script.RecordB.New
static member RecordB.A_ : (RecordB -> string) * (string -> RecordB -> RecordB)
Full name: Script.RecordB.A_
val x : RecordB
val value : string
static member RecordB.B_ : (RecordB -> bool) * (bool -> RecordB -> RecordB)
Full name: Script.RecordB.B_
val value : bool
type RecordA =
{RecordB: RecordB;}
static member New : RecordA
static member RecordB_ : (RecordA -> RecordB) * (RecordB -> RecordA -> RecordA)
Full name: Script.RecordA
Multiple items
RecordA.RecordB: RecordB
--------------------
type RecordB =
{A: string;
B: bool;}
static member A_ : (RecordB -> string) * (string -> RecordB -> RecordB)
static member B_ : (RecordB -> bool) * (bool -> RecordB -> RecordB)
static member New : RecordB
Full name: Script.RecordB
static member RecordA.New : RecordA
Full name: Script.RecordA.New
property RecordB.New: RecordB
static member RecordA.RecordB_ : (RecordA -> RecordB) * (RecordB -> RecordA -> RecordA)
Full name: Script.RecordA.RecordB_
val x : RecordA
RecordA.RecordB: RecordB
val value : RecordB
Multiple items
type Action =
delegate of unit -> unit
Full name: System.Action
--------------------
type Action<'model> =
| InputChanged of Id: string * Value: string * obj
| CheckboxChanged of Id: string * Value: bool * obj
override ToString : unit -> string
Full name: Script.Action<_>
--------------------
type Action<'T1,'T2> =
delegate of 'T1 * 'T2 -> unit
Full name: System.Action<_,_>
--------------------
type Action<'T1,'T2,'T3> =
delegate of 'T1 * 'T2 * 'T3 -> unit
Full name: System.Action<_,_,_>
--------------------
type Action<'T1,'T2,'T3,'T4> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 -> unit
Full name: System.Action<_,_,_,_>
--------------------
type Action<'T1,'T2,'T3,'T4,'T5> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 -> unit
Full name: System.Action<_,_,_,_,_>
--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 -> unit
Full name: System.Action<_,_,_,_,_,_>
--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 -> unit
Full name: System.Action<_,_,_,_,_,_,_>
--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 -> unit
Full name: System.Action<_,_,_,_,_,_,_,_>
--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 -> unit
Full name: System.Action<_,_,_,_,_,_,_,_,_>
--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 -> unit
Full name: System.Action<_,_,_,_,_,_,_,_,_,_>
--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 -> unit
Full name: System.Action<_,_,_,_,_,_,_,_,_,_,_>
--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 -> unit
Full name: System.Action<_,_,_,_,_,_,_,_,_,_,_,_>
--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 -> unit
Full name: System.Action<_,_,_,_,_,_,_,_,_,_,_,_,_>
--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'T14> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 * 'T14 -> unit
Full name: System.Action<_,_,_,_,_,_,_,_,_,_,_,_,_,_>
--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'T14,'T15> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 * 'T14 * 'T15 -> unit
Full name: System.Action<_,_,_,_,_,_,_,_,_,_,_,_,_,_,_>
--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'T14,'T15,'T16> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 * 'T14 * 'T15 * 'T16 -> unit
Full name: System.Action<_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_>
union case Action.InputChanged: Id: string * Value: string * obj -> Action<'model>
union case Action.CheckboxChanged: Id: string * Value: bool * obj -> Action<'model>
val x : Action<'model>
override Action.ToString : unit -> string
Full name: Script.Action`1.ToString
val id : string
val sprintf : format:Printf.StringFormat<'T> -> 'T
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.sprintf
namespace Microsoft.FSharp
namespace Microsoft.FSharp.Reflection
val makeInput : id:obj -> model:'model -> lens:obj -> obj
Full name: Script.makeInput
val id : obj
val model : 'model
val lens : obj
val value : obj
namespace System.Text
val ignore : value:'T -> unit
Full name: Microsoft.FSharp.Core.Operators.ignore
val unbox : value:obj -> 'T
Full name: Microsoft.FSharp.Core.Operators.unbox
val makeCheckbox : id:obj -> model:'model -> lens:obj -> obj
Full name: Script.makeCheckbox
val view : model:RecordA -> 'a
Full name: Script.view
val model : RecordA
val subModel : obj
property RecordA.RecordB_: (RecordA -> RecordB) * (RecordB -> RecordA -> RecordA)
property RecordB.A_: (RecordB -> string) * (string -> RecordB -> RecordB)
property RecordB.B_: (RecordB -> bool) * (bool -> RecordB -> RecordB)
val update : model:RecordA -> action:Action<'a> -> 'b
Full name: Script.update
val action : Action<'a>
val set : elements:seq<'T> -> Set<'T> (requires comparison)
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.set
property RecordA.New: RecordA
val printfn : format:Printf.TextWriterFormat<'T> -> 'T
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
More information