title: Haskell TransformListComp extension
body: <p>I read <a href="https://www.fpcomplete.com/user/PthariensFlame/guide-to-ghc-extensions/list-comprehension-extensions" rel="nofollow">this guide</a> about haskell language extensions and was somewhat confused by the TransformListComp explanation. I tried to rewrite all the TransformListComp expression without the sugar but I'm not sure if I'm correct.</p>
  
  <p>Also I think there is a mistake in the guide: The example for "then group using clauses" is impossible as "(groupBy (==))" is not of the right type ("Eq a" can't be used)</p>
  
  <pre><code>[foo |  x1 &lt;- xs1,
          x2 &lt;- xs2,
          ...
          xi &lt;- xsi,
          then f,
          xj &lt;- xsj,
          ...
          xn &lt;- xni
      ]
  
  ==
  [foo |  f x1 &lt;- xs1,
          f x2 &lt;- xs2,
          ...
          f xi &lt;- xsi,
          xj &lt;- xsj,
          ...
          xn &lt;- xni
      ]
  
  -------------------
  
  
  [foo |  x1 &lt;- xs1,
          x2 &lt;- xs2,
          ...
          xi &lt;- xsi,
          then f by exp,
          xj &lt;- xsj,
          ...
          xn &lt;- xni
      ]
  
  ==
  
  f (\(x1,x2,...,xi) -&gt; exp) [(x1,x2,...,xi) | 
          x1 &lt;- xs1,
          x2 &lt;- xs2,
          ...
          xi &lt;- xsi]
  
  &gt;&gt;=(\(x1,x2,...,xi) -&gt; 
      [foo |  
          xj &lt;- xsj,
          ...
          xn &lt;- xni
      ])
  
  
  -------------------
  
  [foo |  x1 &lt;- xs1,
          x2 &lt;- xs2,
          ...
          xi &lt;- xsi,
          then group using f,
          xj &lt;- xsj,
          ...
          xn &lt;- xni
      ]
  
  ==
  
  map unzipI (f [(x1,x2,...,xi) | 
          x1 &lt;- xs1,
          x2 &lt;- xs2,
          ...
          xi &lt;- xsi])
  
  &gt;&gt;=(\(xs1,xs2,...,xsi) -&gt; 
      [foo |
          x1 &lt;- xs1,
          x2 &lt;- xs2,
          ...
          xi &lt;- xsi,
          xj &lt;- xsj,
          ...
          xn &lt;- xni
      ])
  
  unzipI :: [(t1,t2,...tn)] -&gt; ([t1],[t2]..,[tn])
  
  -------------------
  
  [foo |  x1 &lt;- xs1,
          x2 &lt;- xs2,
          ...
          xi &lt;- xsi,
          then group by exp using f,
          xj &lt;- xsj,
          ...
          xn &lt;- xni
      ]
  
  ==
  
   map unzipI (f (\(x1,x2,...,xi) -&gt; exp) [(x1,x2,...,xi) | 
          x1 &lt;- xs1,
          x2 &lt;- xs2,
          ...
          xi &lt;- xsi])
  
  &gt;&gt;=(\(xs1,xs2,...,xsi) -&gt; 
      [foo |
          x1 &lt;- xs1,
          x2 &lt;- xs2,
          ...
          xi &lt;- xsi,
          xj &lt;- xsj,
          ...
          xn &lt;- xni
      ])
  
  unzipI :: [(t1,t2,...tn)] -&gt; ([t1],[t2]..,[tn])
  </code></pre>