@@ -15,8 +15,9 @@
16module Commands where
16module Commands where
18−import Control.Applicative
18+import Language.PureScript
19−import System.Console.Haskeline
19+
22-- Valid Meta-commands for PSCI
23-- Valid Meta-commands for PSCI
@@ -37,7 +38,7 @@ data Command
38 -- Import a module from a loaded file
39 -- Import a module from a loaded file
40− | Import String
41+ | Import ProperName
42 -- Load a file for use with importing
43 -- Load a file for use with importing
@@ -57,30 +58,31 @@ data Command
58 -- An attempt at a meta command that wasn't recognized.
59 -- An attempt at a meta command that wasn't recognized.
60− | Unknown deriving (Show, Eq)
61+ | Unknown ParseError
63−-- Parses the input and returns either a Metacommand or an expression.
64+---- Parses the input and returns either a Metacommand or an expression.
65−getCommand :: InputT IO Command
66+--getCommand :: InputT IO Command
66−getCommand = do
67+--getCommand = do
67− firstLine <- getInputLine "> "
68+-- firstLine <- getInputLine "> "
68− case firstLine of
69+-- case firstLine of
69− Nothing -> return Empty
70+-- Nothing -> return Empty
71+-- Just line -> psciParser psciHelp
70− Just ":?" -> return Help
72+-- --Just ":?" -> return Help
71− Just (':':'i':' ':moduleName) -> return $ Import moduleName
73+-- --Just (':':'i':' ':moduleName) -> return $ Import moduleName
72− Just (':':'m':' ':filePath) -> return $ LoadFile filePath
74+-- --Just (':':'m':' ':filePath) -> return $ LoadFile filePath
73− Just ":q" -> return Quit
75+-- --Just ":q" -> return Quit
74− Just ":r" -> return Reload
76+-- --Just ":r" -> return Reload
75− Just (':':'t':' ':expr) -> return $ TypeOf expr
77+-- --Just (':':'t':' ':expr) -> return $ TypeOf expr
76− Just (':':_) -> return Unknown
78+-- --Just (':':_) -> return Unknown
77− Just other -> Expression <$> go [other]
79+-- --Just other -> Expression <$> go [other]
79− go ls = do
81+-- go ls = do
80− l <- getInputLine " "
82+-- l <- getInputLine " "
81− case l of
83+-- case l of
82− Nothing -> return $ reverse ls
84+-- Nothing -> return $ reverse ls
83− Just l' -> go (l' : ls)
85+-- Just l' -> go (l' : ls)
86-- The help menu.
88-- The help menu.