@@ -9,21 +9,19 @@ import qualified AST.Type as T
99import qualified AST.Variable as Var
1010import Parse.Helpers
1111
12−type RawType = T.Type Var.Raw
13−
14−tvar :: IParser RawType
12+tvar :: IParser T.RawType
1513tvar = T.Var <$> lowVar <?> "type variable"
1614
17−list :: IParser RawType
15+list :: IParser T.RawType
1816list = T.listOf <$> braces expr
1917
20−tuple :: IParser RawType
18+tuple :: IParser T.RawType
2119tuple = do ts <- parens (commaSep expr)
2220 return $ case ts of
2321 [t] -> t
2422 _ -> T.tupleOf ts
2523
26−record :: IParser RawType
24+record :: IParser T.RawType
2725record =
2826 do char '{' ; whitespace
2927 rcrd <- extended <|> normal
@@ -46,15 +44,15 @@ record =
4644capTypeVar :: IParser String
4745capTypeVar = intercalate "." <$> dotSep1 capVar
4846
49−constructor0 :: IParser RawType
47+constructor0 :: IParser T.RawType
5048constructor0 =
5149 do name <- capTypeVar
5250 return (T.Data (Var.Raw name) [])
5351
54−term :: IParser RawType
52+term :: IParser T.RawType
5553term = list <|> tuple <|> record <|> tvar <|> constructor0
5654
57−app :: IParser RawType
55+app :: IParser T.RawType
5856app =
5957 do name <- capTypeVar <|> try tupleCtor <?> "type constructor"
6058 args <- spacePrefix term
@@ -64,7 +62,7 @@ app =
6462 n <- length <$> parens (many (char ','))
6563 return $ "_Tuple" ++ show (if n == 0 then 0 else n+1)
6664
67−expr :: IParser RawType
65+expr :: IParser T.RawType
6866expr =
6967 do t1 <- app <|> term
7068 arr <- optionMaybe $ try (whitespace >> arrow)
@@ -72,6 +70,6 @@ expr =
7270 Just _ -> T.Lambda t1 <$> (whitespace >> expr)
7371 Nothing -> return t1
7472
75−constructor :: IParser (String, [RawType])
73+constructor :: IParser (String, [T.RawType])
7674constructor = (,) <$> (capTypeVar <?> "another type constructor")
7775 <*> spacePrefix term