
On Thu, Dec 29, 2011 at 8:29 AM, Tim Baumgartner
2011/12/29 Manfred Lotz
Hi there, might be trivial but anyway.
I have a usage of 'any' and 'all' but I only have a predicate p :: a -> IO Bool.
I wrote my own functons for this:
mor :: Monad m => [m Bool] -> m Bool mor = liftM or . sequence
....
myall p = mand . and' p
Hi Manfred,
have a look here: http://hackage.haskell.org/packages/archive/monad-loops/latest/doc/html/Cont...
Note that your functions and those of Control.Monad.Loops don't do the same thing : yours don't short circuit, they have to apply the predicate to all the list elements, C.M.L gives you short-circuiting combinators, that answer as soon as possible. You probably want C.M.L behaviour for performance. (I'm lying a bit here, in fact in certain monads (lazy ones), yours could be short-circuiting too, but in IO for instance, that is not the case) -- Jedaï