lens-3.0.6: Lenses, Folds and Traversals

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

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

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

Map with index. This is an alias for imapOf.

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

over l ≡ iover l . const
 iover :: IndexedSetter i a b c d    -> (i -> c -> d) -> a -> b
 iover :: IndexedLens i a b c d      -> (i -> c -> d) -> a -> b
 iover :: IndexedTraversal i a b c d -> (i -> c -> d) -> a -> b

isets :: ((i -> c -> d) -> a -> b) -> IndexedSetter i a b c dSource

Build an IndexedSetter from an imap-like function.

Your supplied function f is required to satisfy:

 f idid
 f g . f h ≡ f (g . h)

Equational reasoning:

 isets . ioverid
 iover . isetsid

Another way to view sets is that it takes a "semantic editor combinator" and transforms it into a Setter.

(%@~) :: 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 ()

Storing Indexed Setters

newtype ReifiedIndexedSetter i a b c d Source

Useful for storage.

Constructors

ReifyIndexedSetter 

Fields

reflectIndexedSetter :: IndexedSetter i a b c d
 

Simple