See Note [Enumeration types] in TyCon, and comments in Trac #4528
mkDataTyConRhs cons
= DataTyCon {
data_cons = cons,
mkDataTyConRhs cons
= DataTyCon {
data_cons = cons,
- is_enum = not (null cons) &&
- all isNullarySrcDataCon cons
+ is_enum = not (null cons) && all is_enum_con cons
-- See Note [Enumeration types] in TyCon
}
-- See Note [Enumeration types] in TyCon
}
+ where
+ is_enum_con con
+ | (_tvs, theta, arg_tys, _res) <- dataConSig con
+ = null theta && null arg_tys
+
mkNewTyConRhs :: Name -> TyCon -> DataCon -> TcRnIf m n AlgTyConRhs
-- ^ Monadic because it makes a Name for the coercion TyCon
mkNewTyConRhs :: Name -> TyCon -> DataCon -> TcRnIf m n AlgTyConRhs
-- ^ Monadic because it makes a Name for the coercion TyCon
Note [Enumeration types]
~~~~~~~~~~~~~~~~~~~~~~~~
Note [Enumeration types]
~~~~~~~~~~~~~~~~~~~~~~~~
-We define datatypes with no constructors to not be
+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
enumerations; this fixes trac #2578, Otherwise we
end up generating an empty table for
<mod>_<type>_closure_tbl
in an enumeration. The empty table apparently upset
the linker.
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.
+
Note [Newtype coercions]
~~~~~~~~~~~~~~~~~~~~~~~~
The NewTyCon field nt_co is a a TyCon (a coercion constructor in fact)
Note [Newtype coercions]
~~~~~~~~~~~~~~~~~~~~~~~~
The NewTyCon field nt_co is a a TyCon (a coercion constructor in fact)