convertToHsExpr :: SrcSpan -> TH.Exp -> Either Message (LHsExpr RdrName)
convertToHsExpr loc e
= case initCvt loc (cvtl e) of
- Left msg -> Left (msg $$ (ptext (sLit "When converting TH expression")
+ Left msg -> Left (msg $$ (ptext (sLit "When splicing TH expression:")
<+> text (show e)))
Right res -> Right res
convertToPat :: SrcSpan -> TH.Pat -> Either Message (LPat RdrName)
convertToPat loc e
= case initCvt loc (cvtPat e) of
- Left msg -> Left (msg $$ (ptext (sLit "When converting TH pattern")
+ Left msg -> Left (msg $$ (ptext (sLit "When splicing TH pattern:")
<+> text (show e)))
Right res -> Right res
cvtHsDo :: HsStmtContext Name.Name -> [TH.Stmt] -> CvtM (HsExpr RdrName)
cvtHsDo do_or_lc stmts
+ | null stmts = failWith (ptext (sLit "Empty stmt list in do-block"))
+ | otherwise
= do { stmts' <- cvtStmts stmts
; let body = case last stmts' of
L _ (ExprStmt body _ _) -> body
okOcc :: OccName.NameSpace -> String -> Bool
okOcc _ [] = False
okOcc ns str@(c:_)
- | OccName.isVarName ns = startsVarId c || startsVarSym c
- | otherwise = startsConId c || startsConSym c || str == "[]"
+ | OccName.isVarNameSpace ns = startsVarId c || startsVarSym c
+ | otherwise = startsConId c || startsConSym c || str == "[]"
badOcc :: OccName.NameSpace -> String -> SDoc
badOcc ctxt_ns occ
go_tuple _ _ = Nothing
tup_name n
- | OccName.isTcClsName ctxt_ns = Name.getName (tupleTyCon Boxed n)
- | otherwise = Name.getName (tupleCon Boxed n)
+ | OccName.isTcClsNameSpace ctxt_ns = Name.getName (tupleTyCon Boxed n)
+ | otherwise = Name.getName (tupleCon Boxed n)
mk_uniq_occ :: OccName.NameSpace -> String -> Int# -> OccName.OccName
mk_uniq_occ ns occ uniq