#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 _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs