
19 May
2007
19 May
'07
7:12 p.m.
Matthew Cox wrote:
You can define one:
untilM :: Monad m => (a -> Bool) -> (a -> m a) -> a -> m a untilM pred f x | pred x = return x | otherwise = f x >>= untilM pred f
Matthew Cox
Hey, neat! :-D Mmm, I wonder if one could use "fail" to exit the loop instead... Oh, wait, for some monads that fires an error. Hmm. Nice try.