1{-# OPTIONS_GHC -Wall -fno-warn-unused-do-bind #-}
4import Control.Applicative ((<$>),(<*>),(<*))
5import Data.List (intercalate)
8import SourceSyntax.Type as T
12tvar = T.Var <$> lowVar <?> "type variable"
15list = listOf <$> braces expr
17tuple :: IParser T.Type
18tuple = do ts <- parens (commaSep expr)
23record :: IParser T.Type
25 do char '{' ; whitespace
26 rcrd <- extended <|> normal
27 dumbWhitespace ; char '}'
30 normal = flip T.Record Nothing <$> commaSep field
32 -- extended record types require at least one field
34 ext <- try (lowVar <* (whitespace >> string "|"))
36 flip T.Record (Just ext) <$> commaSep1 field
40 whitespace >> hasType >> whitespace
43capTypeVar :: IParser String
44capTypeVar = intercalate "." <$> dotSep1 capVar
46constructor0 :: IParser T.Type
49 return (T.Data name [])
52term = list <|> tuple <|> record <|> tvar <|> constructor0
56 do name <- capTypeVar <|> try tupleCtor <?> "type constructor"
57 args <- spacePrefix term
58 return (T.Data name args)
61 n <- length <$> parens (many (char ','))
62 return $ "_Tuple" ++ show (if n == 0 then 0 else n+1)
67 arr <- optionMaybe $ try (whitespace >> arrow)
69 Just _ -> T.Lambda t1 <$> (whitespace >> expr)
72constructor :: IParser (String, [T.Type])
73constructor = (,) <$> (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