type M<'a> = option<'a>
let bind f d =
match d with
| None -> None
| Some(v) -> f v
let result v = Some(v)
let delay f = f()
type MaybeBuilder() =
member x.Bind(v, f) = bind v f
member x.Return(v) = result v
member x.Delay(f) = delay f
member x.Let(v, f) = bind (result v) f <––– error
let maybe = MaybeBuilder()
The error on result v is
This expression was expected to have type
''a -> 'b option'
but here has type
''c option'
F# Overview (IV.) - Language Oriented Programming
The error on
result v
isThis expression was expected to have type ''a -> 'b option' but here has type ''c option'