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

Moduleth-desugar-1.17Haskell2010

Language.Haskell.TH.Desugar.Subst

Capture-avoiding substitutions on DTypes

  • 2 types
  • 6 values
  • Packageth-desugar-1.17
  • Exports8
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceSubst.hs

Capture-avoiding substitution

5 declarations

Matching a type template against a type

2 declarations
valuematchTy :: IgnoreKinds -> DType -> DType -> Maybe DSubst
#

matchTy ign tmpl targ matches a type template tmpl against a type target targ. This returns a Map from names of type variables in the type template to types if the types indeed match up, or Nothing otherwise. In the Just case, it is guaranteed that every type variable mentioned in the template is mapped by the returned substitution.

The first argument ign tells matchTy whether to ignore kind signatures in the template. A kind signature in the template might mean that a type variable has a more restrictive kind than otherwise possible, and that mapping that type variable to a type of a different kind could be disastrous. So, if we don't ignore kind signatures, this function returns Nothing if the template has a signature anywhere. If we do ignore kind signatures, it's possible the returned map will be ill-kinded. Use at your own risk.