asLens property
Lens<A, B>
get
asLens
Downgrades this isomorphism to a Lens.
Every isomorphism is a lens (you can always get and set), but not every lens is an isomorphism. This returns a lens where:
The old value is ignored during set (since isomorphisms can fully reconstruct from just the new part).
Example:
final iso = Iso(to: (s) => int.parse(s), from: (i) => i.toString());
final lens = iso.asLens;
assert(lens.get('123') == 123);
assert(lens.set('old', 456) == '456');
See also: Lens
Implementation
Lens<A, B> get asLens => Lens(get: to, set: (_, b) => from(b));