[Haskell-beginners] question about any

Manfred Lotz manfred.lotz at arcor.de
Thu Dec 29 20:29:40 CET 2011


On Thu, 29 Dec 2011 12:14:30 +0200
Markus Läll <markus.l2ll at gmail.com> wrote:

> 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 <manfred.lotz at arcor.de>

This is indeed much easier and clearer.

-- 
Thanks,
Manfred





More information about the Beginners mailing list