-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Record updater #399
Comments
The syntax would have to be a bit different from Haskell, since Perhaps something like |
You could also do something like |
I like Trevor's syntax best so far. |
What type would you like this to have? A monomorphic update would be fairly easy, I think:
However, an update function that allows for changing the type of the filed would be tricky to do. |
My needs are met by monomorphic update. I don't think it's unreasonable to ask the user to write their own function for an update that changes field types, since they probably won't do that too often. |
In a discussion with @robdockins a while back, another concern came up: nested record updates. We might like to have nice syntax for updating, say, field |
@jldodds @brianhuffman @robdockins @elliottt I was thinking a bit about the Cryptol records this morning, and I'd like to
In the typing rule In addition, we add a bunch of syntactic sugar to make writing updates nicer:
I tried this syntax with our parser and it works OK, as long as the I think this should cover the basics. Furthermore, here are some examples that I think should work and are more exotic:
Clearly the last two are a bit odd, but they don't look hard to implement, and I think that having the consistent behavior is nice. Most of the desugaring should probably happen in the front end, just like the desugaring for projection. So in the back end, we'd just need to implement the ordinary update on records and pairs, so I don't think there should be a big burden on the evaluation/reasoning system. Also, I wrote everything with
|
After thinking about this some more, here are some more notes:
|
@yav is this feature done? We should close this ticket once documentation and test cases are in place. |
I think so, there might even be documentation, but I should probably add some tests. I've assigned it to myself. |
It would be convenient to have a record update expression, such as Haskell's:
The text was updated successfully, but these errors were encountered: