Re: #16364: Derived Enum for small number of constructors seems suboptimal

"GHC" <[email protected]>
Newsgroups gmane.comp.lang.haskell.glasgow.bugs
Message-ID <[email protected]>
#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>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.