diff --git a/src/IHaskell/Eval/Evaluate.hs b/src/IHaskell/Eval/Evaluate.hs index 61a6d19d..7fa833c0 100644 --- a/src/IHaskell/Eval/Evaluate.hs +++ b/src/IHaskell/Eval/Evaluate.hs @@ -516,10 +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 =