-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversion from base types #37
Comments
My current preference is to do (1), since we can do it without requiring an empty companion object (as happens with the lenses plug-in). However, I see the benefit of providing a generic way to say "I don't know whether all the invariants are satisfied here, so please return a nullable". |
This method in the previous refined types plugin used to be based on nullable too. I think nullable is better so we don't impose a dependency on arrow core or have to provide a custom validation class, also don't allocate just to validate. Alternatively, we could have the plugin automatically codegen versions for I also prefer the first option so we don't have to provide a companion. |
I've never wanted this for Arrow Optics, but there is still no way to currently do this unless you're a compiler plugin. KSP cannot add a companion either but Arrow Analysis should be able to do this since it can add it, right? KotlinX Serialization also adds a companion object on the fly if it's not present.
100% agreed. |
(From a conversation on Slack)
The idea is to automatically provide conversions or constructors from basic types to classes with invariants.Some ideas:
value class
we create from the base type to the type with invariants, as in the case above. Maybe we should returnString?
instead.The text was updated successfully, but these errors were encountered: