forked from purescript/purescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKinds.hs
More file actions
40 lines (32 loc) · 1.01 KB
/
Kinds.hs
File metadata and controls
40 lines (32 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
-- |
-- A parser for kinds
--
module Language.PureScript.Parser.Kinds (parseKind) where
import Prelude.Compat
import Language.PureScript.Environment
import Language.PureScript.Kinds
import Language.PureScript.Parser.Common
import Language.PureScript.Parser.Lexer
import qualified Text.Parsec as P
import qualified Text.Parsec.Expr as P
parseStar :: TokenParser Kind
parseStar = const kindType <$> symbol' "*"
parseBang :: TokenParser Kind
parseBang = const kindEffect <$> symbol' "!"
parseNamedKind :: TokenParser Kind
parseNamedKind = NamedKind <$> parseQualified kindName
parseKindAtom :: TokenParser Kind
parseKindAtom = indented *> P.choice
[ parseStar
, parseBang
, parseNamedKind
, parens parseKind
]
-- |
-- Parse a kind
--
parseKind :: TokenParser Kind
parseKind = P.buildExpressionParser operators parseKindAtom P.<?> "kind"
where
operators = [ [ P.Prefix (symbol' "#" >> return Row) ]
, [ P.Infix (rarrow >> return FunKind) P.AssocRight ] ]