Skip to content

Commit

Permalink
Fix incorrect documentation for (<<>:~) and (<<>:=)
Browse files Browse the repository at this point in the history
This prepend to the front rather than appending at the back. Spotted in #1067.
  • Loading branch information
RyanGlScott committed May 11, 2024
1 parent 1ce86ea commit 052981b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Add a `_SCCP` `Prism` for the `Pragma` data type.
* Add the following `Setter`s for prepending and appending elements:
* `(<>:~)`: prepend an element to the front via `(<>)`.
* `(<<>:~)`: append an element to the back via `(<>)`.
* `(<<>:~)`: prepend an element to the front via `(<>)` and return the result.
* `(<|~)`: 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 `(|>)`.
Expand Down
8 changes: 4 additions & 4 deletions src/Control/Lens/Lens.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1192,18 +1192,18 @@ l <<>~ m = l <%~ (<> m)
l <<>= r = l <%= (<> r)
{-# INLINE (<<>=) #-}

-- | ('<>') a 'Semigroup' value onto the end of the target of a 'Lens' and
-- | ('<>') a 'Semigroup' value onto the front of the target of a 'Lens' and
-- return the result.
-- However, unlike '<<>~', it is prepend to the head side.
-- However, unlike ('<<>~'), it is prepended 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 <>)
{-# INLINE (<<>:~) #-}

-- | ('<>') a 'Semigroup' value onto the end of the target of a 'Lens' into
-- | ('<>') a 'Semigroup' value onto the front of the target of a 'Lens' into
-- your 'Monad''s state and return the result.
-- However, unlike '<<>=', it is prepend to the head side.
-- 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.
(<<>:=) :: (MonadState s m, Semigroup r) => LensLike' ((,)r) s r -> r -> m r
Expand Down

0 comments on commit 052981b

Please sign in to comment.