[Haskell-cafe] monad subexpressions

Jules Bean jules at jellybean.co.uk
Fri Aug 3 04:38:09 EDT 2007

Jules Bean wrote:
> do
>   a <- m
>   b <- n
>   l a x b y
> becomes
> l (<- m) x (<- n) y
> ...with, I suppose, left-to-right evaluation order. This looks 'almost 
> like substitution' which is the goal.

Having read the thread SPJ pointed to, I should point out that using a 
mixture of Applicative and Monad notation, this can currently be written as:

l <$> m <*> (return x) <*> n =<< (return y)

...where the thing that feels weirdest is having to remember to use =<< 
instead of <*> for the final 'application'.


More information about the Haskell-Cafe mailing list