eignnx / eignnx/funlang

Impl Irrefutable Patterns in Match Exprs

Open
#6 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Haskell
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Currently `Ast.Pat` (irrefutable patterns) and `Ast.RefutPat` are totally separate. It would be nice to relate them so that an `Ast.Pat` can be used wherever an `Ast.RefutPat` is expected.

Could this be done using recursion schemes?

## Ex:
```haskell
data Pat r
= VarPat String
| TuplePat [r]

data RefutPat r
= VarRefutPat String
| VrntRefutPat String [r]
| IrrefutPat (Pat r)
```

Then let and match expressions would become:

```haskell
data Expr
...
| LetF (Pat (Fix Pat)) r
...
| MatchF r [(RefutPat (Fix RefutPat), Seq r)]
...
```

Hopefully this would simplify pattern matching/destructuring compilation in `TastToHir.hs`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.