[Haskell-cafe] do {x<-[1,2,3]; True <- return (odd x); return x}.. why? (do notation, monads, guards)

Marc Weber marco-oweber at gmx.de
Sun Jan 8 06:45:18 EST 2006

On Sun, Jan 08, 2006 at 12:19:40PM +0300, Bulat Ziganshin wrote:
> Hello Marc,
> Sunday, January 08, 2006, 3:19:56 AM, you wrote:
> MW> list2=do { x <- [1,2,3]; guard (odd x); return x} -- <- provided by xerox
> list3 = [ x | x <- [1,2,3], odd x]
list4= take 2 $  [2*x+1,x<-[0..]] ;-)

Hi Bulat.. 
Thanks for your reply.
Of cause I know this version, too.

My goal has been to understand why the other versions list1,2rewritten
give the same result.. (especially which monadic implementation of >>=
is used in each case..)
I'm trying to understand this simple example because I want to
understand some other monad examples beeing more complicated..

See my comments of the last post for details..
If something is unclear.. Please tell me..

Some hints like: look at the defintion of Monad xy should be

Sincerly Marc

More information about the Haskell-Cafe mailing list