HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Moduleghc-10.0.0.20260917GHC2024

GHC.Hs.Extension

Synopsis
datadata GhcPass (c :: Pass) where

Used as a data type index for the hsSyn AST; also serves as a singleton type for Pass

Instances1371CvtFlag, Eq, NFData, CollectPass, MapXRec, UnXRec, …
classclass (NoGhcTcPass (NoGhcTcPass p) ~ NoGhcTcPass p, IsPass (NoGhcTcPass p)) => IsPass (p :: Pass) where

Allows us to check what phase we're in at GHC's runtime. For example, this class allows us to write

f :: forall p. IsPass p => HsExpr (GhcPass p) -> blah
f e = case ghcPass @p of
        GhcPs ->    ... in this RHS we have HsExpr GhcPs...
        GhcRn ->    ... in this RHS we have HsExpr GhcRn...
        GhcTc ->    ... in this RHS we have HsExpr GhcTc...

which is very useful, for example, when pretty-printing. See Note [IsPass].

Methods

Instances3IsPass

Orphan instances

2 instances