lens-1.8: Lenses, Folds and Traversals

Portabilityrank 2 types, MPTCs, TFs, flexible
Stabilityprovisional
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellSafe-Infered

Control.Lens.IndexedSetter

Contents

Description

 

Synopsis

Indexed Setter

type IndexedSetter i a b c d = forall f k. (Indexed i k, Settable f) => k (c -> f d) (a -> f b)Source

Every IndexedSetter is a valid Setter

The Setter laws are still required to hold.

imapOf :: Overloaded (Index i) Mutator a b c d -> (i -> c -> d) -> a -> bSource

Map with index.

When you do not need access to the index, then mapOf is more liberal in what it can accept.

mapOf l = imapOf l . const
 imapOf :: IndexedSetter i a b c d    -> (i -> c -> d) -> a -> b
 imapOf :: IndexedLens i a b c d      -> (i -> c -> d) -> a -> b
 imapOf :: IndexedTraversal i a b c d -> (i -> c -> d) -> a -> b

(%@~) :: Overloaded (Index i) Mutator a b c d -> (i -> c -> d) -> a -> bSource

Adjust every target of an IndexedSetter, IndexedLens or IndexedTraversal with access to the index.

(%@~) = imapOf

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 a b c d    -> (i -> c -> d) -> a -> b
 (%@~) :: IndexedLens i a b c d      -> (i -> c -> d) -> a -> b
 (%@~) :: IndexedTraversal i a b c d -> (i -> c -> d) -> a -> b

(%@=) :: MonadState a m => Overloaded (Index i) Mutator a a c d -> (i -> c -> d) -> m ()Source

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 a m => IndexedSetter i a a c d    -> (i -> c -> d) -> m ()
 (%@=) :: MonadState a m => IndexedLens i a a c d      -> (i -> c -> d) -> m ()
 (%@=) :: MonadState a m => IndexedTraversal i a b c d -> (i -> c -> d) -> m ()

Simple

type SimpleIndexedSetter i a b = IndexedSetter i a a b bSource

type 'SimpleIndexedSetter i = Simple (IndexedSetter i)