1{-# OPTIONS_GHC -Wall -fno-warn-unused-do-bind #-}
4import Control.Applicative ((<$>),(<*>),(<*))
5import Data.List (intercalate)
6import Text.Parsec ((<|>), (<?>), char, many, optionMaybe, string, try)
8import qualified AST.Type as T
9import qualified AST.Variable as Var
12tvar :: IParser T.RawType
13tvar = T.Var <$> lowVar <?> "type variable"
16tuple :: IParser T.RawType
17tuple = do ts <- parens (commaSep expr)
22record :: IParser T.RawType
24 do char '{' ; whitespace
25 rcrd <- extended <|> normal
26 dumbWhitespace ; char '}'
29 normal = flip T.Record Nothing <$> commaSep field
31 -- extended record types require at least one field
33 ext <- try (lowVar <* (whitespace >> string "|"))
35 flip T.Record (Just (T.Var ext)) <$> commaSep1 field
39 whitespace >> hasType >> whitespace
42capTypeVar :: IParser String
43capTypeVar = intercalate "." <$> dotSep1 capVar
45constructor0 :: IParser T.RawType
48 return (T.Type (Var.Raw name))
50term :: IParser T.RawType
51term = tuple <|> record <|> tvar <|> constructor0
53app :: IParser T.RawType
55 do f <- constructor0 <|> try tupleCtor <?> "type constructor"
56 args <- spacePrefix term
62 n <- length <$> parens (many (char ','))
63 let ctor = "_Tuple" ++ show (if n == 0 then 0 else n+1)
64 return (T.Type (Var.Raw ctor))
66expr :: IParser T.RawType
69 arr <- optionMaybe $ try (whitespace >> arrow)
71 Just _ -> T.Lambda t1 <$> (whitespace >> expr)
74constructor :: IParser (String, [T.RawType])
75constructor = (,) <$> (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