
#11527: Pattern match translation suboptimal -------------------------------------+------------------------------------- Reporter: augustss | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): For `Integer` I agree we could and should do better. But what about {{{ baz :: (Num a) => a -> Int -> Int }}} which is what you'll get if you don't have a type signature. The report specifies something like this: {{{ baz n x | n == fromInteger 10, x == 1 = 1 | n == fromInteger 20, x == 1 = 2 | n == fromInteger 10, x == 2 = 2 ...etc... }}} Now you might think that we can common up all those tests for `n == fromInteger 10` to get {{{ baz n x | n == fromInteger 10 = case x of 1 -> 1 2 -> 2 ... etc ... | n == fromInteger 20 = ...etc.. }}} But what if both `n == fromInteger 10` and `n == fromInteger 20` are ''both true''? Now it's not OK to group together all the matches against 10. How annoying! The best we can do is to do CSE on those `fromInteger` calls. It's all very irritating but I don't see how to do better. Except for `Integer` when we know that the `Num` instance has good properties. Is that particular case worth improving? Perhaps, and it would not be hard -- I can offer guidance. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11527#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler