Skip to content

Commit

Permalink
IHaskell.Eval.Evaluate: only catch exceptions for GHC >=9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhavsagar committed Apr 21, 2024
1 parent 7aa932b commit 0782ca6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/IHaskell/Eval/Evaluate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -516,12 +516,19 @@ evaluate kernelState code output widgetHandler = do
-- from inside the notebook environment.
extractValue :: Typeable a => String -> Interpreter (Either String a)
extractValue expr = do
#if MIN_VERSION_ghc(9,0,0)
compiled <- gcatch (Right <$> dynCompileExpr expr) (\exc -> return (Left (show exc)))
case compiled of
Left exc -> return (Left exc)
Right dyn -> case fromDynamic dyn of
Nothing -> return (Left multipleIHaskells)
Just result -> return (Right result)
#else
compiled <- dynCompileExpr expr
case fromDynamic compiled of
Nothing -> return (Left multipleIHaskells)
Just result -> return (Right result)
#endif

where
multipleIHaskells =
Expand Down

0 comments on commit 0782ca6

Please sign in to comment.