Mon Aug 8 18:47:59 CEST 2011

Flattening expressions using liftM2

One of the revelations of my recent Haskell study sprint is that it is
possible to "serialize algebra" using liftM2.  This might be
idiosyncratic language for something that has a proper name, but what
I mean is that the function

  liftM2 :: Monad m => (a -> b -> c) -> m a -> m b -> m c

is the bridge between "parallel" computations that have a binary tree
structure, where both legs of the tree (types a and b in the input
function above) are independent, and "sequential" computations that
have a fully specified order imposed by the monad structure.