@@ -1,18 +1,63 @@
1+-----------------------------------------------------------------------------
2+--
3+-- Module : Main
4+-- Copyright : (c) Phil Freeman 2014
5+-- License : MIT
6+--
7+-- Maintainer : Phil Freeman <paf31@cantab.net>
8+-- Stability : experimental
9+-- Portability :
10+--
11+-- |
12+-- Commands for PSCI.
13+--
14+-----------------------------------------------------------------------------
15+
116module Commands where
217
318import Control.Applicative
419import System.Console.Haskeline
520
21+-- |
22+-- Valid Meta-commands for PSCI
23+--
624data Command
25+ -- |
26+ -- And empty line
27+ --
728 = Empty
29+ -- |
30+ -- A purescript expression
31+ --
832 | Expression [String]
33+ -- |
34+ -- Show the help command
35+ --
936 | Help
37+ -- |
38+ -- Import a module from a loaded file
39+ --
1040 | Import String
41+ -- |
42+ -- Load a file for use with importing
43+ --
1144 | LoadFile FilePath
45+ -- |
46+ -- Exit PSCI
47+ --
1248 | Quit
49+ -- |
50+ -- Reload the current modules
51+ --
1352 | Reload
53+ -- |
54+ -- An attempt at a meta command that wasn't recognized.
55+ --
1456 | Unknown deriving (Show, Eq)
1557
58+-- |
59+-- Parses the input and returns either a Metacommand or an expression.
60+--
1661getCommand :: InputT IO Command
1762getCommand = do
1863 firstLine <- getInputLine "> "
@@ -32,6 +77,9 @@ getCommand = do
3277 Nothing -> return $ reverse ls
3378 Just l' -> go (l' : ls)
3479
80+-- |
81+-- The help menu.
82+--
3583help :: [[String]]
3684help =
3785 [ [":? ", "Show this help menu"]