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.Generics

The deriving code for the Generic class

  • 1 type
  • 5 values
  • Packageghc-9.10.3
  • Exports6
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceGenerics.hs

Called by inferConstraints; generates a list of types, each of which must be a Functor in order for the Generic1 instance to work. For instance, if we have:

data Foo a = MkFoo Int a (Maybe a) (Either Int (Maybe a))

Then get_gen1_constrained_tys a (f (g a)) would return [Either Int], as a derived Generic1 instance would need to call fmap at that type. Invoking get_gen1_constrained_tys a on any of the other fields would return [].

get_gen1_constrained_tys is very similar in spirit to deepSubtypesContaining in GHC.Tc.Deriv.Functor. Just like with deepSubtypesContaining, it is important that the TyVar argument come from dataConUnivTyVars. (See #22167 for what goes wrong if tyConTyVars is used.)