@@ -32,7 +32,8 @@ psciModules = P.parseModules
3232-- |
3333-- PSCI version of 'let'.
3434-- This is essentially let from do-notation.
35−-- However, since we don't support the 'Eff' monad, we actually want the normal 'let'.
35+-- However, since we don't support the 'Eff' monad,
36+-- we actually want the normal 'let'.
3637--
3738psciLet :: Parsec String P.ParseState (P.Value -> P.Value)
3839psciLet = P.Let <$> (P.reserved "let" *> P.indented *> P.parseBinder)
@@ -72,30 +73,35 @@ parseExpression = psciParser psciExpression
7273parseCommands :: String -> Either ParseError Command
7374parseCommands = psciParser $ choice availableCommands
7475
76+psciExpr :: Parsec String P.ParseState Command
77+psciExpr = Expression <$> (lookAhead (try (satisfy (/= ':'))) *> many1 anyChar)
78+
7579psciHelp :: Parsec String P.ParseState Command
76−psciHelp = Help <$ (string ":?" *> spaces)
80+psciHelp = Help <$ (spaces *> string ":?" *> spaces)
7781
7882psciImport :: Parsec String P.ParseState Command
79−psciImport = Import <$> (string ":i" *> spaces *> P.properName)
83+psciImport = Import <$> (spaces *> string ":i" *> spaces *> P.properName)
8084
8185psciLoadFile :: Parsec String P.ParseState Command
8286psciLoadFile = LoadFile <$> do
87+ spaces
8388 string ":m"
8489 spaces
8590 try (manyTill anyChar space) <|> many1 anyChar
8691
8792psciQuit :: Parsec String P.ParseState Command
88−psciQuit = Quit <$ (string ":q" *> spaces)
93+psciQuit = Quit <$ (spaces *> string ":q" *> spaces)
8994
9095psciReload :: Parsec String P.ParseState Command
91−psciReload = Reload <$ (string ":r" *> spaces)
96+psciReload = Reload <$ (spaces *> string ":r" *> spaces)
9297
9398psciTypeOf :: Parsec String P.ParseState Command
94−psciTypeOf = TypeOf <$> (string ":t" *> spaces *> many anyChar)
99+psciTypeOf = TypeOf <$> (spaces *> string ":t" *> spaces *> many anyChar)
95100
96101availableCommands :: [Parsec String P.ParseState Command]
97102availableCommands =
98− map try [ psciHelp
103+ map try [ psciExpr
104+ , psciHelp
99105 , psciImport
100106 , psciLoadFile
101107 , psciQuit