HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Moduleghc-10.0.0.20260917GHC2024

GHC.Tc.Deriv.Generate

Generating derived instance declarations

This module is nominally `subordinate' to GHC.Tc.Deriv, which is the `official' interface to deriving-related things.

This is where we do all the grimy bindings' generation.

  • 2 types
  • 24 values
datadata AuxBindSpec
#

A declarative description of an auxiliary binding that should be generated. See Note [Auxiliary binders] for a more detailed description of how these are used.

Constructors

valuegetPossibleDataCons :: TyCon -> [Type] -> [DataCon]
#

getPossibleDataCons tycon tycon_args returns the constructors of tycon whose return types match when checked against tycon_args.

See Note [Filter out impossible GADT data constructors]

datadata DerivInstTys
#

Information about the arguments to the class in a stock- or newtype-derived instance. For a deriving-generated instance declaration such as this one:

instance Ctx => Cls cls_ty_1 ... cls_ty_m (TC tc_arg_1 ... tc_arg_n) where ...

See Note [DerivEnv and DerivSpecMechanism] in GHC.Tc.Deriv.Utils for a more in-depth explanation, including the relationship between dit_tcdit_rep_tc and dit_tc_argsdit_rep_tc_args.

A DerivInstTys value can be seen as a more structured representation of the denv_inst_tys in a DerivEnv, as the denv_inst_tys is equal to dit_cls_tys ++ [mkTyConApp dit_tc dit_tc_args]. Other parts of the instance declaration can be found in the DerivEnv. For example, the Cls in the example above corresponds to the denv_cls field of DerivEnv.

Similarly, the type variables that appear in a DerivInstTys value are the same type variables as the denv_tvs in the parent DerivEnv. Accordingly, if we are inferring an instance context, the type variables will be TcTyVar skolems. Otherwise, they will be ordinary TyVars. See Note [Overlap and deriving] in GHC.Tc.Deriv.Infer.

Constructors

Instances1Outputable