Fri Aug 26 17:44:30 CEST 2011


I keep running into the mapfold operation but don't see why nobody
ever mentions this function.

  foldr   :: (a -> b -> b) -> b -> [a] -> b
  mapfold :: ((a -> b -> (b, c)) -> b -> [a] -> (b, [c])

Maybe it's because this is a combination of two monads: state and
list, and it's usually written as a map?

  :: (a -> m b) -> [a] -> m [b]

Indeed, that's the signature of mapM[1].

It might be a good idea to learn how to use this.  At first glance it
seems that this needs a monad class definition, and that can be a bit

[1] http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#v:mapM