| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
GHC.TcPlugin.API.TyConSubst
Description
This module provides functionality for recognising whether a type is a
TyConApp while taking into account Given nominal equalities.
In particular, this allows dealing with flattening variables on older GHC versions
(9.0 and below). For example, instead of [W] m + n ~ n + m, older GHCs might
produce [G] u ~ m + n, [G] v ~ n + m, [W] u ~ v. In this case, one needs to
use the Givens to recognise that u ~ v can be solved using the laws of natural
number arithmetic.
Usage:
- Use
mkTyConSubstto create aTyConSubstfrom Givens. - Use
splitTyConApp_upToto compute whether a type is aTyConApp, taking into account Given constraints (in the form of theTyConSubst).
Notes:
splitTyConApp_upTowill also look through type synonyms,splitTyConApp_upToonly takes into account nominal equalities. Please open a ticket if you have a need for rewriting modulo representational equalities.
Synopsis
- data TyConSubst
- mkTyConSubst :: [Ct] -> TyConSubst
- splitTyConApp_upTo :: TyConSubst -> Type -> Maybe (NonEmpty (TyCon, [Type], [Coercion]))
Documentation
data TyConSubst Source #
Substitution for recognizing TyCon applications modulo nominal equalities.
Instances
| Outputable TyConSubst Source # | |
Defined in GHC.TcPlugin.API.TyConSubst Methods ppr :: TyConSubst -> SDoc # | |
mkTyConSubst :: [Ct] -> TyConSubst Source #
Construct a TyConSubst from a collection of Given constraints.
splitTyConApp_upTo :: TyConSubst -> Type -> Maybe (NonEmpty (TyCon, [Type], [Coercion])) Source #
Like splitTyConApp_maybe, but taking Given constraints into account.
Alongside the TyCon and its arguments, also returns a list of coercions
that embody the Givens that we depended on.
Looks through type synonyms, just like splitTyConApp_maybe does.