Re: [GHC] #7401: Can't derive instance for Eq when datatype has no constructor, while it is trivial do do so.
#7401: Can't derive instance for Eq when datatype has no constructor, while it is trivial do do so. -------------------------------------+------------------------------------- Reporter: jpbernardy | Owner: osa1 Type: feature request | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.6.1 Resolution: | Keywords: deriving, Operating System: Unknown/Multiple | newcomer Type of failure: GHC rejects | Architecture: valid program | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: Phab:D978 -------------------------------------+------------------------------------- Comment (by osa1): (1) and (2) are done(will push commits soon). For (3), I think it may break some things. I found this NOTE in compiler/types/TyCon.hs: {{{ Note [Enumeration types] ~~~~~~~~~~~~~~~~~~~~~~~~ We define datatypes with no constructors to *not* be enumerations; this fixes trac #2578, Otherwise we end up generating an empty table for <mod>_<type>_closure_tbl which is used by tagToEnum# to map Int# to constructors in an enumeration. The empty table apparently upset the linker. Moreover, all the data constructor must be enumerations, meaning they have type (forall abc. T a b c). GADTs are not enumerations. For example consider data T a where T1 :: T Int T2 :: T Bool T3 :: T a What would [T1 ..] be? [T1,T3] :: T Int? Easiest thing is to exclude them. See Trac #4528. }}} See also trac #2578. Relevant commits: {{{ commit 409e4d9f59dece1c21434191459c96b3e355faa9 Author: Ian Lynagh <igloo@earth.li> Date: Sat Feb 27 17:24:29 2010 +0000 Add a test for #2578 commit a251cba370c9bfb291159c4deea20226a87eeac3 Author: Simon Marlow <marlowsd@gmail.com> Date: Mon Mar 1 09:55:25 2010 +0000 expand comments for #2578 fix commit 09d2b3b2e1f9d0a4c4b938dc6ff6a0b068138445 Author: Ian Lynagh <igloo@earth.li> Date: Sat Feb 27 17:39:51 2010 +0000 Fix trac #2578 We define empty datatypes as not being enumerations, which means the empty blocks aren't generated. }}} This is the fix: {{{ - = DataTyCon { data_cons = cons, is_enum = all isNullarySrcDataCon cons } + = DataTyCon { + data_cons = cons, + is_enum = -- We define datatypes with no constructors to not be + -- enumerations; this fixes trac #2578 + not (null cons) && + all isNullarySrcDataCon cons + } }}} `Note [Enumeration types]` mentions some kind of linker failure related with some table(??), but I don't have a lot of ideas about what it's talking about. I don't have a Mac so I can't try with latest linker/GHC. Any ideas about (3)? How should we proceed? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7401#comment:26> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC