Skip to content

Commit f2dc0a0

Browse files
committed
ES: parser as-pats
1 parent d9b0542 commit f2dc0a0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

grin/src/Grin/ExtendedSyntax/Grin.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ instance FoldNames Val where
2626
instance FoldNames BPat where
2727
foldNames f = \case
2828
VarPat v -> f v
29-
AsPat t vs v -> f v <> foldNames (ConstTagNode t vs)
29+
AsPat t vs v -> f v <> foldNames f (ConstTagNode t vs)
3030

3131

3232
instance FoldNames CPat where

grin/src/Grin/ExtendedSyntax/Parse/AST.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ alternative i = Alt <$> try (L.indentGuard sc EQ i *> altPat) <*> (op "@" *> var
5454
-- and we don't want to parenthesize variables, literals and units.
5555
bindingPat :: Parser BPat
5656
bindingPat =
57-
try (flip AsPat <$> value <*> (op "@" *> var)) <|>
58-
VarPat <$> var
57+
VarPat <$> var <|>
58+
mkAsPat <$> parens ((,) <$> tag <*> many var) <*> (op "@" *> var)
59+
where mkAsPat (tag, fields) var = AsPat tag fields var
5960

6061

6162
altPat :: Parser CPat

0 commit comments

Comments
 (0)