[Haskell-beginners] question about any

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


On Thu, 29 Dec 2011 11:03:38 -0500
Brent Yorgey <byorgey at seas.upenn.edu> wrote:

> On Thu, Dec 29, 2011 at 06:45:27AM +0100, Manfred Lotz wrote:
> > 
> > or' :: Monad m => ( a -> m Bool) -> [a] -> [m Bool]
> > or' _ [] = []
> > or' p (x:xs) = p x : or' p xs
> > 
> > and' :: Monad m => ( a -> m Bool) -> [a] -> [m Bool]
> > and' _ [] = []
> > and' p (x:xs) = p x : and' p xs
> 
> Note that or' = and' = map.
> 
> -Brent
> 

Thanks, Brent for pointing me to this. 

I guess I got it:

With or' = map I get

myany :: Monad m => (a -> m Bool) -> [a] -> m Bool
myany p = mor . map p

and with my former definition of mor I get:

myany p = liftM or . sequence . map p

and then:

myany p = liftM or . mapM p

which is Markus solution.



-- 
Manfred




More information about the Beginners mailing list