lens-1.7: Lenses, Folds and Traversals

PortabilityRank2Types
Stabilityprovisional
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellSafe-Infered

Data.Map.Lens

Description

 

Synopsis

Documentation

at :: Ord k => k -> SimpleIndexedLens k (Map k v) (Maybe v)Source

This Lens can be used to read, write or delete the value associated with a key in a Map.

>>> :m + Control.Lens Data.Map.Lens
>>> Map.fromList [("hello",12)] ^.at "hello"
Just 12
>>> at 10 .~ Just "hello" $ Map.empty
fromList [(10,"hello")]
 at :: Ord k => k -> (Maybe v -> f (Maybe v)) -> Map k v -> f (Map k v)

traverseMap :: IndexedTraversal k (Map k v) (Map k v') v v'Source

Traversal of a Map indexed by the key.

traverseAt :: Ord k => k -> SimpleIndexedTraversal k (Map k v) vSource

Traverse the value at a given key in a Map

 traverseAt :: (Applicative f, Ord k) => k -> (v -> f v) -> Map k v -> f (Map k v)
 traverseAt k = valueAt k . traverse

traverseAtMin :: SimpleIndexedTraversal k (Map k v) vSource

Traverse the value at the minimum key in a Map.

The key of the minimum element is available as the index of the traversal.

traverseAtMax :: SimpleIndexedTraversal k (Map k v) vSource

Traverse the value at the maximum key in a Map.

The key of the maximum element is available as the index of the traversal.