Does something like this already exists? ```infix ...
# arrow
y
Does something like this already exists?
Copy code
infix fun <T, A> Optional<T, A>.default(value: A): Lens<T, A> = Lens(
  get = { opt -> getOrModify(opt).getOrElse { value } },
  set = { opt, v -> set(opt, v) }
)
to turn an
Optional
into a
Lens
by giving a default value if it's not there?
a
I'm not sure this is a well-behaved Lens, though. In particular, if the value is missing, setting to a new one won't make any difference when getting anew
👍🏼 1