title: Haskell Monads implementation
body: <p>I was recently reading learn you a haskell and I came across the expression:</p>
  
  <pre><code>[1,2] &gt;&gt;= \n -&gt; ['a', 'b'] &gt;&gt;= \ch -&gt; return (n, ch)
  </code></pre>
  
  <p>This expressions returns the result</p>
  
  <pre><code>[(1,'a'),(1,'b'),(2,'a'),(2,'b')]
  </code></pre>
  
  <p>so i understand that the monadic bind for lists is implemented as follows</p>
  
  <pre><code>xs &gt;&gt;= f = concatMap f xs
  </code></pre>
  
  <p>Taking the first half of the expression namely the:</p>
  
  <pre><code>[1,2] &gt;&gt;= \n -&gt; ['a', 'b']
  </code></pre>
  
  <p>it evaluates to <code>['a','b','a','b']</code>, from what I understand this is then fed in to the function: <code>(\ch -&gt; return (n , ch))</code>.</p>
  
  <p>What I don't understand is how the values 1,2 from the list are assigned to n and then how the compiler keeps a record of it to then assign it to n in the last function?</p>