1-----------------------------------------------------------------------------
3-- Module : PureScript.Parser.Declarations
4-- Copyright : (c) Phil Freeman 2013
7-- Maintainer : Phil Freeman <paf31@cantab.net>
8-- Stability : experimental
13-----------------------------------------------------------------------------
15module PureScript.Parser.Declarations (
23import Control.Applicative
24import qualified Text.Parsec as P
25import Control.Arrow (Arrow(..))
27import PureScript.Values
28import PureScript.Types
29import PureScript.Parser.Common
30import PureScript.Declarations
31import PureScript.Parser.Values
32import PureScript.Parser.Types
34parseDataDeclaration :: P.Parsec String () Declaration
35parseDataDeclaration = do
38 tyArgs <- many identifier
40 ctors <- P.sepBy1 ((,) <$> properName <*> P.optionMaybe parseType) (lexeme $ P.char '|')
41 return $ DataDeclaration $ DataConstructors name tyArgs ctors
43parseValueDeclaration :: P.Parsec String () Declaration
44parseValueDeclaration = ValueDeclaration <$> identifier <*> (lexeme (P.char '=') *> parseValue)
46parseDeclaration :: P.Parsec String () Declaration
47parseDeclaration = parseDataDeclaration
48 P.<|> parseValueDeclaration
50parseDeclarations :: String -> Either P.ParseError [Declaration]
51parseDeclarations = mapM (P.parse (parseDeclaration <* whiteSpace <* P.eof) "Declaration") . splitFileIntoDeclarations
53splitFileIntoDeclarations :: String -> [String]
54splitFileIntoDeclarations = map unlines . filter (not . all isSpace . head) . groupBy ((==) `on` (all isSpace)) . lines
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