Ensure `type data` declarations don't exist at the term level
This MR is a collection of closely related patches that prevent type data
data constructors from sneaking into the term level:
type data
declarations
Don't generate datacon wrappers for Data constructor wrappers only make sense for value-level data constructors,
but data constructors for type data
declarations only exist at the type
level. This patch does the following:
-
The criteria in
GHC.Types.Id.Make.mkDataConRep
for whether a data constructor receives a wrapper now consider whether or not its parent data type was declared withtype data
, omitting a wrapper if this is the case. -
Now that
type data
data constructors no longer receive wrappers, there is a spot of code inrefineDefaultAlt
that panics when it encounters a value headed by atype data
type constructor. I've fixed this with a special case inrefineDefaultAlt
and expandedNote [Refine DEFAULT case alternatives]
to explain why we do this.
Fixes #22948 (closed).
Treat type data declarations as empty when checking pattern-matching coverage
The data constructors for a type data
declaration don't exist at the value
level, so we don't want GHC to warn users to match on them.
Fixes #22964 (closed).
tagToEnum#
on type data
types
Disallow We don't want to allow users to conjure up values of a type data
type using
tagToEnum#
, as these simply don't exist at the value level.