If xs is a list,
xs >>= f
is the same as (concat (map f xs)). Take a look at the monad instance for lists. So, in
[1..] >>= \x -> ....
x is "every" element of the list. Example:
[1,2,3] >>= \x -> [x, x*2]
is
concat
[ (\x -> [x, x*2]) 1
, (\x -> [x, x*2]) 2
, (\x -> [x, x*2]) 3
]
is
concat [ [1,1], [2,4], [3,6] ]
... and [1,2, ...
is
[1,1,2,4,3,6]
hope that helps. best regards,
daniel
michael rice schrieb:
getLine >>= \x -> -- x is a string at this point
[1..] >>= \x -> -- x is WHAT at this point?
MIchael
--- On Sun, 8/8/10, Henning Thielemann <lemming@henning-thielemann.de> wrote:
From: Henning Thielemann <lemming@henning-thielemann.de>
Subject: Re: [Haskell-cafe] What is <-
To: "michael rice" <nowgate@yahoo.com>
Cc: haskell-cafe@haskell.org
Date: Sunday, August 8, 2010, 9:38 AM
On Sun, 8 Aug 2010, michael rice wrote:
> So, Example 2 desugared becomes...
>
> [1..] >== \z -> ?
Yes, [1..] >>= \z -> ...
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe