Note [Instantiating stupid theta]
Consider a data type with a "stupid theta" (see Note [The stupid context]): data Ord a => T a = MkT (Maybe a) We want to generate an Ord constraint for every use of MkT; but we also want to allow visible type application, such as MkT @Int To achieve this, the wrapper for a data (or newtype) constructor with a datatype context contains a lambda which drops the dictionary argments corresponding to the datatype context: /\a \(_d:Ord a). MkT @a Notice that the wrapper discards the dictionary argument d. We don't need it; it was only there to generate a Wanted constraint. (That is why it is stupid.) This all happens in GHC.Types.Id.Make.mkDataConRep. ************************************************************************ * * \subsection{Data constructors} * * ************************************************************************
References 1
- The stupid context GHC.Core.DataCon
Referenced by 5
- GHC.Types.Id.Make call site ×2
- The need for a wrapper GHC.Core.DataCon
- The stupid context GHC.Core.DataCon
- GHC.Tc.Gen.Head call site