Commit c0d84691 authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Allow existential data constructors to be promoted

This reverts the change in Trac #7347, which prevented promotion
of existential data constructors.  Ones with constraints in
their types, or kind polymorphism, still can't be promoted.
parent 3c06c09f
......@@ -391,6 +391,7 @@ data DataCon
-- The actual fixity is stored elsewhere
dcPromoted :: Maybe TyCon -- The promoted TyCon if this DataCon is promotable
-- See Note [Promoted data constructors] in TyCon
deriving Data.Typeable.Typeable
......@@ -559,9 +560,10 @@ mkDataCon name declared_infix
mkFunTys rep_arg_tys $
mkTyConApp rep_tycon (mkTyVarTys univ_tvs)
| is_vanilla -- No existentials or context
, all (isLiftedTypeKind . tyVarKind) univ_tvs
mb_promoted -- See Note [Promoted data constructors] in TyCon
| all (isLiftedTypeKind . tyVarKind) (univ_tvs ++ ex_tvs)
-- No kind polymorphism, and all of kind *
, null full_theta -- No constraints
, all isPromotableType orig_arg_tys
= Just (mkPromotedDataCon con name (getUnique name) prom_kind arity)
| otherwise
......@@ -596,8 +596,10 @@ Note [Promoted data constructors]
A data constructor can be promoted to become a type constructor,
via the PromotedTyCon alternative in TyCon.
* Only "vanilla" data constructors are promoted; ones with no GADT
stuff, no existentials, etc. We might generalise this later.
* Only data constructors with
(a) no kind polymorphism
(b) no constraints in its type (eg GADTs)
are promoted. Existentials are ok; see Trac #7347.
* The TyCon promoted from a DataCon has the *same* Name and Unique as
the DataCon. Eg. If the data constructor Data.Maybe.Just(unique 78,
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment