lens-3.7.4: Lenses, Folds and Traversals

Portabilitynon-portable
Stabilityexperimental
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellNone

Control.Lens.Each

Description

 

Synopsis

Documentation

class Each i s t a b | s -> i a, t -> i b, s b -> t, t a -> s whereSource

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 indexed traversal, 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 :: IndexedTraversal i s t a bSource

Instances

Each Int ByteString ByteString Word8 Word8 
Each Int Text Text Char Char 
Each Int64 ByteString ByteString Word8 Word8 
Each Int64 Text Text Char Char 
Each Int [a] [b] a b 
(RealFloat a, RealFloat b) => Each Int (Complex a) (Complex b) a b 
Each Int (Maybe a) (Maybe b) a b 
Each Int (Identity a) (Identity b) a b 
Each Int (Tree a) (Tree b) a b 
Each Int (Seq a) (Seq b) a b 
Each Int (IntMap a) (IntMap b) a b 
Each Int (Vector a) (Vector b) a b 
(Unbox a, Unbox b) => Each Int (Vector a) (Vector b) a b 
(Storable a, Storable b) => Each Int (Vector a) (Vector b) a b 
(Prim a, Prim b) => Each Int (Vector a) (Vector b) a b 
(~ * a a', ~ * b b') => Each Int (a, a') (b, b') a b 
(Ix i, IArray UArray a, IArray UArray b) => Each i (UArray i a) (UArray i b) a b 
(Ix i, IArray UArray a, IArray UArray b) => Each i (Array i a) (Array i b) a b 
Each k (HashMap k a) (HashMap k b) a b 
Each k (Map k a) (Map k b) a b 
(~ * a a2, ~ * a a3, ~ * b b2, ~ * b b3) => Each Int (a, a2, a3) (b, b2, b3) a b 
(~ * a a2, ~ * a a3, ~ * a a4, ~ * b b2, ~ * b b3, ~ * b b4) => Each Int (a, a2, a3, a4) (b, b2, b3, b4) a b 
(~ * a a2, ~ * a a3, ~ * a a4, ~ * a a5, ~ * b b2, ~ * b b3, ~ * b b4, ~ * b b5) => Each Int (a, a2, a3, a4, a5) (b, b2, b3, b4, b5) a b 
(~ * a a2, ~ * a a3, ~ * a a4, ~ * a a5, ~ * a a6, ~ * b b2, ~ * b b3, ~ * b b4, ~ * b b5, ~ * b b6) => Each Int (a, a2, a3, a4, a5, a6) (b, b2, b3, b4, b5, b6) a b 
(~ * 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 Int (a, a2, a3, a4, a5, a6, a7) (b, b2, b3, b4, b5, b6, b7) a b 
(~ * 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 Int (a, a2, a3, a4, a5, a6, a7, a8) (b, b2, b3, b4, b5, b6, b7, b8) a b 
(~ * 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 Int (a, a2, a3, a4, a5, a6, a7, a8, a9) (b, b2, b3, b4, b5, b6, b7, b8, b9) a b