ghc-tcplugin-api-0.17.0.0: An API for type-checker plugins.
Safe HaskellNone
LanguageHaskell2010

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:

Notes:

  • splitTyConApp_upTo will also look through type synonyms,
  • splitTyConApp_upTo only takes into account nominal equalities. Please open a ticket if you have a need for rewriting modulo representational equalities.
Synopsis

Documentation

data TyConSubst Source #

Substitution for recognizing TyCon applications modulo nominal equalities.

Instances

Instances details
Outputable TyConSubst Source # 
Instance details

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.