isoList property

Iso<List<A>, List<B>> get isoList

Lifts this isomorphism to work on lists of values.

Returns a new Iso that transforms List<A> to List<B> (and vice versa) by applying to and from to each element. This is useful when you want to apply an isomorphism to a collection of values.

If iso is a valid isomorphism, then iso.isoList is also a valid isomorphism (the round-trip property holds element-wise).

Example:

final iso = Iso(to: int.parse, from: (i) => i.toString());
final listIso = iso.isoList;
assert(listIso.to(['1', '2', '3']) == [1, 2, 3]);
assert(listIso.from([10, 20]) == ['10', '20']);

Implementation

Iso<List<A>, List<B>> get isoList =>
    Iso(to: (as) => as.map(to).toList(), from: (bs) => bs.map(from).toList());