[GHC] #7401: Can't derive instance for Eq when datatype has no constructor, while it is trivial do do so.

GHC ghc-devs at haskell.org
Thu Jun 6 14:01:27 CEST 2013


#7401: Can't derive instance for Eq when datatype has no constructor, while it is
trivial do do so.
---------------------------------+------------------------------------------
    Reporter:  jpbernardy        |       Owner:  monoidal                 
        Type:  feature request   |      Status:  new                      
    Priority:  normal            |   Milestone:  7.8.1                    
   Component:  Compiler          |     Version:  7.6.1                    
    Keywords:  deriving          |          Os:  Unknown/Multiple         
Architecture:  Unknown/Multiple  |     Failure:  GHC rejects valid program
  Difficulty:  Unknown           |    Testcase:                           
   Blockedby:                    |    Blocking:                           
     Related:                    |  
---------------------------------+------------------------------------------

Comment(by simonpj):

 Two more thoughts

  * You point out in #7931, this already works for standalone deriving,
 which is a bit odd.  Standalone and non-standalone deriving should behave
 pretty much the same.

  * When I say "works" what I mean is that, for nullary types, all methods
 `foo` get this definition:
 {{{
 foo = error "Void foo"
 }}}
  This is done in `TcGenDeriv.mkRdrFunBind`.  Several points:
   * Is this always the right thing to do? For every method, and every
 class?  Eg for `Read` it wasn't; see #7931. Needs checking.
   * We could also generate
 {{{
 foo x y = error "Void foo"
 }}}
    (ie with the error inside the lambdas) which isn't quite the same. I'm
 not sure which is right.
   * Including the name of the type constructor in the error message would
 be a lot more helpful.

 Thanks!

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7401#comment:11>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the ghc-tickets mailing list