git.iko.soy/rowtype-yoga/purescript-native
on ea83764 help sign in
41 lines 1.2 kB history raw
1-----------------------------------------------------------------------------
2--
3-- Module : PureScript.Parser.Kinds
4-- Copyright : (c) Phil Freeman 2013
5-- License : MIT
6--
7-- Maintainer : Phil Freeman <paf31@cantab.net>
8-- Stability : experimental
9-- Portability :
10--
11-- |
12--
13-----------------------------------------------------------------------------
15module PureScript.Parser.Kinds (
16 parseKind
17) where
19import PureScript.Kinds
20import PureScript.Parser.State
21import PureScript.Parser.Common
22import Control.Applicative
23import qualified Text.Parsec as P
24import qualified Text.Parsec.Expr as P
26parseStar :: P.Parsec String ParseState Kind
27parseStar = const Star <$> lexeme (P.char '*')
29parseRow :: P.Parsec String ParseState Kind
30parseRow = const Row <$> lexeme (P.char '#')
32parseTypeAtom :: P.Parsec String ParseState Kind
33parseTypeAtom = indented *> P.choice (map P.try
34 [ parseStar
35 , parseRow
36 , parens parseKind ])
38parseKind :: P.Parsec String ParseState Kind
39parseKind = P.buildExpressionParser operators parseTypeAtom P.<?> "kind"
40 where
41 operators = [ [ P.Infix (lexeme (P.try (P.string "->")) >> return FunKind) P.AssocRight ] ]