% package:lens

Adjust the target of an IndexedLens returning a supplementary result, or adjust all of the targets of an IndexedTraversal within the current state, and return a monoidal summary of the supplementary results.
l %%@= f ≡ state (l %%@~ f)
(%%@=) :: MonadState s m                 => IndexedLens i s s a b      -> (i -> a -> (r, b)) -> s -> m r
(%%@=) :: (MonadState s m, Monoid r) => IndexedTraversal i s s a b -> (i -> a -> (r, b)) -> s -> m r
Map over the target of a Lens or all of the targets of a Setter or Traversal in our monadic state.
>>> execState (do _1 %= f;_2 %= g) (a,b)
(f a,g b)
>>> execState (do both %= f) (a,b)
(f a,f b)
(%=) :: MonadState s m => Iso' s a       -> (a -> a) -> m ()
(%=) :: MonadState s m => Lens' s a      -> (a -> a) -> m ()
(%=) :: MonadState s m => Traversal' s a -> (a -> a) -> m ()
(%=) :: MonadState s m => Setter' s a    -> (a -> a) -> m ()
(%=) :: MonadState s m => ASetter s s a b -> (a -> b) -> m ()
Adjust every target in the current state of an IndexedSetter, IndexedLens or IndexedTraversal with access to the index. When you do not need access to the index then (%=) is more liberal in what it can accept.
l %= f ≡ l %@= const f
(%@=) :: MonadState s m => IndexedSetter i s s a b    -> (i -> a -> b) -> m ()
(%@=) :: MonadState s m => IndexedLens i s s a b      -> (i -> a -> b) -> m ()
(%@=) :: MonadState s m => IndexedTraversal i s t a b -> (i -> a -> b) -> m ()
Adjust every target of an IndexedSetter, IndexedLens or IndexedTraversal with access to the index.
(%@~) ≡ iover
When you do not need access to the index then (%~) is more liberal in what it can accept.
l %~ f ≡ l %@~ const f
(%@~) :: IndexedSetter i s t a b    -> (i -> a -> b) -> s -> t
(%@~) :: IndexedLens i s t a b      -> (i -> a -> b) -> s -> t
(%@~) :: IndexedTraversal i s t a b -> (i -> a -> b) -> s -> t
Modifies the target of a Lens or all of the targets of a Setter or Traversal with a user supplied function. This is an infix version of over.
fmap f ≡ mapped %~ f
fmapDefault f ≡ traverse %~ f
>>> (a,b,c) & _3 %~ f
(a,b,f c)
>>> (a,b) & both %~ f
(f a,f b)
>>> _2 %~ length $ (1,"hello")
(1,5)
>>> traverse %~ f $ [a,b,c]
[f a,f b,f c]
>>> traverse %~ even $ [1,2,3]
[False,True,False]
>>> traverse.traverse %~ length $ [["hello","world"],["!!!"]]
[[5,5],[3]]
(%~) :: Setter s t a b    -> (a -> b) -> s -> t
(%~) :: Iso s t a b       -> (a -> b) -> s -> t
(%~) :: Lens s t a b      -> (a -> b) -> s -> t
(%~) :: Traversal s t a b -> (a -> b) -> s -> t
A version of (%%=) that works on ALens.
A version of (%%~) that works on ALens.
>>> ("hello","world") & _2 #%%~ \x -> (length x, x ++ "!")
(5,("hello","world!"))
A version of (%=) that works on ALens.
A version of (%~) that works on ALens.
>>> ("hello","world") & _2 #%~ length
("hello",5)
A version of (<%=) that works on ALens.
A version of (<%~) that works on ALens.
>>> ("hello","world") & _2 <#%~ length
(5,("hello",5))
Modify the target of a Lens into your Monad's state by a user supplied function and return the result. When applied to a Traversal, it this will return a monoidal summary of all of the intermediate results. When you do not need the result of the operation, (%=) is more flexible.
(<%=) :: MonadState s m             => Lens' s a      -> (a -> a) -> m a
(<%=) :: MonadState s m             => Iso' s a       -> (a -> a) -> m a
(<%=) :: (MonadState s m, Monoid a) => Traversal' s a -> (a -> a) -> m a
Adjust the target of an IndexedLens returning the intermediate result, or adjust all of the targets of an IndexedTraversal within the current state, and return a monoidal summary of the intermediate results.
(<%@=) :: MonadState s m                 => IndexedLens i s s a b      -> (i -> a -> b) -> m b
(<%@=) :: (MonadState s m, Monoid b) => IndexedTraversal i s s a b -> (i -> a -> b) -> m b
Adjust the target of an IndexedLens returning the intermediate result, or adjust all of the targets of an IndexedTraversal and return a monoidal summary along with the answer.
l <%~ f ≡ l <%@~ const f
When you do not need access to the index then (<%~) is more liberal in what it can accept. If you do not need the intermediate result, you can use (%@~) or even (%~).
(<%@~) ::             IndexedLens i s t a b      -> (i -> a -> b) -> s -> (b, t)
(<%@~) :: Monoid b => IndexedTraversal i s t a b -> (i -> a -> b) -> s -> (b, t)
Modify the target of a Lens and return the result. When you do not need the result of the operation, (%~) is more flexible.
(<%~) ::             Lens s t a b      -> (a -> b) -> s -> (b, t)
(<%~) ::             Iso s t a b       -> (a -> b) -> s -> (b, t)
(<%~) :: Monoid b => Traversal s t a b -> (a -> b) -> s -> (b, t)
Modify the target of a Lens into your Monad's state by a user supplied function and return the old value that was replaced. When applied to a Traversal, this will return a monoidal summary of all of the old values present. When you do not need the result of the operation, (%=) is more flexible.
(<<%=) :: MonadState s m             => Lens' s a      -> (a -> a) -> m a
(<<%=) :: MonadState s m             => Iso' s a       -> (a -> a) -> m a
(<<%=) :: (MonadState s m, Monoid a) => Traversal' s a -> (a -> a) -> m a
(<<%=) :: MonadState s m => LensLike ((,)a) s s a b -> (a -> b) -> m a
Adjust the target of an IndexedLens returning the old value, or adjust all of the targets of an IndexedTraversal within the current state, and return a monoidal summary of the old values.
(<<%@=) :: MonadState s m                 => IndexedLens i s s a b      -> (i -> a -> b) -> m a
(<<%@=) :: (MonadState s m, Monoid b) => IndexedTraversal i s s a b -> (i -> a -> b) -> m a
Adjust the target of an IndexedLens returning the old value, or adjust all of the targets of an IndexedTraversal and return a monoidal summary of the old values along with the answer.
(<<%@~) ::             IndexedLens i s t a b      -> (i -> a -> b) -> s -> (a, t)
(<<%@~) :: Monoid a => IndexedTraversal i s t a b -> (i -> a -> b) -> s -> (a, t)
Modify the target of a Lens, but return the old value. When you do not need the old value, (%~) is more flexible.
(<<%~) ::             Lens s t a b      -> (a -> b) -> s -> (a, t)
(<<%~) ::             Iso s t a b       -> (a -> b) -> s -> (a, t)
(<<%~) :: Monoid a => Traversal s t a b -> (a -> b) -> s -> (a, t)