[project @ 2001-03-08 11:59:02 by simonpj]
authorsimonpj <unknown>
Thu, 8 Mar 2001 11:59:02 +0000 (11:59 +0000)
committersimonpj <unknown>
Thu, 8 Mar 2001 11:59:02 +0000 (11:59 +0000)
commitd78151f68bdaf05cb1e8ab77e32529327c0dae36
treefa3abad779b7afc9f1425b8c1bb46d6ab581bfb7
parent41d0a61d29cb0daccbcdbf96a339c06c5aa140a4
[project @ 2001-03-08 11:59:02 by simonpj]
-------------------------
Remove function coercions
-------------------------

    (coerce (T1->T2) (S1->S2) F) E
  ===>
    coerce T2 S2 (F (coerce S1 T1 E))

This is a generally good transformation, but it
still doesn't solve the problem I was after.  Consider

  newtype T = MkT (Int -> Int)

  p :: T->T;   p = ...
  q :: T;      q = ...

  foo :: T
  {-# INLINE foo #-}
  foo = p $ q

  f = \y -> ...((coerce (Int->Int) foo) 3)...

Trouble is, foo doesn't see the argument because of the coerce, so it
thinks it's a lone variable and doesn't inline.

Another problem is that since $ ins't inlined into foo's RHS, foo
looks like a redex, which we are reluctant to inline inside a lambda,
even with an INLINE pragma.  Maybe we should be bolder?

Anyway, this commit is an improvement to Simplify, but the story is not
over!
ghc/compiler/simplCore/Simplify.lhs