matt:
> It occurred to me that the predicate will generally be a monadic function
> itself, so here's a
> refined version:
>
> :: Monad m => (a -> m Bool) -> (a -> m a) -> a -> m a
> untilM pred f x = do c <- pred x
> if c then return x
> else f x >>= untilM pred f
Here's a cute example of a loop from xmonad:
fix $ \again -> do
more <- checkMaskEvent d enterWindowMask p
when more again
But maybe Spencer was just being funny when he wrote that.
-- Don
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe