iterate + forever = iterateM? Repeating an action with feedback
问题 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. 回答1: You're right, I don't know of a place this particular kind of loop is implemented. Your implementation looks fine; why not