iterate + forever = iterateM? Repeating an action with feedback

haskell, monads

Solution

You're right, I don't know of a place this particular kind of loop is implemented. Your implementation looks fine; why not submit it as a patch to the monad-loops package?

Problem

I'm trying to repeat an IO action forever, but feeding the result of one execution into the next. Something like this: ``` -- poorly named iterateM :: Monad m => (a -> m a) -> a -> m b iterateM f a = f a >>= iterateM f ``` Hoogle didn't seem to help me, but I see plenty of functions which look enticingly close to what I want, but none seem to come together to be exactly it.

Original source

Related problems