The monads covered in Part II include a mixture of standard Haskell types that
are monads as well as monad classes from Andy Gill's Monad Template Library.
The Monad Template Library is included in the Glasgow Haskell Compiler's
hierarchical libraries under
Control.Monad
| Monad |
Type of computation |
Combination strategy for >>= |
| Identity |
N/A — Used with monad transformers |
The bound function is applied to the input value.
|
| Maybe |
Computations which may not return a result |
Nothing input gives Nothing output
Just x input uses x as input to the bound function.
|
| Error |
Computations which can fail or throw exceptions |
Failure records information describing the failure. Binding passes
failure information on without executing the bound function, or uses
successful values as input to the bound function.
|
| [] (List) |
Non-deterministic computations which can return multiple possible results |
Maps the bound function onto the input list and concatenates the
resulting lists to get a list of all possible results from all possible inputs.
|
| IO |
Computations which perform I/O |
Sequential execution of I/O actions in the order of binding.
|
| State |
Computations which maintain state |
The bound function is applied to the input value to
produce a state transition function which is applied to
the input state.
|
| Reader |
Computations which read from a shared environment |
The bound function is applied to the value of the input
using the same environment.
|
| Writer |
Computations which write data in addition to computing values |
Written data is maintained separately from values.
The bound function is applied to the input value and anything it
writes is appended to the write data stream.
|
| Cont |
Computations which can be interrupted and restarted |
The bound function is inserted into the continuation chain.
|