寻找mapAccumLM

use*_*015 0 haskell

我正在寻找一种在IO monad中使用mapAccumL的方法 - 类似于mapM的模拟,即使用这种类型的签名:

mapAccumLM :: (Monad m) => (a -> b -> m(a, c)) -> a -> [b] -> m(a, [c])

有什么简单的方法吗?

Lou*_*man 6

这基本上mapMStateT a IO:

mapAccumLM f a xs = runStateT (mapM (StateT . f) xs) a
Run Code Online (Sandbox Code Playgroud)