-
Notifications
You must be signed in to change notification settings - Fork 274
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
feat(Setter): add: prepends setter #1058
Conversation
Add a setter that prepends the element, like `cons`. For balance, we also add a setter that also appends the element to the tail, like `snoc`. We often use this when adding elements to list structures and other order-conscious things. When we are doing natural language processing, for example, and we are adding processed data, it is more natural to add the resulting processed data to the head side if the original input source is closer to the head. Naturally we can also construct the processing by adding the tail if we think hard enough, but we don't want to work hard at that since we only need to prepare a function. The naming of the `<>:~` function was lost with `~<>`, but considering that the `~` symbol in the lenses setter operator is basically on the right, I used the `:` operator to indicate that it is closer to the `cons` of the list, rather than focusing on the contrast.
Thanks, @ncaq! Looking at the |
Add "with result" variants. Code review reflected.
What === Move `(<|~)`, `(<|=)`, `(|>~)`, `(|>=)` from `Control.Lens.Setter` to `Control.Lens.Cons`. Why === I try impl with result variants to `Control.Lens.Lens` like other. This requires the import of `Control.Lens.Cons` in `Control.Lens.Lens`. But it cause cycle import. So I decided to implement Cons-related operators with `Control.Lens.Cons`.
@RyanGlScott |
Add Cons operators of "with result" variants.
I made a mistake in describing the test... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @ncaq!
As requested in #1068 (review).
As requested in #1068 (review).
Add a setter that prepends the element, like
cons
. For balance, we also add a setter that also appends the element to the tail, likesnoc
. We often use this when adding elements to list structures and other order-conscious things. When we are doing natural language processing, for example, and we are adding processed data, it is more natural to add the resulting processed data to the head side if the original input source is closer to the head. Naturally we can also construct the processing by adding the tail if we think hard enough, but we don't want to work hard at that since we only need to prepare a function. The naming of the<>:~
function was lost with~<>
, but considering that the~
symbol in the lenses setter operator is basically on the right, I used the:
operator to indicate that it is closer to thecons
of the list, rather than focusing on the contrast.