@@ -69,7 +69,7 @@ data PSCiState = PSCiState
69 { psciImportedFilenames :: [FilePath]
69 { psciImportedFilenames :: [FilePath]
70 , psciImportedModuleNames :: [P.ModuleName]
70 , psciImportedModuleNames :: [P.ModuleName]
71 , psciLoadedModules :: [(Either P.RebuildPolicy FilePath, P.Module)]
71 , psciLoadedModules :: [(Either P.RebuildPolicy FilePath, P.Module)]
72− , psciLetBindings :: [P.Expr -> P.Expr]
72+ , psciLetBindings :: [P.Declaration]
75-- State helpers
75-- State helpers
@@ -95,8 +95,8 @@ updateModules modules st = st { psciLoadedModules = psciLoadedModules st ++ modu
96-- Updates the state to have more let bindings.
96-- Updates the state to have more let bindings.
98−updateLets :: (P.Expr -> P.Expr) -> PSCiState -> PSCiState
98+updateLets :: [P.Declaration] -> PSCiState -> PSCiState
99−updateLets name st = st { psciLetBindings = name : psciLetBindings st }
99+updateLets ds st = st { psciLetBindings = ds ++ psciLetBindings st }
101-- File helpers
101-- File helpers
@@ -348,13 +348,13 @@ createTemporaryModule exec PSCiState{psciImportedModuleNames = imports, psciLetB
348 importDecl m = P.ImportDeclaration m P.Unqualified Nothing
348 importDecl m = P.ImportDeclaration m P.Unqualified Nothing
349 traceModule = P.ModuleName [P.ProperName "Debug", P.ProperName "Trace"]
349 traceModule = P.ModuleName [P.ProperName "Debug", P.ProperName "Trace"]
350 trace = P.Var (P.Qualified (Just traceModule) (P.Ident "print"))
350 trace = P.Var (P.Qualified (Just traceModule) (P.Ident "print"))
351− itValue = foldl (\x f -> f x) val lets
352 mainValue = P.App trace (P.Var (P.Qualified Nothing (P.Ident "it")))
351 mainValue = P.App trace (P.Var (P.Qualified Nothing (P.Ident "it")))
353− itDecl = P.ValueDeclaration (P.Ident "it") P.Value [] $ Right itValue
352+ itDecl = P.ValueDeclaration (P.Ident "it") P.Value [] $ Right val
354 mainDecl = P.ValueDeclaration (P.Ident "main") P.Value [] $ Right mainValue
353 mainDecl = P.ValueDeclaration (P.Ident "main") P.Value [] $ Right mainValue
355 decls = if exec then [itDecl, mainDecl] else [itDecl]
354 decls = if exec then [itDecl, mainDecl] else [itDecl]
357− P.Module moduleName ((importDecl `map` imports) ++ decls) Nothing
356+ P.Module moduleName ((importDecl `map` imports) ++ lets ++ decls) Nothing
360-- Makes a volatile module to hold a non-qualified type synonym for a fully-qualified data type declaration.
360-- Makes a volatile module to hold a non-qualified type synonym for a fully-qualified data type declaration.
@@ -408,10 +408,10 @@ handleDeclaration val = do
408-- Takes a let declaration and updates the environment, then run a make. If the declaration fails,
408-- Takes a let declaration and updates the environment, then run a make. If the declaration fails,
409-- restore the pre-let environment.
409-- restore the pre-let environment.
411−handleLet :: (P.Expr -> P.Expr) -> PSCI ()
411+handleLet :: [P.Declaration] -> PSCI ()
412−handleLet l = do
412+handleLet ds = do
413 st <- PSCI $ lift get
413 st <- PSCI $ lift get
414− let st' = updateLets l st
414+ let st' = updateLets ds st
415 let m = createTemporaryModule False st' (P.ObjectLiteral [])
415 let m = createTemporaryModule False st' (P.ObjectLiteral [])
416 e <- psciIO . runMake $ P.make modulesDir options (psciLoadedModules st' ++ [(Left P.RebuildAlways, m)]) []
416 e <- psciIO . runMake $ P.make modulesDir options (psciLoadedModules st' ++ [(Left P.RebuildAlways, m)]) []
417 case e of
417 case e of