Computations Expressions
This library allows to use some common computation expressions without writing any boiler plate code.
There is a single computation expression: monad
but it comes in 4 flavours:

Delayed or strict
Delayed computations require that the type implements a Delay method. F# comes with async and seq computation expressions, both are delayed.

It can have embedded sideeffects or act as a monadplus
A monadplus can return (or yield) many times, so for example all expressions in a loop can be returned, whereas in the other model those expressions are of type unit, since a side effect is expected.
Async workflows is an example of a sideeffect computation expression and seq expressions are an example of monadplus.
Side effect workflows don't have any additional requirement over the type (apart from the monad operations), but monadplus requires the additional get_Empty and (<>) methods.
The generic computation expression
monad
is a sideeffect one, but it can be turned into a monadplus by accessing the.plus
property. Note thatmonad.fx
is an alias formonad
: fx is used as an abbreviation for sideeffects.These computations are lazy by default, but they can be made strict by adding
.strict
or using a'
, iemonad.plus'
.
In other words:
monad.fx
is the same asmonad
: Lazy monadic builder. Use when you want to use sideeffects instead of the additive behavior of monad plus.monad.fx'
is the strict version ofmonad
monad.plus
Lazy additive monadic builder. Use when you expect one or more results.monad.plus'
is the strict version ofmonad.plus
Examples
You may run this script stepbystep.
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 
