View AsyncExtensions.fs
module Async = | |
let Bind continuation wf = async { | |
let! wf = wf | |
return! continuation wf | |
} | |
let Map continuation = Bind (continuation >> async.Return) | |
// e.g. | |
let workflow = async { return 10 } |
View ConstrainedTypesExamples.fsx
// General hints on defining types with constraints or invariants | |
// | |
// Just as in C#, use a private constructor | |
// and expose "factory" methods that enforce the constraints | |
// | |
// In F#, only classes can have private constructors with public members. | |
// | |
// If you want to use the record and DU types, the whole type becomes | |
// private, which means that you also need to provide: | |
// * a constructor function ("create"). |