-
Notifications
You must be signed in to change notification settings - Fork 125
Typeclasses requiring only read access, and private constructors #222
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
Comments
I think it makes sense, but I'm not sure if the encoding you are proposing has the best UX. |
I'm not sure either, but I can't think of anything that's obviously better. The change shouldn't be too difficult, with this approach. |
Adding a super class to |
We haven't promised binary compatibility yet anyway. |
As a downstream user I'd prefer to not deal with any MethodNotFoundExceptions ;) It will probably be ok.... 🤞 |
I did bump the version number from 0.12.x to 0.13.x in the last (as-yet unannounced) release on the basis that it included a small API change, but in general I haven't been careful about it... |
Yeah if we really want to make sure, then we should cut a 1.0 release and add MiMa. |
I'd like to leave that a while. I'm a bit reluctant to give a binary compatibility guarantee while I at least expect to change a few things... my priority right now is to make it easier to publish both Magnolia and ~20 other libraries... |
Many typeclasses require only read access to fields (e.g.
Show
, diffx'sDiff
, JSON Encoders), but due to the existence ofCaseClass#construct
, magnolia derivation will fail if the primary constructor is not accessible.Proposal:
def combine[T](ctx: CaseClass[Typeclass, T]): Derived[MyTypeClass[T]]
, allow them to usedef combine[T](ctx: ReadOnlyCaseClass[Typeclass, T]): Derived[MyTypeClass[T]]
instead, whereReadOnlyCaseClass
will not have the construct methods.Magnolia.gen
will detect that ReadOnlyCaseClass is used and not try to resolve constructorsThis applies to
abstract
as well, as currentlysealed abstract case class
is quite a common pattern in < 2.12 due to scala/bug#7884 (Should be fixed in 2.13.2?)WDYT?
The text was updated successfully, but these errors were encountered: