HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleghc-9.10.3GHC2021

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
  • Packageghc-9.10.3
  • Exports26
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceGenerate.hs
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