[GHC] #7436: Derived Foldable and Traversable instances become extremely inefficient due to eta-expansion
GHC
cvs-ghc at haskell.org
Wed Jan 2 14:50:17 CET 2013
#7436: Derived Foldable and Traversable instances become extremely inefficient due
to eta-expansion
---------------------------------+------------------------------------------
Reporter: shachaf | Owner:
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Compiler | Version: 7.6.1
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: Runtime performance bug
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------+------------------------------------------
Comment(by twanvl):
I wrote the original deriving code for Functor/Foldable/Traversable.
Someone else later cleaned it up a bit.
The strange code that is generated are lambdas applied to arguments, which
is something that GHC should be able to optimize away easily. To avoid the
eta-expansion, the generated code is always a function. So you end up with
code like
{{{
data Cons a = Cons (a,a)
fmap f (Cons x) = (\x -> case x of (x1,x2) -> (f x1 , f x2)) x
}}}
I could add this example to a note, if you insist.
There are no library changes in the patch, and the derived code is
functionally equivalent to what was there before.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7436#comment:12>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list