title: Haskell : Will GHC optimize this?
body: <p>Can GHC simplify <code>id = (\(a, b) -&gt; (a, b)).(\(a, b) -&gt; (a, b))</code> into <code>id = \(a, b) -&gt; (a, b)</code>?</p>
  
  <p>What about more complicated case :</p>
  
  <pre><code>id (Just x) = Just x
  id Nothing = Nothing
  
  map f (Just x) = Just (f x)
  map _ Nothing  = Nothing
  </code></pre>
  
  <p>Will GHC simplify <code>id . map</code> into <code>map</code>?</p>
  
  <p>I tried to use plain beta reduction but it looks like these terms are irreducible because of the nasty pattern matching.</p>
  
  <p>Therefore I am curious how do GHC's optimization techniques deal with that.</p>