Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Safe Haskell | Trustworthy |
At
class Ixed m => At m whereSource
At
provides a Lens
that can be used to read,
write or delete the value associated with a key in a Map
-like
container on an ad hoc basis.
An instance of At
should satisfy:
ix
k ≡at
k.
traverse
Ixed
This simple Traversal
lets you traverse
the value at a given
key in a Map
or element at an ordinal position in a list or Seq
.
ix :: Index m -> Traversal' m (IxValue m)Source
This simple Traversal
lets you traverse
the value at a given
key in a Map
or element at an ordinal position in a list or Seq
.
NB: Setting the value of this Traversal
will only set the value in
at
if it is already present.
If you want to be able to insert missing values, you want at
.
>>>
Seq.fromList [a,b,c,d] & ix 2 %~ f
fromList [a,b,f c,d]
>>>
Seq.fromList [a,b,c,d] & ix 2 .~ e
fromList [a,b,e,d]
>>>
Seq.fromList [a,b,c,d] ^? ix 2
Just c
>>>
Seq.fromList [] ^? ix 2
Nothing
Ixed ByteString | |
Ixed ByteString | |
Ixed IntSet | |
Ixed Text | |
Ixed Text | |
Ixed [a] | |
Ixed (Maybe a) | |
Ixed (Identity a) | |
Ixed (Tree a) | |
Ixed (Seq a) | |
Ixed (IntMap a) | |
Ord k => Ixed (Set k) | |
Ixed (NonEmpty a) | |
(Eq k, Hashable k) => Ixed (HashSet k) | |
Ixed (Vector a) | |
Unbox a => Ixed (Vector a) | |
Storable a => Ixed (Vector a) | |
Prim a => Ixed (Vector a) | |
Eq e => Ixed (e -> a) | |
~ * a b => Ixed (a, b) | |
(IArray UArray e, Ix i) => Ixed (UArray i e) | arr |
Ix i => Ixed (Array i e) | arr |
Ord k => Ixed (Map k a) | |
(Eq k, Hashable k) => Ixed (HashMap k a) | |
(~ * a b, ~ * a c) => Ixed (a, b, c) | |
(~ * a b, ~ * a c, ~ * a d) => Ixed (a, b, c, d) | |
(~ * a b, ~ * a c, ~ * a d, ~ * a e) => Ixed (a, b, c, d, e) | |
(~ * a b, ~ * a c, ~ * a d, ~ * a e, ~ * a f) => Ixed (a, b, c, d, e, f) | |
(~ * a b, ~ * a c, ~ * a d, ~ * a e, ~ * a f, ~ * a g) => Ixed (a, b, c, d, e, f, g) | |
(~ * a b, ~ * a c, ~ * a d, ~ * a e, ~ * a f, ~ * a g, ~ * a h) => Ixed (a, b, c, d, e, f, g, h) | |
(~ * a b, ~ * a c, ~ * a d, ~ * a e, ~ * a f, ~ * a g, ~ * a h, ~ * a i) => Ixed (a, b, c, d, e, f, g, h, i) |
Contains
This class provides a simple IndexedFold
(or IndexedTraversal
) that lets you view (and modify)
information about whether or not a container contains a given Index
.