-
-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lawful lenses #177
Comments
Wouldn't the following lens be lawful? const fail = e => { throw new TypeError(e) }
const lensProp = p => ({
view: o => o.hasOwnProperty(p) ? o[p] : fail(`Missing property ${p}`),
update: x => o => o.hasOwnProperty(p) ? { ...o, [p]: x } : fail(`Missing property ${p}`)
}) |
@davidchambers Sweet. So basically |
Apologies, I completely missed this issue ... 2 years ago. I'd be happy to help migrate https://github.com/flunc/optics over to become a Sanctuary project if there's interest. The existing As it stands, the library is void of documentation and there has been no focus on performance, but these are things we can change :) |
We needn't move flunc/optics to the @sanctuary-js namespace, though if you would like to do this, @scott-christopher, I'd be very happy for you to do so. I could not at this point commit much of my time to the effort. |
@davidchambers is there anything on the roadmap still for implementing lenses? |
As a side note, what's the story for lens/optics from sanctuary at this moment? Seemed there's only getter (like |
@protoEvangelion and @coodoo, lenses will be the next major addition to Sanctuary. As it may be of interest, I will share the backstory. In order to define van Laarhoven lenses, which have the desirable property of being compatible with In mid 2019 I started a full-time job, as I was running out of money. My ambitious plans may have made sense when I had a lot of time to devote to Sanctuary, but when the demands on my time increased I should have reconsidered them. The Fantasy Land changes are themselves several weeks of full-time work, as they involve updating fantasy-laws and the many Sanctuary ADTs. Let's finalize and merge sanctuary-js/sanctuary-constant#1 without waiting for fantasyland/fantasy-land#315. We will then have what we need to define |
As remarked in Gitter, we don't necessarily have to use van Laarhoven encoding to get lenses to work with The downside of this approach is that these lenses will not work with function-specialized |
R.lensProp
andR.lensIndex
aren't quite lawful, as @scott-christopher explained in ramda/ramda#1281 (comment).Scott, have you any interest in working on Sanctuary equivalents of Ramda's lens functions, which would use the Maybe type where appropriate to satisfy the lens laws?
The text was updated successfully, but these errors were encountered: