on master help sign in
cosmetic changes on fix for #305

I felt weird about the previous style where things were more intermingled. Does everything still look okay?

commitc685c8b91b710d06b58a22ef4acb0a321860cbe6 authorEvan Czaplicki <info@elm-lang.org> dateSat 19 Oct 2013, 22:14 (13 years ago) parent013e19e
1 file changed+12−11
compiler/Parse/Type.hs+12−11
compiler/Parse/Type.hs+12−11
@@ -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