Skip to content
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

Set multiple lenses successively #74

Open
singularitti opened this issue Aug 13, 2019 · 3 comments
Open

Set multiple lenses successively #74

singularitti opened this issue Aug 13, 2019 · 3 comments

Comments

@singularitti
Copy link

singularitti commented Aug 13, 2019

For example, I have the following code:

struct M
    c
end

struct N
    d
end

struct A
    a::M
    b::N
end

x = A(M(1), N(2))
lens1 = @lens _.a.c
lens2 = @lens _.b.d

If I want to set the two lenses successively, I need to write

set(set(x, lens1, 4), lens2, 5)

This code is a bit lacking readability. Could we provide a syntax that can set independent lenses successively? Thank you!

@tkf
Copy link
Collaborator

tkf commented Aug 13, 2019

FYI I wrote Kaleido.@batchlens to do this. See: https://github.com/tkf/Kaleido.jl

@singularitti
Copy link
Author

Wow, this is pretty cool!!! Thank you, I will take a look!

singularitti added a commit to MineralsCloud/Express.jl that referenced this issue Aug 13, 2019
@jw3126
Copy link
Owner

jw3126 commented Aug 15, 2019

Yeah Kaleido is pretty cool. I would love to have a batch @set someday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants