<div dir="ltr">If you rewrite your example without do notation, you'll get:<br><br>[1,2,3] >>= \a -> [a+1] >>= return a<div><br></div><div>You can notice that first `a` and the last one are different things. They are just different bindings that happen to have the same name (You'll get the shadowing warning if enable -Wall). They have nothing in common and can have different types as well.</div></div><br><div class="gmail_quote">On Tue, Apr 28, 2015 at 12:53 PM Shishir Srivastava <<a href="mailto:shishir.srivastava@gmail.com">shishir.srivastava@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi, <div><br></div><div>Please can anyone explain how does 'a' get re-used in the code below. My understanding so far of haskell is that variables are not allowed to mutate or re-assigned.</div><div><br></div><div><font face="monospace, monospace">---</font></div><div><div><font face="monospace, monospace">do</font></div><div><font face="monospace, monospace">a <- [1,2,3]</font></div><div><font face="monospace, monospace">a <- [a+1]</font></div><div><font face="monospace, monospace">return a</font></div><div><font face="monospace, monospace"> </font></div><div><font face="monospace, monospace">[2,3,4]</font></div><div><font face="monospace, monospace">---</font></div></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Thanks,</font></div><div><div><div><div dir="ltr"><font color="#0b5394"><font style="background-color:rgb(255,255,255)"><font size="2" face="georgia, serif">Shishir </font></font><br></font><br></div></div></div>
</div></div>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote></div>