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

New operators not exported by Control.Lens.Operators #1067

Closed
endgame opened this issue May 8, 2024 · 7 comments · Fixed by #1068
Closed

New operators not exported by Control.Lens.Operators #1067

endgame opened this issue May 8, 2024 · 7 comments · Fixed by #1068

Comments

@endgame
Copy link
Contributor

endgame commented May 8, 2024

These operators, introduced in lens-5.3, are not re-exported through Control.Lens.Operators:

  • (<>:~): prepend an element to the front via (<>).
  • (<<>:~): append an element to the back prepend an element to the front via (<>).
  • (<|~): cons an element to the front via (<|).
  • (<<|~): cons an element to the front via (<|) and return the result.
  • (|>~): snoc an element to the back via (|>).
  • (<|>~): snoc an element to the back via (|>) and return the result.

(<<>:~) appears misdocumented in the changelog: it is actually left-side <> and-return-result

Should these lenses also have << variants which return the old value?

Ping @ncaq

@RyanGlScott
Copy link
Collaborator

Yes, I think we should re-export these from Control.Lens.Operators as well.

(<<>:~) appears misdocumented in the changelog: it is actually left-side <> and-return-result

Sorry about that! I wrote the CHANGELOG after #1058 had landed, so any errors in the CHANGELOG are purely my fault. @ncaq, would you be willing to double-check what I wrote and fix any inaccuracies?

Should these lenses also have << variants which return the old value?

Thoughts, @ncaq?

@ncaq
Copy link
Contributor

ncaq commented May 10, 2024

I think it is a good policy to export.

@RyanGlScott
Copy link
Collaborator

OK. Regarding the CHANGELOG mistake, I think I was confused by the Haddocks for (<<>:~):

lens/src/Control/Lens/Lens.hs

Lines 1195 to 1201 in 1ce86ea

-- | ('<>') a 'Semigroup' value onto the end of the target of a 'Lens' and
-- return the result.
-- However, unlike '<<>~', it is prepend to the head side.
--
-- When you do not need the result of the operation, ('Control.Lens.Setter.<>:~') is more flexible.
(<<>:~) :: Semigroup m => LensLike ((,)m) s t m m -> m -> s -> (m, t)
l <<>:~ m = l <%~ (m <>)

The Haddocks talk about appending an element to the end, but the implementation prepends to the front instead. As such, I think we need to correct both the Haddocks and the CHANGELOG.

RyanGlScott added a commit that referenced this issue May 11, 2024
This prepend to the front rather than appending at the back. Spotted in #1067.
@RyanGlScott
Copy link
Collaborator

I've submitted a fix in #1068.

RyanGlScott added a commit that referenced this issue May 12, 2024
This prepend to the front rather than appending at the back. Spotted in #1067.
RyanGlScott added a commit that referenced this issue May 12, 2024
This prepend to the front rather than appending at the back. Spotted in #1067.
@ncaq
Copy link
Contributor

ncaq commented May 13, 2024

I copied and pasted the basic part thinking it was basically the same and unlike it, prepend to the head side...
I should have checked the basic part properly.
I made a mistake because I am not good at English.
Thank you for your time and effort.

@RyanGlScott
Copy link
Collaborator

No problem at all, @ncaq. Thank you for your contribution!

@endgame
Copy link
Contributor Author

endgame commented May 13, 2024

Thank you for your time and effort.

And thank you for yours.

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

Successfully merging a pull request may close this issue.

3 participants