@@ -25,21 +25,22 @@ tuple = do ts <- parens (commaSep expr)
25record :: IParser T.Type
25record :: IParser T.Type
27 do char '{' ; whitespace
27 do char '{' ; whitespace
28− ext <- extend
28+ (ext,fs) <- extended <|> normal
30− T.EmptyRecord -> commaSep fields
31− _ -> commaSep1 fields
32 dumbWhitespace ; char '}'
29 dumbWhitespace ; char '}'
33 return (T.Record fs ext)
30 return (T.Record fs ext)
35− extend = option T.EmptyRecord . try $ do
32+ normal = (,) T.EmptyRecord <$> commaSep fields
34+ -- extended record types require at least one field
37− whitespace >> string "|" >> whitespace
36+ ext <- try (const <$> tvar <*> (whitespace >> string "|"))
38− return t
37+ whitespace
38+ (,) ext <$> commaSep1 fields
39 fields = do
40 fields = do
40− lbl <- rLabel
41+ lbl <- rLabel
41− whitespace >> hasType >> whitespace
42+ whitespace >> hasType >> whitespace
42− (,) lbl <$> expr
43+ (,) lbl <$> expr
44capTypeVar = intercalate "." <$> dotSep1 capVar
45capTypeVar = intercalate "." <$> dotSep1 capVar