@@ -1,18 +1,63 @@
1+-----------------------------------------------------------------------------
4+-- Copyright : (c) Phil Freeman 2014
7+-- Maintainer : Phil Freeman <paf31@cantab.net>
8+-- Stability : experimental
14+-----------------------------------------------------------------------------
1module Commands where
16module Commands where
3import Control.Applicative
18import Control.Applicative
4import System.Console.Haskeline
19import System.Console.Haskeline
22+-- Valid Meta-commands for PSCI
6data Command
24data Command
30+ -- A purescript expression
8 | Expression [String]
32 | Expression [String]
34+ -- Show the help command
38+ -- Import a module from a loaded file
10 | Import String
40 | Import String
42+ -- Load a file for use with importing
11 | LoadFile FilePath
44 | LoadFile FilePath
50+ -- Reload the current modules
54+ -- An attempt at a meta command that wasn't recognized.
14 | Unknown deriving (Show, Eq)
56 | Unknown deriving (Show, Eq)
59+-- Parses the input and returns either a Metacommand or an expression.
16getCommand :: InputT IO Command
61getCommand :: InputT IO Command
17getCommand = do
62getCommand = do
18 firstLine <- getInputLine "> "
63 firstLine <- getInputLine "> "
@@ -32,6 +77,9 @@ getCommand = do
32 Nothing -> return $ reverse ls
77 Nothing -> return $ reverse ls
33 Just l' -> go (l' : ls)
78 Just l' -> go (l' : ls)
35help :: [[String]]
83help :: [[String]]
37 [ [":? ", "Show this help menu"]
85 [ [":? ", "Show this help menu"]