hscParsedStmt :: HscEnv
              -> GhciLStmt RdrName  -- ^ The parsed statement
              -> IO ( Maybe (Either Reinterpret ([Id]
                    , ForeignHValue {- IO [HValue] -}
                    , FixityEnv)))
hscParsedStmt hsc_env stmt = runInteractiveHsc hsc_env $ do
  -- Rename and typecheck it
  eResult <- ioMsgMaybe $ tcRnStmt hsc_env stmt

  case eResult of
    Right (ids, tc_expr, fix_env) -> do

        -- Desugar it
        ds_expr <- ioMsgMaybe $ deSugarExpr hsc_env tc_expr
        liftIO (lintInteractiveExpr "desugar expression" hsc_env ds_expr)
        handleWarnings

        -- Then code-gen, and link it
        -- It's important NOT to have package 'interactive' as thisUnitId
        -- for linking, else we try to link 'main' and can't find it.
        -- Whereas the linker already knows to ignore 'interactive'
        let src_span = srcLocSpan interactiveSrcLoc
        -- TODO: Allow hooks to work
        hval <- liftIO $ hscCompileCoreExpr hsc_env src_span ds_expr

        return $ Just $ Right (ids, hval, fix_env)
    Left reinterpret -> return $ Just $ Left reinterpret

-- | Compile a decls
hscParsedStmt :: HscEnv
              -> GhciLStmt RdrName  -- ^ The parsed statement
              -> IO ( Maybe (Either Reinterpret ([Id]
                    , ForeignHValue {- IO [HValue] -}
                    , FixityEnv)))
hscParsedStmt hsc_env stmt = runInteractiveHsc hsc_env $ do
  -- Rename and typecheck it
  eResult <- ioMsgMaybe $ tcRnStmt hsc_env stmt

  case eResult of
    Right (ids, tc_expr, fix_env) -> do

        -- Desugar it
        ds_expr <- ioMsgMaybe $ deSugarExpr hsc_env tc_expr
        liftIO (lintInteractiveExpr "desugar expression" hsc_env ds_expr)
        handleWarnings

        -- Then code-gen, and link it
        -- It's important NOT to have package 'interactive' as thisUnitId
        -- for linking, else we try to link 'main' and can't find it.
        -- Whereas the linker already knows to ignore 'interactive'
        let src_span = srcLocSpan interactiveSrcLoc
        -- TODO: Allow hooks to work
        hval <- liftIO $ hscCompileCoreExpr hsc_env src_span ds_expr

        return $ Just $ Right (ids, hval, fix_env)
    Left reinterpret -> return $ Just $ Left reinterpret

-- | Compile a decls
hscParsedStmt hsc_env stmt = runInteractiveHsc hsc_env $ do
  -- Rename and typecheck it
  eResult <- ioMsgMaybe $ tcRnStmt hsc_env stmt

  case eResult of
    Right (ids, tc_expr, fix_env) -> do

        -- Desugar it
        ds_expr <- ioMsgMaybe $ deSugarExpr hsc_env tc_expr
        liftIO (lintInteractiveExpr "desugar expression" hsc_env ds_expr)
        handleWarnings

        -- Then code-gen, and link it
        -- It's important NOT to have package 'interactive' as thisUnitId
        -- for linking, else we try to link 'main' and can't find it.
        -- Whereas the linker already knows to ignore 'interactive'
        let src_span = srcLocSpan interactiveSrcLoc
        -- TODO: Allow hooks to work
        hval <- liftIO $ hscCompileCoreExpr hsc_env src_span ds_expr

        return $ Just $ Right (ids, hval, fix_env)
    Left reinterpret -> return $ Just $ Left reinterpret

-- | Compile a decls