on master help sign in
Be more flexible with the position of the closing bracket of a record type.
08ff939Evan Czaplicki
compiler/Parse/Helpers.hs+4
@@ -156,6 +156,10 @@ forcedWS :: IParser [String]
156forcedWS = try (do { spaces; many nl_space }) <|> try (many1 nl_space)
156forcedWS = try (do { spaces; many nl_space }) <|> try (many1 nl_space)
157 where nl_space = try $ many1 newline >> spaces
157 where nl_space = try $ many1 newline >> spaces
158
158
159+-- Just eats whitespace until the next meaningful character.
160+dumbWhitespace :: IParser ()
161+dumbWhitespace = many (spaces <|> newline) >> return ()
162+
159whitespace :: IParser ()
163whitespace :: IParser ()
160whitespace = optional forcedWS <?> ""
164whitespace = optional forcedWS <?> ""
161
165
compiler/Parse/Type.hs+7−4
@@ -28,10 +28,12 @@ tuple = do ts <- parens (commaSep expr)
28 _ -> tupleOf ts
28 _ -> tupleOf ts
29
29
30record :: IParser T.Type
30record :: IParser T.Type
31−record = brackets $ do
31+record =
32+ do char '{' ; whitespace
32− ext <- extend
33+ ext <- extend
33− fs <- fields
34+ fs <- fields
35+ dumbWhitespace ; char '}'
34− return (T.Record (fieldMap fs) ext)
36+ return (T.Record (fieldMap fs) ext)
35 where
37 where
36 extend = option T.EmptyRecord . try $ do
38 extend = option T.EmptyRecord . try $ do
37 t <- tvar
39 t <- tvar
@@ -42,6 +44,7 @@ record = brackets $ do
42 whitespace >> hasType >> whitespace
44 whitespace >> hasType >> whitespace
43 (,) lbl <$> expr
45 (,) lbl <$> expr
44
46
47+
45constructor0 :: IParser T.Type
48constructor0 :: IParser T.Type
46constructor0 =
49constructor0 =
47 do name <- capVar
50 do name <- capVar