google / google/codeworld

Requirements: Captures for matching rules

Open
#774 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Haskell
Stars
1.3k
Forks
201
PR merge metrics
No merged PRs in 30d

Description

In addition to the feature in #772, allow matching rules to capture matches into an environment. For instance, you should be able to write:

f(__var_x) = __var_x + 42

and this should match any of:

f(x) = x + 42
f(banana) = banana + 42

but not

f(x) = y + 42

Note that this extends the syntax of matches... `__var_x` carries all the same requirements as `__var`, but also binds the match. There's some flexibility though, since on the left-hand side above, `__var` matches a `PVar` (pattern variable), while on the right, it matches a `Var`. There should be an equivalence of sorts between patterns and expressions, by which a match of patterns that are also valid expressions (like `PVar _ (Ident _ a)` and `Var _ (UnQual _ (Ident _ a))` match each other.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.