If you look at the various calculation builders in ExtCore , there is one interesting thing - for any monad, the implementation While(and also For) of the member is usually the same.
, Bind, Zero While. , , - ( M<_> ):
// (unit -> bool) * M<'T> -> M<'T>
member this.While (guard, body : M<_>) : M<_> =
if guard () then
this.Bind (body, (fun () -> this.While (guard, body)))
else
this.Zero ()
- - , While, .
, , F # - F # , , , Haskell , , ( , ExtCore, - ). , , , , ...