Bangs on data constructor arguments as the user wrote them in the
source code.
(HsSrcBang _ SrcUnpack SrcLazy) and
(HsSrcBang _ SrcUnpack NoSrcStrict) (without StrictData) makes no sense, we
emit a warning (in checkValidDataCon) and treat it like
(HsSrcBang _ NoSrcUnpack SrcLazy)
We need the Binary Name constraint here even though there is an instance
defined in GHC.Types.Name, because the we have a SOURCE import, so the
instance is not in scope. And the instance cannot be added to Name.hs-boot
because GHC.Utils.Binary itself depends on GHC.Types.Name.
Instantiate the universal tyvars of a data con,
returning
( instantiated existentials
, instantiated constraints including dependent GADT equalities
which are *also* listed in the instantiated existentials
, instantiated args)
The original type constructor used in the definition of this data
constructor. In case of a data family instance, that will be the family
type constructor.
Which type variables of this data constructor that must be
instantiated to concrete types?
For example: the RuntimeRep variables of unboxed tuples and unboxed sums.
See Note [Representation-polymorphism checking built-ins]
in GHC.Tc.Gen.Head.
Finds the instantiated types of the arguments required to construct a
DataCon representation
NB: these INCLUDE any dictionary args
but EXCLUDE the data-declaration context, which is discarded
It's all post-flattening etc; this is a representation type
Returns the arg types of the worker, including *all* non-dependent
evidence, after any flattening has been done and without substituting for
any type variables
Were the type variables of the data con written in a different order
than the regular order (universal tyvars followed by existential tyvars)?
This is not a cheap test, so we minimize its use in GHC as much as possible.
Currently, its only call site in the GHC codebase is in mkDataConRep in
MkId, and so dataConUserTyVarsNeedWrapper is only called at most once
during a data constructor's lifetime.
Given a data constructor dc with n universally quantified type
variables a_{1}, a_{2}, ..., a_{n}, and given a list of argument
types dc_args of length m where m <= n, then:
That is, return the list of universal type variables with
a_{1}, a_{2}, ..., a_{m} instantiated with
dc_arg_{1}, dc_arg_{2}, ..., dc_arg_{m}. It is possible for m to
be less than n, in which case the remaining n - m elements will simply
be universal type variables (with their kinds possibly instantiated).
Examples:
Given the data constructor D :: forall a b. Foo a b and
dc_args[Int, Bool], then dataConInstUnivs D dc_args will return
[Int, Bool].
Given the data constructor D :: forall a b. Foo a b and
dc_args[Int], then @dataConInstUnivs D dc_args will return
[Int, b].
Given the data constructor E :: forall k (a :: k). Bar k a and
dc_args[Type], then @dataConInstUnivs D dc_args will return
[Type, (a :: Type)].
This is primarily used in GHC.Tc.Deriv.* in service of instantiating data
constructors' field types.
See Note [Instantiating field types in stock deriving] for a notable
example of this.
Strictness/unpack annotations, from user; or, for imported
DataCons, from the interface file
The list is in one-to-one correspondence with the arity of the DataCon
Gives the number of value arguments (including zero-width coercions)
stored by the given DataCon's worker in its Core representation. This may
differ from the number of arguments that appear in the source code; see also
Note [DataCon arities]
Get the Id of the DataCon worker: a function that is the "actual"
constructor and has no top level binding in the program. The type may
be different from the obvious one written in the source program. Panics
if there is no such Id for this DataCon
Returns an Id which looks like the Haskell-source constructor by using
the wrapper if it exists (see dataConWrapId_maybe) and failing over to
the worker (see dataConWorkId)
Get the Id of the DataCon wrapper: a function that wraps the "actual"
constructor so it has the type visible in the source program: c.f.
dataConWorkId.
Returns Nothing if there is no wrapper, which occurs for an algebraic data
constructor and also for a newtype (whose constructor is inlined
compulsorily)
Return whether this DataCon's worker, in its Core representation, takes
any value arguments.
In particular, remember that we include coercion arguments in the arity of
the Core representation of the DataCon -- both lifted and unlifted
coercions, despite the latter having zero-width runtime representation.