
29 Dec
2011
29 Dec
'11
7:29 p.m.
On Thu, 29 Dec 2011 12:14:30 +0200
Markus Läll
You can use 'mapM' similar to 'map', to get the resultant list in the monad, and then liftM the function 'or' into it. This way you don't need to recurse explicitly, like in or' and and'.
many :: Monad m => (a -> m Bool) -> [a] -> m Bool many p list = or `liftM` mapM p list
(Type of mapM is: Monad m => (a -> m b) -> [a] -> m [b])
On Thu, Dec 29, 2011 at 7:45 AM, Manfred Lotz
This is indeed much easier and clearer. -- Thanks, Manfred