
#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: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Moderate (less Unknown/Multiple | than a day) Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by rwbarton): Replying to [comment:9 nomeata]:
(Even more crazy idea: One can even take this further. What about `case x of Right str -> Just str`. `Right` and `Just` can be used interchangeable at runtime (same constructor number, same number of arguments of the same shape). The compiler could create only one constructor for each such shape, and optimize the code above to `case x of Right _ -> x`. Furthermore we could have representational coercions between datatypes that are α-equal... Although I doubt that the run-time benefit of that will be high, and we’d lose all hopes to implement something like `vacuum` or `ghc-vis`.)
This could make `toInteger :: Int -> Integer` a no-op, for example. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9291#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler