
#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 Resolution: | Keywords: deriving Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects valid program | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Comment (by simonpj): There was some follow-up email on ghc-devs about this. (But let's accumulate comments here.) My summary * If we have `EmptyDataDecls` then surely {{{ data T deriving( Eq ) }}} should work, just as well as standalone deriving {{{ data T deriving Eq T }}} The two must behave the same. * Surely all the built-in classes (Eq, Show, Ord etc) should derive for with `EmptyDataDecls` too. * Haskell 2010 doesn't have `EmptyDataDecls` (eg the [http://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-680004.2 data type chapter] specifies n>0 constructors). But oddly the [http://www.haskell.org/onlinereport/haskell2010/haskellch11.html#x18-1820001... deriving appendix] clause 6 says that nothing is derived if there are no constructors. I think we should just ignore clause 6, since H2010 doesn't have empty data types. * It would be better if the `error "Void Eq"` mentioned the data type. More like `error "Eq on empty data type T"`. Might you do those things, Omer? Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/7401#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler