lens-3.4: Lenses, Folds and Traversals

PortabilityRank2Types
Stabilityexperimental
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellSafe-Inferred

Data.Monoid.Lens

Description

 

Synopsis

Documentation

(<>~) :: Monoid a => Setting s t a a -> a -> s -> tSource

Modify the target of a monoidally valued by mappending another value.

>>> both <>~ "!!!" $ ("hello","world")
("hello!!!","world!!!")
 (<>~) :: Monoid a => Setter s t a a -> a -> s -> t
 (<>~) :: Monoid a => Iso s t a a -> a -> s -> t
 (<>~) :: Monoid a => Lens s t a a -> a -> s -> t
 (<>~) :: Monoid a => Traversal s t a a -> a -> s -> t

(<<>~) :: Monoid m => LensLike ((,) m) s t m m -> m -> s -> (m, t)Source

mappend a monoidal value onto the end of the target of a Lens and return the result

When you do not need the result of the operation, (<>~) is more flexible.

(<>=) :: (MonadState s m, Monoid a) => SimpleSetting s a -> a -> m ()Source

Modify the target(s) of a Simple Lens, Iso, Setter or Traversal by mappending a value.

 (<>=) :: (MonadState s m, Monoid a) => Simple Setter s a -> a -> m ()
 (<>=) :: (MonadState s m, Monoid a) => Simple Iso s a -> a -> m ()
 (<>=) :: (MonadState s m, Monoid a) => Simple Lens s a -> a -> m ()
 (<>=) :: (MonadState s m, Monoid a) => Simple Traversal s a -> a -> m ()

(<<>=) :: (MonadState s m, Monoid r) => SimpleLensLike ((,) r) s r -> r -> m rSource

mappend a monoidal value onto the end of the target of a Lens into your monad's state and return the result.

When you do not need the result of the operation, (<>=) is more flexible.

_dual :: Iso a b (Dual a) (Dual b)Source

Isomorphism for Dual

_endo :: Iso (a -> a) (b -> b) (Endo a) (Endo b)Source

Isomorphism for Endo

_all :: Simple Iso Bool AllSource

Isomorphism for All

>>> ala _all foldMap [True,True]
True
>>> ala _all foldMap [True,False]
False

_any :: Simple Iso Bool AnySource

Isomorphism for Any

>>> ala _any foldMap [False,False]
False
>>> ala _any foldMap [True,False]
True

_sum :: Iso a b (Sum a) (Sum b)Source

Isomorphism for Sum

>>> ala _sum foldMap [1,2,3,4]
10

_product :: Iso a b (Product a) (Product b)Source

Isomorphism for Product

>>> ala _product foldMap [1,2,3,4]
24

_first :: Iso (Maybe a) (Maybe b) (First a) (First b)Source

Isomorphism for First

_last :: Iso (Maybe a) (Maybe b) (Last a) (Last b)Source

Isomorphism for Last