Note [Data constructor representation]
Consider the following Haskell data type declaration
data T = T !Int ![Int]
Using the strictness annotations, GHC will represent this as
data T = T Int# [Int]
That is, the Int has been unboxed. Furthermore, the Haskell source construction
T e1 e2
is translated to
case e1 of { I# x ->
case e2 of { r ->
T x r }}
That is, the first argument is unboxed, and the second is evaluated. Finally,
pattern matching is translated too:
case e of { T a b -> ... }
becomes
case e of { T a' b -> let a = I# a' in ... }
To keep ourselves sane, we name the different versions of the data constructor
differently, as follows in Note [Data Constructor Naming].
The `dcRepType` field of a `DataCon` contains the type of the representation of
the constructor /worker/, also called the Core representation.
The Core representation may differ from the type of the constructor /wrapper/
(built by `mkDataConRep`). Besides unpacking (as seen in the example above),
dictionaries and coercions become explict arguments in the Core representation
of a constructor.
Note that this representation is still *different* from runtime
representation. (Which is what STG uses after unarise).
See Note [Constructor applications in STG] in GHC.Stg.Syntax. References 2
- Data Constructor Naming GHC.Core.DataCon
- Constructor applications in STG GHC.Stg.Syntax
Referenced by 1
- GHC.Core.DataCon call site