@@ -17,7 +17,7 @@ module Parser where
18import Commands
18import Commands
20−import Control.Applicative
20+import Control.Applicative hiding (many)
22import Text.Parsec hiding ((<|>))
22import Text.Parsec hiding ((<|>))
@@ -69,17 +69,36 @@ parseLet = psciParser psciLet
69parseExpression :: String -> Either ParseError P.Value
69parseExpression :: String -> Either ParseError P.Value
70parseExpression = psciParser psciExpression
70parseExpression = psciParser psciExpression
72−parseCommands :: String -> Either ParseError (IO Command)
72+parseCommands :: String -> Either ParseError Command
73−parseCommands = either Left (Right . return) . psciParser (choice availableCommands)
73+parseCommands = psciParser $ choice availableCommands
75psciHelp :: Parsec String P.ParseState Command
75psciHelp :: Parsec String P.ParseState Command
76−psciHelp = Help <$ (string ":?" >> spaces)
76+psciHelp = Help <$ (string ":?" *> spaces)
78psciImport :: Parsec String P.ParseState Command
78psciImport :: Parsec String P.ParseState Command
79−psciImport = Import <$> (string ":i" >> spaces >> P.properName)
79+psciImport = Import <$> (string ":i" *> spaces *> P.properName)
81+psciLoadFile :: Parsec String P.ParseState Command
82+psciLoadFile = LoadFile <$> do
85+ try (manyTill anyChar space) <|> many1 anyChar
87+psciQuit :: Parsec String P.ParseState Command
88+psciQuit = Quit <$ (string ":q" *> spaces)
90+psciReload :: Parsec String P.ParseState Command
91+psciReload = Reload <$ (string ":r" *> spaces)
93+psciTypeOf :: Parsec String P.ParseState Command
94+psciTypeOf = TypeOf <$> (string ":t" *> spaces *> many anyChar)
81availableCommands :: [Parsec String P.ParseState Command]
96availableCommands :: [Parsec String P.ParseState Command]
82availableCommands =
97availableCommands =
83 map try [ psciHelp
98 map try [ psciHelp
84 , psciImport
99 , psciImport