@@ -69,7 +69,7 @@ data PSCiState = PSCiState
6969 { psciImportedFilenames :: [FilePath]
7070 , psciImportedModuleNames :: [P.ModuleName]
7171 , psciLoadedModules :: [(Either P.RebuildPolicy FilePath, P.Module)]
72− , psciLetBindings :: [P.Expr -> P.Expr]
72+ , psciLetBindings :: [P.Declaration]
7373 }
7474
7575-- State helpers
@@ -95,8 +95,8 @@ updateModules modules st = st { psciLoadedModules = psciLoadedModules st ++ modu
9595-- |
9696-- Updates the state to have more let bindings.
9797--
98−updateLets :: (P.Expr -> P.Expr) -> PSCiState -> PSCiState
99−updateLets name st = st { psciLetBindings = name : psciLetBindings st }
98+updateLets :: [P.Declaration] -> PSCiState -> PSCiState
99+updateLets ds st = st { psciLetBindings = ds ++ psciLetBindings st }
100100
101101-- File helpers
102102-- |
@@ -348,13 +348,13 @@ createTemporaryModule exec PSCiState{psciImportedModuleNames = imports, psciLetB
348348 importDecl m = P.ImportDeclaration m P.Unqualified Nothing
349349 traceModule = P.ModuleName [P.ProperName "Debug", P.ProperName "Trace"]
350350 trace = P.Var (P.Qualified (Just traceModule) (P.Ident "print"))
351− itValue = foldl (\x f -> f x) val lets
352351 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
354353 mainDecl = P.ValueDeclaration (P.Ident "main") P.Value [] $ Right mainValue
355354 decls = if exec then [itDecl, mainDecl] else [itDecl]
356355 in
357− P.Module moduleName ((importDecl `map` imports) ++ decls) Nothing
356+ P.Module moduleName ((importDecl `map` imports) ++ lets ++ decls) Nothing
357+
358358
359359-- |
360360-- 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
408408-- Takes a let declaration and updates the environment, then run a make. If the declaration fails,
409409-- restore the pre-let environment.
410410--
411−handleLet :: (P.Expr -> P.Expr) -> PSCI ()
412−handleLet l = do
411+handleLet :: [P.Declaration] -> PSCI ()
412+handleLet ds = do
413413 st <- PSCI $ lift get
414− let st' = updateLets l st
414+ let st' = updateLets ds st
415415 let m = createTemporaryModule False st' (P.ObjectLiteral [])
416416 e <- psciIO . runMake $ P.make modulesDir options (psciLoadedModules st' ++ [(Left P.RebuildAlways, m)]) []
417417 case e of