ghc-lib-parser-9.12.2.20250421: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Core.TyCo.Tidy

Contents

- Tidying type related things up for printing

Description

Tidying types and coercions for printing in error messages.

Synopsis

- tidyType :: TidyEnv -> Type -> Type
- tidyTypes :: TidyEnv -> [Type] -> [Type]
- tidyCo :: TidyEnv -> Coercion -> Coercion
- tidyCos :: TidyEnv -> [Coercion] -> [Coercion]
- tidyTopType :: Type -> Type
- tidyOpenType :: TidyEnv -> Type -> Type
- tidyOpenTypes :: TidyEnv -> [Type] -> [Type]
- tidyOpenTypeX :: TidyEnv -> Type -> (TidyEnv, Type)
- tidyOpenTypesX :: TidyEnv -> [Type] -> (TidyEnv, [Type])
- tidyFreeTyCoVars :: TidyEnv -> [TyCoVar] -> TidyEnv
- tidyFreeTyCoVarX :: TidyEnv -> TyCoVar -> (TidyEnv, TyCoVar)
- tidyFreeTyCoVarsX :: TidyEnv -> [TyCoVar] -> (TidyEnv, [TyCoVar])
- tidyAvoiding :: [OccName] -> (TidyEnv -> a -> TidyEnv) -> a -> TidyEnv
- tidyVarBndr :: TidyEnv -> TyCoVar -> (TidyEnv, TyCoVar)
- tidyVarBndrs :: TidyEnv -> [TyCoVar] -> (TidyEnv, [TyCoVar])
- avoidNameClashes :: [TyCoVar] -> TidyEnv -> TidyEnv
- tidyForAllTyBinder :: TidyEnv -> VarBndr TyCoVar vis -> (TidyEnv, VarBndr TyCoVar vis)
- tidyForAllTyBinders :: TidyEnv -> [VarBndr TyCoVar vis] -> (TidyEnv, [VarBndr TyCoVar vis])
- tidyTyCoVarOcc :: TidyEnv -> TyCoVar -> TyCoVar

# Tidying type related things up for printing

tidyType :: TidyEnv -> Type -> Type Source #

Tidy a Type

See Note [Strictness in tidyType and friends]

tidyTypes :: TidyEnv -> [Type] -> [Type] Source #

Tidy a list of Types

See Note [Strictness in tidyType and friends]

tidyCo :: TidyEnv -> Coercion -> Coercion Source #

Tidy a Coercion

See Note [Strictness in tidyType and friends]

tidyCos :: TidyEnv -> [Coercion] -> [Coercion] Source #

tidyTopType :: Type -> Type Source #

Calls `tidyType` on a top-level type (i.e. with an empty tidying environment)

tidyOpenType :: TidyEnv -> Type -> Type Source #

tidyOpenTypes :: TidyEnv -> [Type] -> [Type] Source #

tidyOpenTypeX :: TidyEnv -> Type -> (TidyEnv, Type) Source #

tidyOpenTypesX :: TidyEnv -> [Type] -> (TidyEnv, [Type]) Source #

Grabs the free type variables, tidies them and then uses `tidyType` to work over the type itself

tidyFreeTyCoVars :: TidyEnv -> [TyCoVar] -> TidyEnv Source #

Add the free `TyVar`s to the env in tidy form, so that we can tidy the type they are free in Precondition: input free vars are closed over kinds and This function does a scopedSort, so that tidied variables have tidied kinds. See Note [Tidying is idempotent]

tidyFreeTyCoVarX :: TidyEnv -> TyCoVar -> (TidyEnv, TyCoVar) Source #

Treat a new `TyCoVar` as a binder, and give it a fresh tidy name using the environment if one has not already been allocated. See also `tidyVarBndr` See Note [Tidying is idempotent]

tidyFreeTyCoVarsX :: TidyEnv -> [TyCoVar] -> (TidyEnv, [TyCoVar]) Source #

tidyAvoiding :: [OccName] -> (TidyEnv -> a -> TidyEnv) -> a -> TidyEnv Source #

tidyVarBndr :: TidyEnv -> TyCoVar -> (TidyEnv, TyCoVar) Source #

tidyVarBndrs :: TidyEnv -> [TyCoVar] -> (TidyEnv, [TyCoVar]) Source #

This tidies up a type for printing in an error message, or in an interface file.

It doesn't change the uniques at all, just the print names.

avoidNameClashes :: [TyCoVar] -> TidyEnv -> TidyEnv Source #

tidyForAllTyBinder :: TidyEnv -> VarBndr TyCoVar vis -> (TidyEnv, VarBndr TyCoVar vis) Source #

tidyForAllTyBinders :: TidyEnv -> [VarBndr TyCoVar vis] -> (TidyEnv, [VarBndr TyCoVar vis]) Source #

tidyTyCoVarOcc :: TidyEnv -> TyCoVar -> TyCoVar Source #