| Copyright | (C) 2012-14 Edward Kmett |
|---|---|
| License | BSD-style (see the file LICENSE) |
| Maintainer | Edward Kmett <ekmett@gmail.com> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | Trustworthy |
| Language | Haskell98 |
Control.Lens.At
Description
At
class Ixed m => At m where Source
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:
ixk ≡atk.traverse
Methods
Ixed
type family Index s :: * Source
Instances
| type Index ByteString = Int64 | |
| type Index ByteString = Int | |
| type Index IntSet = Int | |
| type Index Text = Int64 | |
| type Index Text = Int | |
| type Index [a] = Int | |
| type Index (Complex a) = Int | |
| type Index (Maybe a) = () | |
| type Index (Identity a) = () | |
| type Index (IntMap a) = Int | |
| type Index (Set a) = a | |
| type Index (Tree a) = [Int] | |
| type Index (Seq a) = Int | |
| type Index (NonEmpty a) = Int | |
| type Index (HashSet a) = a | |
| type Index (Vector a) = Int | |
| type Index (Vector a) = Int | |
| type Index (Vector a) = Int | |
| type Index (Vector a) = Int | |
| type Index (e -> a) = e | |
| type Index (a, b) = Int | |
| type Index (UArray i e) = i | |
| type Index (Array i e) = i | |
| type Index (Map k a) = k | |
| type Index (HashMap k a) = k | |
| type Index (a, b, c) = Int | |
| type Index (a, b, c, d) = Int | |
| type Index (a, b, c, d, e) = Int | |
| type Index (a, b, c, d, e, f) = Int | |
| type Index (a, b, c, d, e, f, g) = Int | |
| type Index (a, b, c, d, e, f, g, h) = Int | |
| type Index (a, b, c, d, e, f, g, h, i) = Int |
type family IxValue m :: * Source
Instances
| type IxValue ByteString = Word8 | |
| type IxValue ByteString = Word8 | |
| type IxValue IntSet = () | |
| type IxValue Text = Char | |
| type IxValue Text = Char | |
| type IxValue [a] = a | |
| type IxValue (Maybe a) = a | |
| type IxValue (Identity a) = a | |
| type IxValue (IntMap a) = a | |
| type IxValue (Set k) = () | |
| type IxValue (Tree a) = a | |
| type IxValue (Seq a) = a | |
| type IxValue (NonEmpty a) = a | |
| type IxValue (HashSet k) = () | |
| type IxValue (Vector a) = a | |
| type IxValue (Vector a) = a | |
| type IxValue (Vector a) = a | |
| type IxValue (Vector a) = a | |
| type IxValue (e -> a) = a | |
| type IxValue (a, a2) = a |
|
| type IxValue (UArray i e) = e | |
| type IxValue (Array i e) = e | |
| type IxValue (Map k a) = a | |
| type IxValue (HashMap k a) = a | |
| type IxValue (a, a2, a3) = a |
|
| type IxValue (a, a2, a3, a4) = a |
|
| type IxValue (a, a2, a3, a4, a5) = a |
|
| type IxValue (a, a2, a3, a4, a5, a6) = a |
|
| type IxValue (a, a2, a3, a4, a5, a6, a7) = a |
|
| type IxValue (a, a2, a3, a4, a5, a6, a7, a8) = a |
|
| type IxValue (a, a2, a3, a4, a5, a6, a7, a8, a9) = a |
|
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.
Methods
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 %~ ffromList [a,b,f c,d]
>>>Seq.fromList [a,b,c,d] & ix 2 .~ efromList [a,b,e,d]
>>>Seq.fromList [a,b,c,d] ^? ix 2Just c
>>>Seq.fromList [] ^? ix 2Nothing
Instances
| Ixed ByteString | |
| Ixed ByteString | |
| Ixed IntSet | |
| Ixed Text | |
| Ixed Text | |
| Ixed [a] | |
| Ixed (Maybe a) | |
| Ixed (Identity a) | |
| Ixed (IntMap a) | |
| Ord k => Ixed (Set k) | |
| Ixed (Tree a) | |
| Ixed (Seq a) | |
| 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 a2 => Ixed (a, a2) | |
| (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 a2, (~) * a a3) => Ixed (a, a2, a3) | |
| ((~) * a a2, (~) * a a3, (~) * a a4) => Ixed (a, a2, a3, a4) | |
| ((~) * a a2, (~) * a a3, (~) * a a4, (~) * a a5) => Ixed (a, a2, a3, a4, a5) | |
| ((~) * a a2, (~) * a a3, (~) * a a4, (~) * a a5, (~) * a a6) => Ixed (a, a2, a3, a4, a5, a6) | |
| ((~) * a a2, (~) * a a3, (~) * a a4, (~) * a a5, (~) * a a6, (~) * a a7) => Ixed (a, a2, a3, a4, a5, a6, a7) | |
| ((~) * a a2, (~) * a a3, (~) * a a4, (~) * a a5, (~) * a a6, (~) * a a7, (~) * a a8) => Ixed (a, a2, a3, a4, a5, a6, a7, a8) | |
| ((~) * a a2, (~) * a a3, (~) * a a4, (~) * a a5, (~) * a a6, (~) * a a7, (~) * a a8, (~) * a a9) => Ixed (a, a2, a3, a4, a5, a6, a7, a8, a9) |
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.