
#13328: Foldable, Functor, and Traversable deriving handle phantom types badly -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: deriving-perf Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): One way we could help mitigate the effect of this is by doing an additional optimization for derived `Foldable` instances. First, we check each constructor, and if it does not contain an occurrence of the last type parameter, we filter out that constructor. Then we generate the `foldMap` cases as normal for fhe constructors that remain, and if any constructors were filtered out, we generate a catch-all `foldMap _ _ = mempty` case at the end. This should at least help in the case when all the data constructors of a phantom type are in scope, but its role has been annotated as something other than phantom. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13328#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler