Press CTRL+C or CMD+C to copy the selected text and close this dialog.
Tweet
81 people like it. Like the snippet!
Factory pattern in F#
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
type IA = abstract Action : unit -> unit type Type = | TypeA | TypeB let factory = function | TypeA -> { new IA with member this.Action() = printfn "type A" } | TypeB -> { new IA with member this.Action() = printfn "type B" }