summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc/Gen/Splice.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC/Tc/Gen/Splice.hs')
-rw-r--r--compiler/GHC/Tc/Gen/Splice.hs23
1 files changed, 9 insertions, 14 deletions
diff --git a/compiler/GHC/Tc/Gen/Splice.hs b/compiler/GHC/Tc/Gen/Splice.hs
index 5acffaca7d..09b5e070ad 100644
--- a/compiler/GHC/Tc/Gen/Splice.hs
+++ b/compiler/GHC/Tc/Gen/Splice.hs
@@ -163,8 +163,8 @@ import Data.Proxy ( Proxy (..) )
************************************************************************
-}
-tcTypedBracket :: HsExpr GhcRn -> HsBracket GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc)
-tcUntypedBracket :: HsExpr GhcRn -> HsBracket GhcRn -> [PendingRnSplice] -> ExpRhoType
+tcTypedBracket :: HsExpr GhcRn -> HsTypedBracket GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc)
+tcUntypedBracket :: HsExpr GhcRn -> HsUntypedBracket GhcRn -> [PendingRnSplice] -> ExpRhoType
-> TcM (HsExpr GhcTc)
tcSpliceExpr :: HsSplice GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc)
-- None of these functions add constraints to the LIE
@@ -184,9 +184,8 @@ runAnnotation :: CoreAnnTarget -> LHsExpr GhcRn -> TcM Annotation
-}
-- See Note [How brackets and nested splices are handled]
--- tcTypedBracket :: HsBracket Name -> TcRhoType -> TcM (HsExpr TcId)
-tcTypedBracket rn_expr brack@(TExpBr _ expr) res_ty
- = addErrCtxt (quotationCtxtDoc brack) $
+tcTypedBracket rn_expr e@(TExpBr ext expr) res_ty
+ = addErrCtxt (quotationCtxtDoc e) $
do { cur_stage <- getStage
; ps_ref <- newMutVar []
; lie_var <- getConstraintVar -- Any constraints arising from nested splices
@@ -213,16 +212,13 @@ tcTypedBracket rn_expr brack@(TExpBr _ expr) res_ty
; ps' <- readMutVar ps_ref
; codeco <- tcLookupId unsafeCodeCoerceName
; bracket_ty <- mkAppTy m_var <$> tcMetaTy expTyConName
- ; tcWrapResultO (Shouldn'tHappenOrigin "TExpBr")
+ ; tcWrapResultO (Shouldn'tHappenOrigin "TExpBr") -- romes TODO: What is Shouldn'tHappenOrigin? Is this still accurate?
rn_expr
(unLoc (mkHsApp (mkLHsWrap (applyQuoteWrapper wrapper)
(nlHsTyApp codeco [rep, expr_ty]))
- (noLocA (HsBracket (HsBracketTc bracket_ty (Just wrapper) ps') (XBracket brack)))))
+ (noLocA (HsTypedBracket (HsBracketTc bracket_ty (Just wrapper) ps') (XTypedBracket (TExpBr ext expr))))))
meta_ty res_ty }
-tcTypedBracket _ other_brack _
- = pprPanic "tcTypedBracket" (ppr other_brack)
--- tcUntypedBracket :: HsBracket Name -> [PendingRnSplice] -> ExpRhoType -> TcM (HsExpr TcId)
-- See Note [Typechecking Overloaded Quotes]
tcUntypedBracket rn_expr brack ps res_ty
= do { traceTc "tc_bracket untyped" (ppr brack $$ ppr ps)
@@ -246,7 +242,7 @@ tcUntypedBracket rn_expr brack ps res_ty
-- Unify the overall type of the bracket with the expected result
-- type
; tcWrapResultO BracketOrigin rn_expr
- (HsBracket (HsBracketTc expected_type brack_info ps') (XBracket brack))
+ (HsUntypedBracket (HsBracketTc expected_type brack_info ps') (XUntypedBracket brack))
expected_type res_ty
}
@@ -268,7 +264,7 @@ emitQuoteWanted m_var = do
-- | Compute the expected type of a quotation, and also the QuoteWrapper in
-- the case where it is an overloaded quotation. All quotation forms are
-- overloaded aprt from Variable quotations ('foo)
-brackTy :: HsBracket GhcRn -> TcM (Maybe QuoteWrapper, Type)
+brackTy :: HsUntypedBracket GhcRn -> TcM (Maybe QuoteWrapper, Type)
brackTy b =
let mkTy n = do
-- New polymorphic type variable for the bracket
@@ -291,7 +287,6 @@ brackTy b =
(DecBrG {}) -> mkTy decsTyConName -- Result type is m [Dec]
(PatBr {}) -> mkTy patTyConName -- Result type is m Pat
(DecBrL {}) -> panic "tcBrackTy: Unexpected DecBrL"
- (TExpBr {}) -> panic "tcUntypedBracket: Unexpected TExpBr"
---------------
-- | Typechecking a pending splice from a untyped bracket
@@ -329,7 +324,7 @@ tcTExpTy m_ty exp_ty
, text "The type of a Typed Template Haskell expression must" <+>
text "not have any quantification." ]
-quotationCtxtDoc :: HsBracket GhcRn -> SDoc
+quotationCtxtDoc :: HsTypedBracket GhcRn -> SDoc
quotationCtxtDoc br_body
= hang (text "In the Template Haskell quotation")
2 (ppr br_body)