ghc-9.6.3: The GHC API

Safe Haskell | Safe-Inferred
Language | Haskell2010

GHC.Core.TyCo.Ppr

Contents

- Precedence
- Pretty-printing types
- Pretty-printing coercions

Description

Pretty-printing types and coercions.

Synopsis

- newtype PprPrec = PprPrec Int
- topPrec :: PprPrec
- sigPrec :: PprPrec
- opPrec :: PprPrec
- funPrec :: PprPrec
- appPrec :: PprPrec
- maybeParen :: PprPrec -> PprPrec -> SDoc -> SDoc
- pprType :: Type -> SDoc
- pprParendType :: Type -> SDoc
- pprTidiedType :: Type -> SDoc
- pprPrecType :: PprPrec -> Type -> SDoc
- pprPrecTypeX :: TidyEnv -> PprPrec -> Type -> SDoc
- pprTypeApp :: TyCon -> [Type] -> SDoc
- pprTCvBndr :: ForAllTyBinder -> SDoc
- pprTCvBndrs :: [ForAllTyBinder] -> SDoc
- pprSigmaType :: Type -> SDoc
- pprTheta :: ThetaType -> SDoc
- pprParendTheta :: ThetaType -> SDoc
- pprForAll :: [ForAllTyBinder] -> SDoc
- pprUserForAll :: [ForAllTyBinder] -> SDoc
- pprTyVar :: TyVar -> SDoc
- pprTyVars :: [TyVar] -> SDoc
- pprThetaArrowTy :: ThetaType -> SDoc
- pprClassPred :: Class -> [Type] -> SDoc
- pprKind :: Kind -> SDoc
- pprParendKind :: Kind -> SDoc
- pprTyLit :: TyLit -> SDoc
- pprDataCons :: TyCon -> SDoc
- pprWithExplicitKindsWhen :: Bool -> SDoc -> SDoc
- pprWithTYPE :: Type -> SDoc
- pprSourceTyCon :: TyCon -> SDoc
- pprCo :: Coercion -> SDoc
- pprParendCo :: Coercion -> SDoc
- debugPprType :: Type -> SDoc

# Precedence

newtype PprPrec Source #

A general-purpose pretty-printing precedence type.

Constructors

PprPrec Int |

#### Instances

Instances details

Show PprPrec Source # |
Instance details Defined in GHC.Types.Basic Methods showsPrec :: Int -> PprPrec -> ShowS Source # show :: PprPrec -> String Source # showList :: [PprPrec] -> ShowS Source #
Eq PprPrec Source # |
Instance details Defined in GHC.Types.Basic Methods (==) :: PprPrec -> PprPrec -> Bool # (/=) :: PprPrec -> PprPrec -> Bool #
Ord PprPrec Source # |
Instance details Defined in GHC.Types.Basic Methods compare :: PprPrec -> PprPrec -> Ordering # (<) :: PprPrec -> PprPrec -> Bool # (<=) :: PprPrec -> PprPrec -> Bool # (>) :: PprPrec -> PprPrec -> Bool # (>=) :: PprPrec -> PprPrec -> Bool # max :: PprPrec -> PprPrec -> PprPrec # min :: PprPrec -> PprPrec -> PprPrec #

topPrec :: PprPrec Source #

sigPrec :: PprPrec Source #

opPrec :: PprPrec Source #

funPrec :: PprPrec Source #

appPrec :: PprPrec Source #

maybeParen :: PprPrec -> PprPrec -> SDoc -> SDoc Source #

# Pretty-printing types

pprType :: Type -> SDoc Source #

pprParendType :: Type -> SDoc Source #

pprTidiedType :: Type -> SDoc Source #

pprPrecType :: PprPrec -> Type -> SDoc Source #

pprPrecTypeX :: TidyEnv -> PprPrec -> Type -> SDoc Source #

pprTypeApp :: TyCon -> [Type] -> SDoc Source #

pprTCvBndr :: ForAllTyBinder -> SDoc Source #

pprTCvBndrs :: [ForAllTyBinder] -> SDoc Source #

pprSigmaType :: Type -> SDoc Source #

pprTheta :: ThetaType -> SDoc Source #

pprParendTheta :: ThetaType -> SDoc Source #

pprForAll :: [ForAllTyBinder] -> SDoc Source #

pprUserForAll :: [ForAllTyBinder] -> SDoc Source #

Print a user-level forall; see `Note [When to print foralls]` in GHC.Iface.Type.

pprTyVar :: TyVar -> SDoc Source #

pprTyVars :: [TyVar] -> SDoc Source #

pprThetaArrowTy :: ThetaType -> SDoc Source #

pprClassPred :: Class -> [Type] -> SDoc Source #

pprKind :: Kind -> SDoc Source #

pprParendKind :: Kind -> SDoc Source #

pprTyLit :: TyLit -> SDoc Source #

pprDataCons :: TyCon -> SDoc Source #

pprWithExplicitKindsWhen :: Bool -> SDoc -> SDoc Source #

Display all kind information (with `-fprint-explicit-kinds`) when the provided `Bool` argument is `True`. See `Note [Kind arguments in error messages]` in GHC.Tc.Errors.

pprWithTYPE :: Type -> SDoc Source #

This variant preserves any use of TYPE in a type, effectively locally setting -fprint-explicit-runtime-reps.

pprSourceTyCon :: TyCon -> SDoc Source #

Pretty prints a `TyCon`, using the family instance in case of a representation tycon. For example:

    data T [a] = ...

In that case we want to print `T [a]`, where `T` is the family `TyCon`

# Pretty-printing coercions

pprCo :: Coercion -> SDoc Source #

pprParendCo :: Coercion -> SDoc Source #

debugPprType :: Type -> SDoc Source #

debugPprType is a simple pretty printer that prints a type without going through IfaceType. It does not format as prettily as the normal route, but it's much more direct, and that can be useful for debugging. E.g. with -dppr-debug it prints the kind on type-variable occurrences which the normal route fundamentally cannot do.