[Haskell-cafe] Monad fold

Roman Cheplyaka roma at ro-che.info
Tue Apr 16 14:57:37 CEST 2013

* Christopher Howard <christopher.howard at frigidcode.com> [2013-04-16 04:35:39-0800]
> So, I'm doing something like this
> foldl (>>=) someA list :: Monad m => m a
> where
>   list :: Monad m => [a -> m a],
>   someA :: Monad m => m a
> Is there a more concise way to write this? I don't think foldM is what I
> want -- or is it?

I don't think it can get any more concise. (No, foldM isn't what you

But you most probably should prefer the right fold in this case.
(Unless you don't care about efficiency.)

Something like

  someA >>= foldr (>=>) return list

should do.


More information about the Haskell-Cafe mailing list