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
13tvar :: IParser T.RawType
15 T.Var <$> lowVar <?> "type variable"
18tuple :: IParser T.RawType
20 do ts <- parens (commaSep expr)
23 _ -> return (T.tupleOf ts)
26record :: IParser T.RawType
30 rcrd <- extended <|> normal
35 normal = flip T.Record Nothing <$> commaSep field
37 -- extended record types require at least one field
39 ext <- try (lowVar <* (whitespace >> string "|"))
41 flip T.Record (Just (T.Var ext)) <$> commaSep1 field
45 whitespace >> hasType >> whitespace
49capTypeVar :: IParser String
51 intercalate "." <$> dotSep1 capVar
54constructor0 :: IParser T.RawType
57 return (T.Type (Var.Raw name))
60term :: IParser T.RawType
62 tuple <|> record <|> tvar <|> constructor0
65app :: IParser T.RawType
67 do f <- constructor0 <|> try tupleCtor <?> "type constructor"
68 args <- spacePrefix term
71 _ -> return (T.App f args)
74 n <- length <$> parens (many (char ','))
75 let ctor = "_Tuple" ++ show (if n == 0 then 0 else n+1)
76 return (T.Type (Var.Raw ctor))
79expr :: IParser T.RawType
82 arr <- optionMaybe $ try (whitespace >> arrow)
84 Just _ -> T.Lambda t1 <$> (whitespace >> expr)
88constructor :: IParser (String, [T.RawType])
90 (,) <$> (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