diff options
author | simonpj@microsoft.com <unknown> | 2010-12-15 12:19:27 +0000 |
---|---|---|
committer | simonpj@microsoft.com <unknown> | 2010-12-15 12:19:27 +0000 |
commit | bee517d218a9546db88ee3ad4e15fb2010562e4a (patch) | |
tree | 21b0944a39355640c618964131d569df9a551ea3 | |
parent | 35a77384d096e9cec8488f09ddaee533ad61051a (diff) | |
download | haskell-bee517d218a9546db88ee3ad4e15fb2010562e4a.tar.gz |
Tighten up what it means to be an "enumeration data constructor"
See Note [Enumeration types] in TyCon, and comments in Trac #4528
-rw-r--r-- | compiler/iface/BuildTyCl.lhs | 8 | ||||
-rw-r--r-- | compiler/types/TyCon.lhs | 12 |
2 files changed, 17 insertions, 3 deletions
diff --git a/compiler/iface/BuildTyCl.lhs b/compiler/iface/BuildTyCl.lhs index 4319d1fc18..e71eefe339 100644 --- a/compiler/iface/BuildTyCl.lhs +++ b/compiler/iface/BuildTyCl.lhs @@ -112,10 +112,14 @@ mkDataTyConRhs :: [DataCon] -> AlgTyConRhs 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 } + 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 diff --git a/compiler/types/TyCon.lhs b/compiler/types/TyCon.lhs index 235097369f..2958107367 100644 --- a/compiler/types/TyCon.lhs +++ b/compiler/types/TyCon.lhs @@ -582,7 +582,7 @@ data CoTyConDesc 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 @@ -590,6 +590,16 @@ 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. + Note [Newtype coercions] ~~~~~~~~~~~~~~~~~~~~~~~~ The NewTyCon field nt_co is a a TyCon (a coercion constructor in fact) |