-hscStmt dflags hst hit pcs0 icontext stmt just_expr
- = do { maybe_stmt <- hscParseStmt dflags stmt
- ; case maybe_stmt of
- Nothing -> return (pcs0, Nothing)
- Just parsed_stmt -> do {
-
- let { notExprStmt (ExprStmt _ _ _) = False;
- notExprStmt _ = True
- };
-
- if (just_expr && notExprStmt parsed_stmt)
- then do hPutStrLn stderr ("not an expression: `" ++ stmt ++ "'")
- return (pcs0, Nothing)
- else do {
-
- -- Rename it
- (pcs1, print_unqual, maybe_renamed_stmt)
- <- renameStmt dflags hit hst pcs0 icontext parsed_stmt
-
- ; case maybe_renamed_stmt of
- Nothing -> return (pcs0, Nothing)
- Just (bound_names, rn_stmt) -> do {
-
- -- Typecheck it
- maybe_tc_return <-
- if just_expr
- then case rn_stmt of { (ExprStmt e _ _, decls) ->
- typecheckExpr dflags pcs1 hst (ic_type_env icontext)
- print_unqual iNTERACTIVE (e,decls) }
- else typecheckStmt dflags pcs1 hst (ic_type_env icontext)
- print_unqual iNTERACTIVE bound_names rn_stmt
-
- ; case maybe_tc_return of
- Nothing -> return (pcs0, Nothing)
- Just (pcs2, tc_expr, bound_ids, ty) -> do {
-
- -- Desugar it
- ds_expr <- deSugarExpr dflags pcs2 hst iNTERACTIVE print_unqual tc_expr
-
- -- Flatten it
- ; flat_expr <- flattenExpr dflags pcs2 hst ds_expr
-
- -- Simplify it
- ; simpl_expr <- simplifyExpr dflags pcs2 hst flat_expr
+#ifdef GHCI
+hscStmt -- Compile a stmt all the way to an HValue, but don't run it
+ :: HscEnv
+ -> InteractiveContext -- Context for compiling
+ -> String -- The statement
+ -> IO (Maybe (InteractiveContext, [Name], HValue))