on master help sign in
Allow pattern matching on ADTs that are not surrounded by parentheses.
commitf710b07dfd7bf71af4056ac4c663940ed7b70cfb authorevancz <info@elm-lang.org> dateSun 10 Jun 2012, 00:29 (14 years ago) parent6075cc8
1 file changed+6−1
elm/src/Parse/Parser.hs+6−1
elm/src/Parse/Parser.hs+6−1
@@ -80,7 +80,12 @@ lambdaExpr = do char '\\' <|> char '\x03BB' <?> "anonymous function"
8080 return $ makeFunction args e
8181
8282assignExpr = do
83− patterns <- spaceSep1 (patternTerm <?> "the definition of a variable (x = ...)")
83+ patterns <-
84+ choice [ try $ do v <- PVar <$> lowVar
85+ notFollowedBy (whitespace >> char ':')
86+ (v:) <$> spacePrefix patternTerm
87+ , (:[]) <$> patternExpr
88+ ] <?> "the definition of a variable (x = ...)"
8489 whitespace; string "="; whitespace; exp <- expr
8590 flattenPatterns patterns exp
8691