-
Notifications
You must be signed in to change notification settings - Fork 448
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
Optics based on kotlin.reflect #2612
Conversation
As a rule Arrow never exports unsafe functions from the main APIs. With that in mind, that'd also mean we'd have to deprecate this. |
Or perhaps in a second module |
I can do that, sure. The goal here was to provide a simple bridge which works for now. |
Yes, that makes perfect sense. We've historically done that in other projects too, there is a small reflection based module in Arrow Endpoints for Thanks for adding this! When moved to |
e7c5aa1
to
0014fe3
Compare
@nomisRev I've just pushed a commit which moves this to a new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that looks perfect @serras! Thanks for moving it 👍
Some docs would be great too ❤️
Let me know when you think this is ready, and I'll review and ✔️
api(libs.kotlin.stdlibCommon) | ||
implementation(libs.kotlin.stdlibJDK8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this exposes the API of Kotlin Std, and uses the JDK8 implementation?
I'm still not a 100% sure how this works, and what is the correct config :/
I don't we're doing different things in different modules.. but off-topic for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure 100% either. In any case, I've removed the api
dependency on stdlibCommon
and just left the implementation
for the JDK version.
@serras should become green after merging |
The issue #2418 (by @magneticflux-) has given me an idea for an API for optics based on
KProperty
. It's a bit rough on the edges (for example, there's no way to check at compile-time that you are referring to a field in adata class
, so the access may fail at runtime). On the other hand, it allows you to create optics easily for types you do not control:The prism part is done using a combinator
instance<Parent, Children>
. Maybe a better name is needed, though.