+data ThStage -- See Note [Template Haskell state diagram] in TcSplice
+ = Splice -- Top-level splicing
+ -- This code will be run *at compile time*;
+ -- the result replaces the splice
+ -- Binding level = 0
+
+ | Comp -- Ordinary Haskell code
+ -- Binding level = 1
+
+ | Brack -- Inside brackets
+ ThStage -- Binding level = level(stage) + 1
+ (TcRef [PendingSplice]) -- Accumulate pending splices here
+ (TcRef LIE) -- and type constraints here
+
+topStage, topAnnStage, topSpliceStage :: ThStage
+topStage = Comp
+topAnnStage = Splice
+topSpliceStage = Splice
+
+instance Outputable ThStage where
+ ppr Splice = text "Splice"
+ ppr Comp = text "Comp"
+ ppr (Brack s _ _) = text "Brack" <> parens (ppr s)
+