-
Notifications
You must be signed in to change notification settings - Fork 9
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
Infix operator alias for Lens.compose #11
Comments
looks as a good candidate por a PR, pls contribute
niedz., 3 gru 2017 o 13:05 użytkownik Michel Belleville <
notifications@github.com> napisał:
… I really love monocle and the ability to use lenses to get and set values
easily.
But since lenses are especially interesting when you can compose them, and
since composition can be deep for deeply nested structures, it's a bit
annoying and counter-intuitive to have to do this:
lens1 : Lens a blens2 : Lens b clens3 : Lens c d
lens13_1 : Lens a dlens13_1 =
lens3
|> compose lens2
|> compose lens1
-- OR
lens13_2 : Lens a dlens13_2 =
compose (compose lens1 lens2) lens3
-- OR
lens13_3 : Lens a dlens13_3 =
let
lens12 = compose lens1 lens2
in
compose lens12 lens3
-- OR EVENlens 13_4 : Lens a dlens13_4 =
compose lens1 <| compose lens2 lens3
All these patterns are grating to read. We usually solved it making
"half-way" lenses like:
lens12 = compose lens1 lens2lens13 = compose lens12 lens3
But I can't help thinking we might benefit from an infix Lens.compose
alias allowing to do things like:
(<|>) = Lens.composelens13 = lens1 <|> lens2 <|> lens3
(I've actually done it in projects of my own that use lenses)
So, what do you think?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#11>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAPULyQMrMskTP2XMvw1qRWLb-cq0DrFks5s8pypgaJpZM4QzthG>
.
|
Gladly ^^ I just didn't want to do it out of the blue without asking wether
it was a good idea first, and maybe discuss which symbol would be
appropriate for that operator.
Le dim. 3 déc. 2017 à 18:16, Artur Opala <notifications@github.com> a
écrit :
… looks as a good candidate por a PR, pls contribute
niedz., 3 gru 2017 o 13:05 użytkownik Michel Belleville <
***@***.***> napisał:
> I really love monocle and the ability to use lenses to get and set values
> easily.
>
> But since lenses are especially interesting when you can compose them,
and
> since composition can be deep for deeply nested structures, it's a bit
> annoying and counter-intuitive to have to do this:
>
> lens1 : Lens a blens2 : Lens b clens3 : Lens c d
> lens13_1 : Lens a dlens13_1 =
> lens3
> |> compose lens2
> |> compose lens1
> -- OR
> lens13_2 : Lens a dlens13_2 =
> compose (compose lens1 lens2) lens3
> -- OR
> lens13_3 : Lens a dlens13_3 =
> let
> lens12 = compose lens1 lens2
> in
> compose lens12 lens3
> -- OR EVENlens 13_4 : Lens a dlens13_4 =
> compose lens1 <| compose lens2 lens3
>
> All these patterns are grating to read. We usually solved it making
> "half-way" lenses like:
>
> lens12 = compose lens1 lens2lens13 = compose lens12 lens3
>
> But I can't help thinking we might benefit from an infix Lens.compose
> alias allowing to do things like:
>
> (<|>) = Lens.composelens13 = lens1 <|> lens2 <|> lens3
>
> (I've actually done it in projects of my own that use lenses)
>
> So, what do you think?
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <#11>, or mute the
thread
> <
https://github.com/notifications/unsubscribe-auth/AAPULyQMrMskTP2XMvw1qRWLb-cq0DrFks5s8pypgaJpZM4QzthG
>
> .
>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#11 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAApq5dM2ppLWuf8I_C5WwoMBYN7e-Tgks5s8tdwgaJpZM4QzthG>
.
|
Here, finally took time to implement it 😄 |
(sorry, it appears I have forgotten to bump the version up 😅 I'm fairly new to publishing packages in elm -completely new in fact- should I send you another pull request with the new version? I'm reading this can be done automatically using "elm-package bump", but I don't want to do something that'd mess with your repo) |
I just tried the |
(and I guess we can close this now anyways ^^° sorry for not being very responsive the last few days) |
I really love monocle and the ability to use lenses to get and set values easily.
But since lenses are especially interesting when you can compose them, and since composition can be deep for deeply nested structures, it's a bit annoying and counter-intuitive to have to do this:
All these patterns are grating to read. We usually solved it making "half-way" lenses like:
But I can't help thinking we might benefit from an infix Lens.compose alias allowing to do things like:
(I've actually done it in projects of my own that use lenses)
So, what do you think?
The text was updated successfully, but these errors were encountered: