lens-3.10: Lenses, Folds and Traversals

Portability | non-portable
Stability | experimental
Maintainer | Edward Kmett <ekmett@gmail.com>
Safe Haskell | None

Control.Lens.Each

Contents

- Indices
- Each

Description

Synopsis

- type family Index s :: *
- class (Functor f, Index s ~ Index t) => Each f s t a b | s -> a, t -> b, s b -> t, t a -> s where
  - each :: IndexedLensLike (Index s) f s t a b

# Indices

type family Index s :: *Source

This is a common `Index` type shared by `Each`, `At`, `Contains` and `Ixed`.

# Each

class (Functor f, Index s ~ Index t) => Each f s t a b | s -> a, t -> b, s b -> t, t a -> s where Source

Extract `each` element of a (potentially monomorphic) container.

Notably, when applied to a tuple, this generalizes `both` to arbitrary homogeneous tuples.

    >>> (1,2,3) & each *~ 10
    (10,20,30)

It can also be used on monomorphic containers like `Text` or `ByteString`.

    >>> over each Char.toUpper ("hello"^.Text.packed)
    "HELLO"

`each` is an `IndexedTraversal`, so it can be used to access keys in many containers:

    >>> itoListOf each $ Map.fromList [("hello",2),("world",4)]
    [("hello",2),("world",4)]

    >>> ("hello","world") & each.each %~ Char.toUpper
    ("HELLO","WORLD")

Methods

each :: IndexedLensLike (Index s) f s t a bSource

Instances

Applicative f => Each f ByteString ByteString Word8 Word8

    each :: IndexedTraversal Int64 ByteString ByteString Word8 Word8

Applicative f => Each f ByteString ByteString Word8 Word8

    each :: IndexedTraversal Int ByteString ByteString Word8 Word8

Applicative f => Each f Text Text Char Char

    each :: IndexedTraversal Int64 Text Text Char Char

Applicative f => Each f Text Text Char Char

    each :: IndexedTraversal Int Text Text Char Char

(Applicative f, Unbox a, Unbox b) => Each f (Vector a) (Vector b) a b

    each :: (Unbox a, Unbox b) => IndexedTraversal Int (Vector a) (Vector b) a b

(Applicative f, Storable a, Storable b) => Each f (Vector a) (Vector b) a b

    each :: (Storable a, Storable b) => IndexedTraversal Int (Vector a) (Vector b) a b

(Applicative f, Prim a, Prim b) => Each f (Vector a) (Vector b) a b

    each :: (Prim a, Prim b) => IndexedTraversal Int (Vector a) (Vector b) a b

Applicative f => Each f (Vector a) (Vector b) a b

    each :: IndexedTraversal Int (Vector a) (Vector b) a b

Applicative f => Each f (Tree a) (Tree b) a b

    each :: IndexedTraversal [Int] (Tree a) (Tree b) a b

Applicative f => Each f (Seq a) (Seq b) a b

    each :: IndexedTraversal Int (Seq a) (Seq b) a b

Applicative f => Each f (Maybe a) (Maybe b) a b

    each :: IndexedTraversal () (Maybe a) (Maybe b) a b

Functor f => Each f (Identity a) (Identity b) a b

    each :: IndexedTraversal () (Identity a) (Identity b) a b

Applicative f => Each f [a] [b] a b

    each :: IndexedTraversal Int [a] [b] a b

Applicative f => Each f (IntMap a) (IntMap b) a b

    each :: IndexedTraversal c (Map c a) (Map c b) a b

Applicative f => Each f (Complex a) (Complex b) a b

    each :: (RealFloat a, RealFloat b) => IndexedTraversal Int (Complex a) (Complex b) a b

Settable f => Each f (i -> a) (i -> b) a b

    each :: IndexedSetter i (i -> a) (i -> b) a b

(Applicative f, Ix i, IArray UArray a, IArray UArray b) => Each f (UArray i a) (UArray i b) a b

    each :: (Ix i, IArray UArray a, IArray UArray b) => IndexedTraversal i (Array i a) (Array i b) a b

(Applicative f, Ix i) => Each f (Array i a) (Array i b) a b

    each :: Ix i => IndexedTraversal i (Array i a) (Array i b) a b

Applicative f => Each f (HashMap c a) (HashMap c b) a b

    each :: IndexedTraversal c (HashMap c a) (HashMap c b) a b

Applicative f => Each f (Map c a) (Map c b) a b

    each :: IndexedTraversal c (Map c a) (Map c b) a b

(Applicative f, ~ * a a', ~ * b b') => Each f (a, a') (b, b') a b

    each :: IndexedTraversal Int (a,a) (b,b) a b

(Applicative f, ~ * a a2, ~ * a a3, ~ * b b2, ~ * b b3) => Each f (a, a2, a3) (b, b2, b3) a b

    each :: IndexedTraversal Int (a,a,a) (b,b,b) a b

(Applicative f, ~ * a a2, ~ * a a3, ~ * a a4, ~ * b b2, ~ * b b3, ~ * b b4) => Each f (a, a2, a3, a4) (b, b2, b3, b4) a b

    each :: IndexedTraversal Int (a,a,a,a) (b,b,b,b) a b

(Applicative f, ~ * a a2, ~ * a a3, ~ * a a4, ~ * a a5, ~ * b b2, ~ * b b3, ~ * b b4, ~ * b b5) => Each f (a, a2, a3, a4, a5) (b, b2, b3, b4, b5) a b

    each :: IndexedTraversal Int (a,a,a,a,a) (b,b,b,b,b) a b

(Applicative f, ~ * a a2, ~ * a a3, ~ * a a4, ~ * a a5, ~ * a a6, ~ * b b2, ~ * b b3, ~ * b b4, ~ * b b5, ~ * b b6) => Each f (a, a2, a3, a4, a5, a6) (b, b2, b3, b4, b5, b6) a b

    each :: IndexedTraversal Int (a,a,a,a,a,a) (b,b,b,b,b,b) a b

(Applicative f, ~ * a a2, ~ * a a3, ~ * a a4, ~ * a a5, ~ * a a6, ~ * a a7, ~ * b b2, ~ * b b3, ~ * b b4, ~ * b b5, ~ * b b6, ~ * b b7) => Each f (a, a2, a3, a4, a5, a6, a7) (b, b2, b3, b4, b5, b6, b7) a b

    each :: IndexedTraversal Int (a,a,a,a,a,a,a) (b,b,b,b,b,b,b) a b

(Applicative f, ~ * a a2, ~ * a a3, ~ * a a4, ~ * a a5, ~ * a a6, ~ * a a7, ~ * a a8, ~ * b b2, ~ * b b3, ~ * b b4, ~ * b b5, ~ * b b6, ~ * b b7, ~ * b b8) => Each f (a, a2, a3, a4, a5, a6, a7, a8) (b, b2, b3, b4, b5, b6, b7, b8) a b

    each :: IndexedTraversal Int (a,a,a,a,a,a,a,a) (b,b,b,b,b,b,b,b) a b

(Applicative f, ~ * a a2, ~ * a a3, ~ * a a4, ~ * a a5, ~ * a a6, ~ * a a7, ~ * a a8, ~ * a a9, ~ * b b2, ~ * b b3, ~ * b b4, ~ * b b5, ~ * b b6, ~ * b b7, ~ * b b8, ~ * b b9) => Each f (a, a2, a3, a4, a5, a6, a7, a8, a9) (b, b2, b3, b4, b5, b6, b7, b8, b9) a b

    each :: IndexedTraversal Int (a,a,a,a,a,a,a,a,a) (b,b,b,b,b,b,b,b,b) a b