composeLens()
composeLens<
A,B,C>(ab,bc):Lens<A,C>
Compose two lenses together.
Given a lens A ⭢ B and a lens B ⭢ C, produces a lens A ⭢ C.
Type Parameters
A
A
The type of the first object being inspected.
B
B
The type of the second object being inspected.
C
C
The type of the property value on the second lens.
Parameters
ab
Lens<A, B>
The lens from A ⭢ B.
bc
Lens<B, C>
The lens from B ⭢ C.
Returns
Lens<A, C>
Remarks
pure function
Example
const addressLens = lens(
(person: Person) => property(person)('address'),
(person) => (addr) => associateDeep(person)('address')(addr)
);
const cityLens = lens(
(address?: Address) => optionalProperty(address)('city'),
(address) => (city) => associateDeep(address)('city')(city)
);
const personCityLens = composeLens(addressLens, cityLens);