X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcSplice.lhs;h=7139fa8da844b7a9b3ebef0816944ee4d80f192c;hp=51cf39282bc5fc98f9b55e9932e8754937a97cfc;hb=66579ff945831c5fc9a17c58c722ff01f2268d76;hpb=628ca41da974b157a374280b7abfe550e12b22b0 diff --git a/compiler/typecheck/TcSplice.lhs b/compiler/typecheck/TcSplice.lhs index 51cf392..7139fa8 100644 --- a/compiler/typecheck/TcSplice.lhs +++ b/compiler/typecheck/TcSplice.lhs @@ -63,13 +63,19 @@ import Maybe import BasicTypes import Panic import FastString +import Data.Typeable (cast) +import Exception import qualified Language.Haskell.TH as TH -- THSyntax gives access to internal functions and data types import qualified Language.Haskell.TH.Syntax as TH import GHC.Exts ( unsafeCoerce#, Int#, Int(..) ) -import qualified Control.Exception as Exception( userErrors ) +#if __GLASGOW_HASKELL__ < 609 +import qualified Exception ( userErrors ) +#else +import System.IO.Error +#endif \end{code} Note [Template Haskell levels] @@ -157,6 +163,7 @@ The predicate we use is TcEnv.thTopLevelId. %************************************************************************ \begin{code} +tcBracket :: HsBracket Name -> BoxyRhoType -> TcM (LHsExpr TcId) tcSpliceDecls :: LHsExpr Name -> TcM [LHsDecl RdrName] tcSpliceExpr :: HsSplice Name -> BoxyRhoType -> TcM (HsExpr TcId) kcSpliceType :: HsSplice Name -> TcM (HsType Name, TcKind) @@ -166,8 +173,10 @@ runQuasiQuoteExpr :: HsQuasiQuote Name -> TcM (LHsExpr RdrName) runQuasiQuotePat :: HsQuasiQuote Name -> TcM (LPat RdrName) #ifndef GHCI -tcSpliceExpr _ e _ = pprPanic "Cant do tcSpliceExpr without GHCi" (ppr e) -tcSpliceDecls e = pprPanic "Cant do tcSpliceDecls without GHCi" (ppr e) +tcBracket x _ = pprPanic "Cant do tcBracket without GHCi" (ppr x) +tcSpliceExpr e = pprPanic "Cant do tcSpliceExpr without GHCi" (ppr e) +tcSpliceDecls x = pprPanic "Cant do tcSpliceDecls without GHCi" (ppr x) +kcSpliceType x = pprPanic "Cant do kcSpliceType without GHCi" (ppr x) runQuasiQuoteExpr q = pprPanic "Cant do runQuasiQuoteExpr without GHCi" (ppr q) runQuasiQuotePat q = pprPanic "Cant do runQuasiQuotePat without GHCi" (ppr q) @@ -193,7 +202,6 @@ Desugared: f = do { s7 <- g Int 3 ; return (ConE "Data.Maybe.Just" s7) } \begin{code} -tcBracket :: HsBracket Name -> BoxyRhoType -> TcM (LHsExpr TcId) tcBracket brack res_ty = do level <- getStage case bracketOK level of { @@ -591,10 +599,24 @@ runMeta convert expr ; case either_tval of Right v -> return v +#if __GLASGOW_HASKELL__ < 609 Left exn | Just s <- Exception.userErrors exn , s == "IOEnv failure" -> failM -- Error already in Tc monad | otherwise -> failWithTc (mk_msg "run" exn) -- Exception +#else + Left (SomeException exn) -> + case cast exn of + Just (ErrorCall "IOEnv failure") -> + failM -- Error already in Tc monad + _ -> + case cast exn of + Just ioe + | isUserError ioe && + (ioeGetErrorString ioe == "IOEnv failure") -> + failM -- Error already in Tc monad + _ -> failWithTc (mk_msg "run" exn) -- Exception +#endif }}} where mk_msg s exn = vcat [text "Exception when trying to" <+> text s <+> text "compile-time code:", @@ -918,7 +940,7 @@ reifyName thing -- have free variables, we may need to generate NameL's for them. where name = getName thing - mod = nameModule name + mod = ASSERT( isExternalName name ) nameModule name pkg_str = packageIdString (modulePackageId mod) mod_str = moduleNameString (moduleName mod) occ_str = occNameString occ