1-----------------------------------------------------------------------------
4-- Copyright : (c) Phil Freeman 2014
7-- Maintainer : Phil Freeman <paf31@cantab.net>
8-- Stability : experimental
14-----------------------------------------------------------------------------
22import Data.Char (isSpace)
24import Control.Applicative hiding (many)
26import Text.Parsec hiding ((<|>))
28import qualified Language.PureScript as P
29import qualified Language.PureScript.Parser.Common as C (mark, same)
32-- PSCI version of @let@.
33-- This is essentially let from do-notation.
34-- However, since we don't support the @Eff@ monad,
35-- we actually want the normal @let@.
37psciLet :: Parsec String P.ParseState Command
38psciLet = Let <$> (P.Let <$> (P.reserved "let" *> P.indented *> C.mark (many1 (C.same *> P.parseDeclaration))))
41-- Parses PSCI metacommands or expressions input from the user.
43parseCommand :: String -> Either ParseError Command
44parseCommand = P.runIndentParser "" $ choice
45 [ P.whiteSpace *> char ':' *> (psciHelp <|> psciImport <|> psciLoadFile <|> psciQuit <|> psciReload <|> psciTypeOf)
51-- Parses expressions entered at the PSCI repl.
53psciExpression :: Parsec String P.ParseState Command
54psciExpression = Expression <$> P.parseValue
57-- Parses 'Commands.Help' command.
59psciHelp :: Parsec String P.ParseState Command
60psciHelp = Help <$ char '?'
63-- Parses 'Commands.Import' command.
65psciImport :: Parsec String P.ParseState Command
66psciImport = Import <$> (char 'i' *> P.whiteSpace *> P.moduleName)
69-- Parses 'Commands.LoadFile' command.
71psciLoadFile :: Parsec String P.ParseState Command
72psciLoadFile = LoadFile . trimEnd <$> (char 'm' *> P.whiteSpace *> manyTill anyChar eof)
74 trimEnd = reverse . dropWhile isSpace . reverse
77-- Parses 'Commands.Quit' command.
79psciQuit :: Parsec String P.ParseState Command
80psciQuit = Quit <$ char 'q'
83-- Parses 'Commands.Reload' command.
85psciReload :: Parsec String P.ParseState Command
86psciReload = Reset <$ char 'r'
89-- Parses 'Commands.TypeOf' command.
91psciTypeOf :: Parsec String P.ParseState Command
92psciTypeOf = TypeOf <$> (char 't' *> P.whiteSpace *> P.parseValue)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list