@@ -32,7 +32,8 @@ psciModules = P.parseModules
33-- PSCI version of 'let'.
33-- PSCI version of 'let'.
34-- This is essentially let from do-notation.
34-- 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'.
37psciLet :: Parsec String P.ParseState (P.Value -> P.Value)
38psciLet :: Parsec String P.ParseState (P.Value -> P.Value)
38psciLet = P.Let <$> (P.reserved "let" *> P.indented *> P.parseBinder)
39psciLet = P.Let <$> (P.reserved "let" *> P.indented *> P.parseBinder)
@@ -72,30 +73,35 @@ parseExpression = psciParser psciExpression
72parseCommands :: String -> Either ParseError Command
73parseCommands :: String -> Either ParseError Command
73parseCommands = psciParser $ choice availableCommands
74parseCommands = psciParser $ choice availableCommands
76+psciExpr :: Parsec String P.ParseState Command
77+psciExpr = Expression <$> (lookAhead (try (satisfy (/= ':'))) *> many1 anyChar)
75psciHelp :: Parsec String P.ParseState Command
79psciHelp :: Parsec String P.ParseState Command
76−psciHelp = Help <$ (string ":?" *> spaces)
80+psciHelp = Help <$ (spaces *> string ":?" *> spaces)
78psciImport :: Parsec String P.ParseState Command
82psciImport :: Parsec String P.ParseState Command
79−psciImport = Import <$> (string ":i" *> spaces *> P.properName)
83+psciImport = Import <$> (spaces *> string ":i" *> spaces *> P.properName)
81psciLoadFile :: Parsec String P.ParseState Command
85psciLoadFile :: Parsec String P.ParseState Command
82psciLoadFile = LoadFile <$> do
86psciLoadFile = LoadFile <$> do
83 string ":m"
88 string ":m"
85 try (manyTill anyChar space) <|> many1 anyChar
90 try (manyTill anyChar space) <|> many1 anyChar
87psciQuit :: Parsec String P.ParseState Command
92psciQuit :: Parsec String P.ParseState Command
88−psciQuit = Quit <$ (string ":q" *> spaces)
93+psciQuit = Quit <$ (spaces *> string ":q" *> spaces)
90psciReload :: Parsec String P.ParseState Command
95psciReload :: Parsec String P.ParseState Command
91−psciReload = Reload <$ (string ":r" *> spaces)
96+psciReload = Reload <$ (spaces *> string ":r" *> spaces)
93psciTypeOf :: Parsec String P.ParseState Command
98psciTypeOf :: Parsec String P.ParseState Command
94−psciTypeOf = TypeOf <$> (string ":t" *> spaces *> many anyChar)
99+psciTypeOf = TypeOf <$> (spaces *> string ":t" *> spaces *> many anyChar)
96availableCommands :: [Parsec String P.ParseState Command]
101availableCommands :: [Parsec String P.ParseState Command]
97availableCommands =
102availableCommands =
98− map try [ psciHelp
104+ , psciHelp
99 , psciImport
105 , psciImport
100 , psciLoadFile
106 , psciLoadFile
101 , psciQuit
107 , psciQuit