dark
dark copied to clipboard
Support lists in pattern matches
Right now, we don't support lists in pattern matches. We'd like to. They would look like this I imagine:
match myList
[] -> something
[a] -> something else
[1,b] -> another thing
[a,b] -> another thing
I'm unclear whether we also want to support head :: rest style, but if so we'll make another issue.
Adding a language feature like this involves several steps:
- add it to the AST (both expr and FluidExpression.t, and the converter between them, if it hasn't been removed by then)
- add serializers between the frontend and the backend/analysis
- add the execution to backend/libexecution/ast.ml
- add "fluid" tokens and keystrokes (in client/src/fluid/fluid.ml) to allow them to be added
- make sure they can be deleted in Fluid.ml as well
Typically a good strategy is to do the frontend component only as a first step, putting it behind a feature flag). The backend component is generally more straightforward. This task is achievable, but it has many steps and isn't small. Definitely doable by a determined contributor.
I found a duplicate issue #3319. At time of closing that Issue, its contents were:
Pattern matching doesn't support lists yet. We should support:
- [ ] literal lists
- [ ] (multiple) cons
Maybe this Issue focuses on just literal lists, and cons-style matching waits for a separate Issue?
Done!