At

dev.constructive.eo.optics.At
object At

Monocle's At as a plain constructor object — NOT a typeclass. At(k) builds an ordinary total Lens from a Map[K, V] to the Option[V] at key k: replacing with Some(v) inserts or updates, replacing with None deletes the key. The Lens laws hold for every key (get-replace, replace-get, replace-replace). When you only want to touch an EXISTING value — never insert — use Index, whose focus is the bare V.

Attributes

Source
At.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
At.type

Members list

Grouped members

Constructors

def apply[K, V](k: K): GetReplaceLens[Map[K, V], Map[K, V], Option[V], Option[V]]

Total Lens to the Option[V] at key kSome inserts/updates, None deletes.

Total Lens to the Option[V] at key kSome inserts/updates, None deletes.

Attributes

Example
val port = At[String, Int]("port")
port.get(Map.empty)                        // None
port.replace(Some(80))(Map.empty)          // Map("port" -> 80)
port.replace(None)(Map("port" -> 80))      // Map()
Source
At.scala