lens-3.7.6: Lenses, Folds and Traversals

PortabilityMPTCs, Rank2Types, LiberalTypeSynonyms
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellNone







ix :: (IArray a e, Ix i) => i -> Simple Lens (a i e) eSource

Access an element of an array.

Note: The indexed element is assumed to exist in the target IArray.

 arr ! i ≡ arr ^. ix i
 arr // [(i,e)] ≡ ix i .~ e $ arr
>>> ix 2 .~ 9 $ (listArray (1,5) [4,5,6,7,8] :: Array Int Int)
array (1,5) [(1,4),(2,9),(3,6),(4,7),(5,8)]


ixmapped :: (IArray a e, Ix i, Ix j) => (i, i) -> Setter (a j e) (a i e) i jSource

This setter can be used to derive a new IArray from an old array by applying a function to each of the indices to look it up in the old IArray.

This is a contravariant Setter.

 ixmapover . ixmapped
 ixmappedsets . ixmap
 over (ixmapped b) f arr ! i ≡ arr ! f i
 bounds (over (ixmapped b) f arr) ≡ b


_array :: (IArray arr a, IArray arr b, Ix i) => IndexedTraversal i (arr i a) (arr i b) a bSource

An IndexedTraversal of the elements of an IArray, using the index into the array as the index of the traversal.

amapover _array