Note [The need for a wrapper]
Why might the wrapper have anything to do? The full story is
in wrapper_reqd in GHC.Types.Id.Make.mkDataConRep.
* Unboxing strict fields (with -funbox-strict-fields)
data T = MkT !(Int,Int)
\$wMkT :: (Int,Int) -> T
\$wMkT (x,y) = MkT x y
Notice that the worker has two fields where the wrapper has
just one. That is, the worker has type
MkT :: Int -> Int -> T
* Equality constraints for GADTs
data T a where { MkT :: a -> T [a] }
The worker gets a type with explicit equality
constraints, thus:
MkT :: forall a b. (a=[b]) => b -> T a
The wrapper has the programmer-specified type:
\$wMkT :: a -> T [a]
\$wMkT a x = MkT [a] a [a] x
The third argument is a coercion
[a] :: [a]~[a]
* Data family instances may do a cast on the result
* Type variables may be permuted; see MkId
Note [Data con wrappers and GADT syntax]
* Datatype contexts require dropping some dictionary arguments.
See Note [Instantiating stupid theta]. References 2
- Instantiating stupid theta GHC.Core.DataCon
- Data con wrappers and GADT syntax GHC.Types.Id.Make
Referenced by 3
- Data constructor workers and wrappers GHC.Core.DataCon ×2
- Data Constructor Naming GHC.Core.DataCon