mapAccum in monad

I recently had two functions of very similar shape, only difference was that one was pure and the other need some I/O. The former was easily written using mapAccumL. I failed to find a function like mapAccumL that runs in a monad, so I wrote up the following:

Bring on the comments/suggestions/improvements/etc!

Franklin Chen

I guess my only comment is that mapAccumL is already based on a hidden state transformer, so the generalization is natural and maybe it should even be standard?

Leave a comment