
#9291: Don't reconstruct sum types if the type subtly changes ----------------------------+---------------------------------------------- Reporter: schyler | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.8.2 Component: | Keywords: Compiler | Architecture: Unknown/Multiple Resolution: | Difficulty: Moderate (less than a day) Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | None/Unknown | Test Case: | Blocking: | ----------------------------+---------------------------------------------- Comment (by simonpj): I hate the fact that a type-system question forces us to lose a potential optimisation. But I do not know any well-typed way around this particular one. I'm absolutely not willing for the compiler to add `unsafeCoerce`s to the code! One of GHC's most unique and distinctive features is its commitment to a solidly-typed intermediate language, and I'm not willing to compromise that property. There is a long tradition in Haskell of doing things the Right Way and using the pain to drive innovation. (Monads, System FC, kind polymorphism, etc etc.) All that said, STG code is un-typed and I would be quite happy with STG- level optimisations that transformed {{{ case e of y { ... C a b -> C a b ... } =====> case e of y { ... C a b -> y ... } }}} and then commoned identical branches. (The above transformation is done in Core too, but not when the types don't match. In STG that doesn't matter.) Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9291#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler