@@ -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-- |
@@ -358,13 +358,13 @@ createTemporaryModule exec PSCiState{psciImportedModuleNames = imports, psciLetB
358358 importDecl m = P.ImportDeclaration m P.Unqualified Nothing
359359 traceModule = P.ModuleName [P.ProperName "Debug", P.ProperName "Trace"]
360360 trace = P.Var (P.Qualified (Just traceModule) (P.Ident "print"))
361− itValue = foldl (\x f -> f x) val lets
362361 mainValue = P.App trace (P.Var (P.Qualified Nothing (P.Ident "it")))
363− itDecl = P.ValueDeclaration (P.Ident "it") P.Value [] $ Right itValue
362+ itDecl = P.ValueDeclaration (P.Ident "it") P.Value [] $ Right val
364363 mainDecl = P.ValueDeclaration (P.Ident "main") P.Value [] $ Right mainValue
365364 decls = if exec then [itDecl, mainDecl] else [itDecl]
366365 in
367− P.Module moduleName ((importDecl `map` imports) ++ decls) Nothing
366+ P.Module moduleName ((importDecl `map` imports) ++ lets ++ decls) Nothing
367+
368368
369369-- |
370370-- Makes a volatile module to hold a non-qualified type synonym for a fully-qualified data type declaration.
@@ -418,10 +418,10 @@ handleDeclaration val = do
418418-- Takes a let declaration and updates the environment, then run a make. If the declaration fails,
419419-- restore the pre-let environment.
420420--
421−handleLet :: (P.Expr -> P.Expr) -> PSCI ()
422−handleLet l = do
421+handleLet :: [P.Declaration] -> PSCI ()
422+handleLet ds = do
423423 st <- PSCI $ lift get
424− let st' = updateLets l st
424+ let st' = updateLets ds st
425425 let m = createTemporaryModule False st' (P.ObjectLiteral [])
426426 e <- psciIO . runMake $ P.make modulesDir options (psciLoadedModules st' ++ [(Left P.RebuildAlways, m)]) []
427427 case e of