1{-# OPTIONS_GHC -Wall -fno-warn-unused-do-bind #-}
4import Control.Applicative ((<$>),(<*>),(<*))
5import Data.List (intercalate)
8import qualified AST.Type as T
9import qualified AST.Variable as Var
12tvar :: IParser T.RawType
13tvar = T.Var <$> lowVar <?> "type variable"
15list :: IParser T.RawType
16list = T.listOf <$> braces expr
18tuple :: IParser T.RawType
19tuple = do ts <- parens (commaSep expr)
24record :: IParser T.RawType
26 do char '{' ; whitespace
27 rcrd <- extended <|> normal
28 dumbWhitespace ; char '}'
31 normal = flip T.Record Nothing <$> commaSep field
33 -- extended record types require at least one field
35 ext <- try (lowVar <* (whitespace >> string "|"))
37 flip T.Record (Just (T.Var ext)) <$> commaSep1 field
41 whitespace >> hasType >> whitespace
44capTypeVar :: IParser String
45capTypeVar = intercalate "." <$> dotSep1 capVar
47constructor0 :: IParser T.RawType
50 return (T.Type (Var.Raw name))
52term :: IParser T.RawType
53term = list <|> tuple <|> record <|> tvar <|> constructor0
55app :: IParser T.RawType
57 do f <- constructor0 <|> tvar <|> try tupleCtor <?> "type constructor"
58 args <- spacePrefix term
64 n <- length <$> parens (many (char ','))
65 let ctor = "_Tuple" ++ show (if n == 0 then 0 else n+1)
66 return (T.Type (Var.Raw ctor))
68expr :: IParser T.RawType
71 arr <- optionMaybe $ try (whitespace >> arrow)
73 Just _ -> T.Lambda t1 <$> (whitespace >> expr)
76constructor :: IParser (String, [T.RawType])
77constructor = (,) <$> (capTypeVar <?> "another type constructor")
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