Longhand Lenses
Ramda's lensProp and lensIndex are convenience functions. Understanding the longhand version primes us to dive even deeper. (3 min. read)
We'll cover the following...
We'll cover the following...
lensProp and lensIndex are actually built on top of the lower-level lens function.
This
Is a convenient shorthand for this
See the difference?
Why prop() and assoc()?
Ramda’s prop function lets you get object properties.
And assoc lets you set them without mutating the original object.
And since lenses need a getter and a setter to perform their duties, prop and assoc make the perfect combination to immutably handle and change lenses.