You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
untilM evaluates the condition after the loop, keeping all results. iterateUntilM should behave the same (judging from the name), except that it returns only the final result.
However, it seems to evaluate the condition before the loop:
iterateUntilM :: (Monad m) => (a -> Bool) -> (a -> m a) -> a -> m a
iterateUntilM p f v
| p v = return v
| otherwise = f v >>= iterateUntilM p f
That confuses me. Is the naming to be unfortunate or the implementation to be incorrect?
The text was updated successfully, but these errors were encountered:
I don't think that this is a bug. The current semantics is intuitively clear: We want to iterate starting with a, until some condition. If the condition is already true we do not have to iterate.
But the fact that iterateUntilM is infix operator is indeed a bug. It should not.
untilM
evaluates the condition after the loop, keeping all results.iterateUntilM
should behave the same (judging from the name), except that it returns only the final result.However, it seems to evaluate the condition before the loop:
That confuses me. Is the naming to be unfortunate or the implementation to be incorrect?
The text was updated successfully, but these errors were encountered: