on master help sign in
Add support for "(,,) a b c" as a valid type annotation
5cb82c6Evan Czaplicki
compiler/Parse/Type.hs+5−5
@@ -7,11 +7,7 @@ import Data.List (lookup,intercalate)
7import Text.Parsec
7import Text.Parsec
8import Text.Parsec.Indent
8import Text.Parsec.Indent
9
9
10−import SourceSyntax.Location as Located
11−--import SourceSyntax.PrettyPrint
12import SourceSyntax.Type as T
10import SourceSyntax.Type as T
13−--import qualified SourceSyntax.Expression as Expr
14−--import qualified SourceSyntax.Declaration as Decl
15import Parse.Helpers
11import Parse.Helpers
16import Unique
12import Unique
17
13
@@ -55,9 +51,13 @@ term = list <|> tuple <|> record <|> tvar <|> constructor0
55
51
56app :: IParser T.Type
52app :: IParser T.Type
57app =
53app =
58− do name <- capVar <?> "type constructor"
54+ do name <- capVar <|> try tupleCtor <?> "type constructor"
59 args <- spacePrefix term
55 args <- spacePrefix term
60 return (T.Data name args)
56 return (T.Data name args)
57+ where
58+ tupleCtor = do
59+ n <- length <$> parens (many (char ','))
60+ return $ "_Tuple" ++ show (if n == 0 then 0 else n+1)
61
61
62expr :: IParser T.Type
62expr :: IParser T.Type
63expr =
63expr =