Fri Jun 27 11:24:25 CEST 2008
point-free style and monads
Cons: M t
Unit: t -> M t
Bind: (M t) -> (t -> M u) -> (M u)
A monad M is a way to organize a collection of t, together with a way
to sequence computations of such collections. The 'bind' operation
takes values t from M t, produces a collection of monadic values M u
and combines those into a single collection M u.
The thing with '>>=' and 'do' is that they introduce new names.
Instead of mapping one monad to another one directly, this is
unwrapped to a 'do' comprehension that is then 'iterated' by the
implementation of '>>='.
It's probably better to look at the alternative formulation, replacing
Map: (t -> u) -> (M t -> M u)
Join: M (M t) -> M t
which can be used in point-free style, and is closer to the spirit of
FP and stack languages.