Skip to content

Commit

Permalink
Doc: checkCrossStageLifting, RnSplice/TcExpr is untyped/typed bracket…
Browse files Browse the repository at this point in the history
…s (#10384)

Clarify that repeated checkCrossStageLifting in RnSplice/TcExpr
check untyped/typed brackets, respectively.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
  • Loading branch information
ezyang committed May 5, 2015
1 parent 1a4374c commit 341a766
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions compiler/rename/RnSplice.hs
Expand Up @@ -595,6 +595,9 @@ checkCrossStageLifting :: TopLevelFlag -> Name -> ThStage -> TcM ()
-- Now we must check whether there's a cross-stage lift to do
-- Examples \x -> [| x |]
-- [| map |]
--
-- This code is similar to checkCrossStageLifting in TcExpr, but
-- this is only run on *untyped* brackets.

checkCrossStageLifting top_lvl name (Brack _ (RnPendingUntyped ps_var))
| isTopLevel top_lvl
Expand Down
11 changes: 7 additions & 4 deletions compiler/typecheck/TcExpr.hs
Expand Up @@ -1254,15 +1254,18 @@ checkThLocalId id

--------------------------------------
checkCrossStageLifting :: Id -> ThStage -> TcM ()
-- If we are inside brackets, and (use_lvl > bind_lvl)
-- If we are inside typed brackets, and (use_lvl > bind_lvl)
-- we must check whether there's a cross-stage lift to do
-- Examples \x -> [| x |]
-- [| map |]
-- Examples \x -> [|| x ||]
-- [|| map ||]
-- There is no error-checking to do, because the renamer did that
--
-- This is similar to checkCrossStageLifting in RnSplice, but
-- this code is applied to *typed* brackets.

checkCrossStageLifting id (Brack _ (TcPending ps_var lie_var))
= -- Nested identifiers, such as 'x' in
-- E.g. \x -> [| h x |]
-- E.g. \x -> [|| h x ||]
-- We must behave as if the reference to x was
-- h $(lift x)
-- We use 'x' itself as the splice proxy, used by
Expand Down

0 comments on commit 341a766

Please sign in to comment.