Commit 61916c5d authored by Simon Peyton Jones's avatar Simon Peyton Jones Committed by Marge Bot

Add comments about TH levels

parent 077a88de
...@@ -1957,6 +1957,9 @@ too_many_args fun args ...@@ -1957,6 +1957,9 @@ too_many_args fun args
-} -}
checkThLocalId :: Id -> TcM () checkThLocalId :: Id -> TcM ()
-- The renamer has already done checkWellStaged,
-- in RnSplice.checkThLocalName, so don't repeat that here.
-- Here we just just add constraints fro cross-stage lifting
checkThLocalId id checkThLocalId id
= do { mb_local_use <- getStageAndBindLevel (idName id) = do { mb_local_use <- getStageAndBindLevel (idName id)
; case mb_local_use of ; case mb_local_use of
...@@ -1973,7 +1976,6 @@ checkCrossStageLifting :: TopLevelFlag -> Id -> ThStage -> TcM () ...@@ -1973,7 +1976,6 @@ checkCrossStageLifting :: TopLevelFlag -> Id -> ThStage -> TcM ()
-- we must check whether there's a cross-stage lift to do -- we must check whether there's a cross-stage lift to do
-- Examples \x -> [|| x ||] -- Examples \x -> [|| x ||]
-- [|| map ||] -- [|| map ||]
-- There is no error-checking to do, because the renamer did that
-- --
-- This is similar to checkCrossStageLifting in GHC.Rename.Splice, but -- This is similar to checkCrossStageLifting in GHC.Rename.Splice, but
-- this code is applied to *typed* brackets. -- this code is applied to *typed* brackets.
......
...@@ -911,7 +911,12 @@ removeBindingShadowing bindings = reverse $ fst $ foldl ...@@ -911,7 +911,12 @@ removeBindingShadowing bindings = reverse $ fst $ foldl
data SpliceType = Typed | Untyped data SpliceType = Typed | Untyped
data ThStage -- See Note [Template Haskell state diagram] in TcSplice data ThStage -- See Note [Template Haskell state diagram]
-- and Note [Template Haskell levels] in TcSplice
-- Start at: Comp
-- At bracket: wrap current stage in Brack
-- At splice: currently Brack: return to previous stage
-- currently Comp/Splice: compile and run
= Splice SpliceType -- Inside a top-level splice = Splice SpliceType -- Inside a top-level splice
-- This code will be run *at compile time*; -- This code will be run *at compile time*;
-- the result replaces the splice -- the result replaces the splice
...@@ -980,11 +985,10 @@ outerLevel = 1 -- Things defined outside brackets ...@@ -980,11 +985,10 @@ outerLevel = 1 -- Things defined outside brackets
thLevel :: ThStage -> ThLevel thLevel :: ThStage -> ThLevel
thLevel (Splice _) = 0 thLevel (Splice _) = 0
thLevel (RunSplice _) =
-- See Note [RunSplice ThLevel].
panic "thLevel: called when running a splice"
thLevel Comp = 1 thLevel Comp = 1
thLevel (Brack s _) = thLevel s + 1 thLevel (Brack s _) = thLevel s + 1
thLevel (RunSplice _) = panic "thLevel: called when running a splice"
-- See Note [RunSplice ThLevel].
{- Node [RunSplice ThLevel] {- Node [RunSplice ThLevel]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
...@@ -466,7 +466,7 @@ Note [Template Haskell levels] ...@@ -466,7 +466,7 @@ Note [Template Haskell levels]
incremented by brackets [| |] incremented by brackets [| |]
incremented by name-quoting 'f incremented by name-quoting 'f
When a variable is used, we compare * When a variable is used, checkWellStaged compares
bind: binding level, and bind: binding level, and
use: current level at usage site use: current level at usage site
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment