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