@@ -17,7 +17,7 @@ module Parser where
1717
1818import Commands
1919
20−import Control.Applicative
20+import Control.Applicative hiding (many)
2121
2222import Text.Parsec hiding ((<|>))
2323
@@ -69,17 +69,36 @@ parseLet = psciParser psciLet
6969parseExpression :: String -> Either ParseError P.Value
7070parseExpression = psciParser psciExpression
7171
72−parseCommands :: String -> Either ParseError (IO Command)
73−parseCommands = either Left (Right . return) . psciParser (choice availableCommands)
72+parseCommands :: String -> Either ParseError Command
73+parseCommands = psciParser $ choice availableCommands
7474
7575psciHelp :: Parsec String P.ParseState Command
76−psciHelp = Help <$ (string ":?" >> spaces)
76+psciHelp = Help <$ (string ":?" *> spaces)
7777
7878psciImport :: Parsec String P.ParseState Command
79−psciImport = Import <$> (string ":i" >> spaces >> P.properName)
79+psciImport = Import <$> (string ":i" *> spaces *> P.properName)
80+
81+psciLoadFile :: Parsec String P.ParseState Command
82+psciLoadFile = LoadFile <$> do
83+ string ":m"
84+ spaces
85+ try (manyTill anyChar space) <|> many1 anyChar
86+
87+psciQuit :: Parsec String P.ParseState Command
88+psciQuit = Quit <$ (string ":q" *> spaces)
89+
90+psciReload :: Parsec String P.ParseState Command
91+psciReload = Reload <$ (string ":r" *> spaces)
92+
93+psciTypeOf :: Parsec String P.ParseState Command
94+psciTypeOf = TypeOf <$> (string ":t" *> spaces *> many anyChar)
8095
8196availableCommands :: [Parsec String P.ParseState Command]
8297availableCommands =
8398 map try [ psciHelp
8499 , psciImport
100+ , psciLoadFile
101+ , psciQuit
102+ , psciReload
103+ , psciTypeOf
85104 ]