Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin Ashton ashtonkj

View GitHub Profile
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 }
@swlaschin
swlaschin / ConstrainedTypesExamples.fsx
Last active Jan 6, 2021
Examples of creating constrained types in F#
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").
You can’t perform that action at this time.