Improve eta reduction
Consider
-- bar :: Int -> Int
-- g :: Moo ~ Int
f :: (Moo -> Int) -> Char
foo f = f (\ x -> bar (x `cast` a))
This will allocate a closure for (\ x -> bar (x `cast` a))
before calling f
. But really it should eta-reduce the lambda to
foo f = f (bar `cast` (sym g -> Int))
-- (sym g -> Int) :: (Int -> Int) ~ (Moo -> Int)
Result: no allocation before calling f
.
Thanks to Louis for suggesting this http://www.haskell.org/pipermail/glasgow-haskell-users/2010-July/018982.html
Trac metadata
Trac field | Value |
---|---|
Version | 6.12.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | wasserman.louis@gmail.com |
Operating system | |
Architecture |