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 % _Just
Methods
at :: Index m -> Lens' m (Maybe (IxValue m))Example1 expression Map.fromList [(1,"world")] ^. at 1Just "world"
Example1 expression at 1 ?~ "hello" $ Map.emptyfromList [(1,"hello")]
Note: Usage of this function might introduce space leaks if you're not careful to make sure that values put inside the Just constructor are evaluated. To force the values and avoid such leaks, use at' instead.
Note: Map-like containers form a reasonable instance, but not
Array-like ones, where you cannot satisfy the Lens laws.
Instances7At, …
At IntSetDefined in optics-core-0.4.1.1 · Optics.At.CoreOrd k => At (Set k)Defined in optics-core-0.4.1.1 · Optics.At.CoreAt (IntMap a)Defined in optics-core-0.4.1.1 · Optics.At.CoreAt (Maybe a)Defined in optics-core-0.4.1.1 · Optics.At.Core(Eq k, Hashable k) => At (HashSet k)Defined in optics-extra-0.4.2.1 · Optics.At · orphanOrd k => At (Map k a)Defined in optics-core-0.4.1.1 · Optics.At.Core(Eq k, Hashable k) => At (HashMap k a)Defined in optics-extra-0.4.2.1 · Optics.At · orphan