1{-# OPTIONS_GHC -Wall -fno-warn-unused-do-bind #-}
4import Data.List (intercalate)
5import Text.Parsec ((<|>), (<?>), char, choice, many, optionMaybe, string, try)
7import qualified AST.Type as Type
8import qualified AST.Variable as Var
10import qualified Reporting.Annotation as A
11import qualified Reporting.Region as R
14tvar :: IParser Type.Raw
17 (Type.RVar <$> lowVar <?> "a type variable")
20tuple :: IParser Type.Raw
22 do (start, types, end) <- located (parens (commaSep expr))
25 _ -> return (Type.tuple (R.Region start end) types)
28record :: IParser Type.Raw
33 rcrd <- extended <|> normal
38 normal = flip Type.RRecord Nothing <$> commaSep field
40 -- extended record types require at least one field
42 do ext <- try (addLocation lowVar <* (whitespace >> string "|"))
44 fields <- commaSep1 field
45 return (Type.RRecord fields (Just (A.map Type.RVar ext)))
49 whitespace >> hasType >> whitespace
53capTypeVar :: IParser String
55 intercalate "." <$> dotSep1 capVar
58constructor0 :: IParser Type.Raw
62 return (Type.RType (Var.Raw name))
65term :: IParser Type.Raw
67 choice [ tuple, record, tvar, constructor0 ]
70app :: IParser Type.Raw
72 do start <- getMyPosition
73 f <- constructor0 <|> try tupleCtor <?> "a type constructor"
74 args <- spacePrefix term
78 _ -> return (A.A (R.Region start end) (Type.RApp f args))
82 do n <- length <$> parens (many (char ','))
83 let ctor = "_Tuple" ++ show (if n == 0 then 0 else n+1)
84 return (Type.RType (Var.Raw ctor))
87expr :: IParser Type.Raw
89 do start <- getMyPosition
91 arr <- optionMaybe $ try (whitespace >> rightArrow)
99 return (A.A (R.Region start end) (Type.RLambda t1 t2))
102constructor :: IParser (String, [Type.Raw])
104 (,) <$> (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