Shortcut to pass-through type-classes for opaque type #17654
ivan-klass
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Opaque types are very helpful to enforce type safety, but in practice it often leads to a silly boilerplate code when defining type-classes for them (e.g. circe codecs, db read/write, config readers, etc) which are nothing but a pass-through to a TC instance for underlying type.
One-for-all tricks like the below may help but don't cover all the cases (some derivations may diverge) and may also silently bring an implementation when pass-through is not desired
Explicitly putting given into a companion disables a way to summon TC for underlying type resulting in infinite loop in function body, e.g:
It would be much better if there's a way to declare a pass-through type-classes, something like
or
Beta Was this translation helpful? Give feedback.
All reactions