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 Type
9import qualified AST.Variable as Var
11import qualified Reporting.Annotation as A
12import qualified Reporting.Region as R
15tvar :: IParser Type.Raw
18 (Type.RVar <$> lowVar <?> "type variable")
21tuple :: IParser Type.Raw
23 do (start, types, end) <- located (parens (commaSep expr))
26 _ -> return (Type.tuple (R.Region start end) types)
29record :: IParser Type.Raw
34 rcrd <- extended <|> normal
39 normal = flip Type.RRecord Nothing <$> commaSep field
41 -- extended record types require at least one field
43 do ext <- try (addLocation lowVar <* (whitespace >> string "|"))
45 fields <- commaSep1 field
46 return (Type.RRecord fields (Just (A.map Type.RVar ext)))
50 whitespace >> hasType >> whitespace
54capTypeVar :: IParser String
56 intercalate "." <$> dotSep1 capVar
59constructor0 :: IParser Type.Raw
63 return (Type.RType (Var.Raw name))
66term :: IParser Type.Raw
68 tuple <|> record <|> tvar <|> constructor0
71app :: IParser Type.Raw
73 do start <- getMyPosition
74 f <- constructor0 <|> try tupleCtor <?> "type constructor"
75 args <- spacePrefix term
79 _ -> return (A.A (R.Region start end) (Type.RApp f args))
83 do n <- length <$> parens (many (char ','))
84 let ctor = "_Tuple" ++ show (if n == 0 then 0 else n+1)
85 return (Type.RType (Var.Raw ctor))
88expr :: IParser Type.Raw
90 do start <- getMyPosition
92 arr <- optionMaybe $ try (whitespace >> arrow)
100 return (A.A (R.Region start end) (Type.RLambda t1 t2))
103constructor :: IParser (String, [Type.Raw])
105 (,) <$> (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