summaryrefslogtreecommitdiff
path: root/libraries/ghci/GHCi/TH.hs
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ghci/GHCi/TH.hs')
-rw-r--r--libraries/ghci/GHCi/TH.hs13
1 files changed, 7 insertions, 6 deletions
diff --git a/libraries/ghci/GHCi/TH.hs b/libraries/ghci/GHCi/TH.hs
index 5779b5073e..04c5fcffcc 100644
--- a/libraries/ghci/GHCi/TH.hs
+++ b/libraries/ghci/GHCi/TH.hs
@@ -106,6 +106,7 @@ import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as LB
import Data.Data
import Data.Dynamic
+import Data.Either
import Data.IORef
import Data.Map (Map)
import qualified Data.Map as M
@@ -170,13 +171,13 @@ instance TH.Quasi GHCiQ where
qReport isError msg = ghcCmd (Report isError msg)
-- See Note [TH recover with -fexternal-interpreter] in TcSplice
- qRecover (GHCiQ h) (GHCiQ a) = GHCiQ $ \s -> (do
+ qRecover (GHCiQ h) a = GHCiQ $ \s -> mask $ \unmask -> do
remoteTHCall (qsPipe s) StartRecover
- (r, s') <- a s
- remoteTHCall (qsPipe s) (EndRecover False)
- return (r,s'))
- `catch`
- \GHCiQException{} -> remoteTHCall (qsPipe s) (EndRecover True) >> h s
+ e <- try $ unmask $ runGHCiQ (a <* ghcCmd FailIfErrs) s
+ remoteTHCall (qsPipe s) (EndRecover (isLeft e))
+ case e of
+ Left GHCiQException{} -> h s
+ Right r -> return r
qLookupName isType occ = ghcCmd (LookupName isType occ)
qReify name = ghcCmd (Reify name)
qReifyFixity name = ghcCmd (ReifyFixity name)