[Haskell-beginners] I don't understand mapM in mapM id (Just 1, Nothing, Just 3)
Brent Yorgey
byorgey at seas.upenn.edu
Mon Jun 6 17:54:53 CEST 2011
On Mon, Jun 06, 2011 at 09:08:40AM +0800, Haisheng Wu wrote:
> Thanks Senastian!
>
> I would refine the equality as below:
>
> sequence [Just 2, Nothing]
> = do x <- Just 2
> y <- sequence [Nothing]
> return (x:y)
> = Just 2 >>= \x -> sequence [Nothing] >>= \y -> return (x:y)
> = Nothing >>= \y -> return (2:y)
> = Nothing
Yes, exactly.
-Brent
More information about the Beginners
mailing list