module GHC.Tc.Types.TH (
SpliceType(..)
, SpliceOrBracket(..)
, ThLevel(..)
, PendingStuff(..)
, ThLevelIndex
, topLevel
, topAnnLevel
, topSpliceLevel
, thLevelIndex
, topLevelIndex
, spliceLevelIndex
, quoteLevelIndex
, thLevelIndexFromImportLevel
) where
import GHCi.RemoteTypes
import qualified GHC.Boot.TH.Syntax as TH
import GHC.Tc.Types.Evidence
import GHC.Utils.Outputable
import GHC.Tc.Types.TcRef
import GHC.Tc.Types.Constraint
import GHC.Hs.Expr ( PendingTcSplice, PendingRnSplice )
import GHC.Types.ThLevelIndex
data SpliceType = Typed | Untyped
data SpliceOrBracket = IsSplice | IsBracket
data ThLevel
= Splice SpliceType ThLevel
| RunSplice (TcRef [ForeignRef (TH.Q ())])
| Comp
| Brack
ThLevel
PendingStuff
data PendingStuff
= RnPendingUntyped
(TcRef [PendingRnSplice])
| RnPendingTyped
| TcPending
(TcRef [PendingTcSplice])
(TcRef WantedConstraints)
QuoteWrapper
topLevel, topAnnLevel, topSpliceLevel :: ThLevel
topLevel :: ThLevel
topLevel = ThLevel
Comp
topAnnLevel :: ThLevel
topAnnLevel = SpliceType -> ThLevel -> ThLevel
Splice SpliceType
Untyped ThLevel
Comp
topSpliceLevel :: ThLevel
topSpliceLevel = SpliceType -> ThLevel -> ThLevel
Splice SpliceType
Untyped ThLevel
Comp
instance Outputable ThLevel where
ppr :: ThLevel -> SDoc
ppr (Splice SpliceType
_ ThLevel
s) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Splice" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens (ThLevel -> SDoc
forall a. Outputable a => a -> SDoc
ppr ThLevel
s)
ppr (RunSplice TcRef [ForeignRef (Q ())]
_) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"RunSplice"
ppr ThLevel
Comp = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Comp"
ppr (Brack ThLevel
s PendingStuff
_) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"Brack" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens (ThLevel -> SDoc
forall a. Outputable a => a -> SDoc
ppr ThLevel
s)
thLevelIndex :: ThLevel -> ThLevelIndex
thLevelIndex :: ThLevel -> ThLevelIndex
thLevelIndex (Splice SpliceType
_ ThLevel
s) = ThLevelIndex -> ThLevelIndex
decThLevelIndex (ThLevel -> ThLevelIndex
thLevelIndex ThLevel
s)
thLevelIndex ThLevel
Comp = ThLevelIndex
topLevelIndex
thLevelIndex (Brack ThLevel
s PendingStuff
_) = ThLevelIndex -> ThLevelIndex
incThLevelIndex (ThLevel -> ThLevelIndex
thLevelIndex ThLevel
s)
thLevelIndex (RunSplice TcRef [ForeignRef (Q ())]
_) = ThLevel -> ThLevelIndex
thLevelIndex (SpliceType -> ThLevel -> ThLevel
Splice SpliceType
Untyped ThLevel
Comp)