-
-
Notifications
You must be signed in to change notification settings - Fork 666
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
Struct field access syntax #240
Comments
Should probably also support If you want to support row-typing as well as nominal typing then you could also go the route a lot of ML languages have done and make a generic |
Yes totally. I've closed this issue for now as I want to put more thought into the best way to do this. You mentioned first class lenses before, I would be interested in seeing any material on your ideas if you have any knocking about :) |
Full on first-class lenses would be a lot more powerful! In essense for the OP example, you could have // Global `Lens` definition:
struct Lens<Object, Result> {
type Result;
get: Fn(&Object) -> Result;
update: Fn(Object) -> Object
}
// Create the `.doodad` lens
Lens<Thing, i32>{
get: |&thing| -> thing.doodad
update: |doodad, thing| -> Thing{doodad: doodad, ..thing}
} Which then given a struct Thing {
doodad: Int
}
struct HoldsAThing {
thing: Thing
} Then you could A common pattern in some languages is that a tuple of lenses acts as an implicit And of course, since a lens is just a struct/record, can call it's callbacks straight too And of course, you can have a pretty trivial pass in the compiler so that if something like For note, haskall does implicit composition of lenses by doing things like |
The text was updated successfully, but these errors were encountered: