
#16364: Derived Enum for small number of constructors seems suboptimal -------------------------------------+------------------------------------- Reporter: Fuuzetsu | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.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): I agree that a straight pattern-match on the tag might be better, at least for small enumerations. Another interesting question is this: what is the behaviour of the primitive operation `tagToEnum#` when given an out-of-range tag? Does it crash somehow, return a bogus answer, or call `error`? It think it might be the former, relying on the caller to check for out-of-range cases, like array indexing. We should document this properly. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16364#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler