effekt-lang / effekt-lang/effekt
Record update syntax?
- Dominant language
- Scala
- Stars
- 469
- Forks
- 41
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 23
Description
## Summary
It would be nice to have a syntax for record update in Effekt (the copying, immutable kind).
## Proposal
Generate "update*" functions, so we can have:
```effekt
record Foo(a: Int, b: Int)
val default = Foo(12,9)
val x = default.updateA(10)
println(x) // Foo(10,9)
```
Feel free to suggest better names/syntax...
## Motivating use case
Some libraries may have multiple options, e.g. a regex library may have options for case sensitivity, multiline mode, ...
A default options record could then be passed or first updated using record update syntax (as common in e.g. Haskell).
### Alternatives for this use case
- keyword + default arguments (probably harder to implement?), also potentially needs: forwarding.
- Instead of a record, effects could be used, but unless we have one single-operation effect per option, this does not solve the "set a single one" problem (but the equivalent "forward remaining operations" may be interesting).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.