Make RefinedTypeOps definition more ergonomic #253
Labels
breaking changes
Changes that break compatibility with older versions
enhancement
New feature or request
Milestone
Currently, declaring a new type requires to declare the constraint in the opaque type and in
RefinedTypeOps
's second argument which can be problematic for long constraints. Example derived from Valentin Bergeron and Raphaël Lemaitre's talkAn alias can be used to mitigate the boilerplate:
Ideally, the redundancy should be removed either by passing only the third parameter in
RefinedTypeOps
:or defining the type alias from the companion object (like Neotype):
I think defining the ops from the opaque type (first solution) is more natural. It was not possible before but might be doable easily enough since
TypeRepr#dealias
in Scala 3.4+ also dealiases opaque types. Thus, a mirror-like mechanism can (need to be tested) be used internally:On the other hand, solution 2 is pretty easy to do:
Users' opinions need to be collected in order to make a choice.
The text was updated successfully, but these errors were encountered: