Make RefinedTypeOps blackbox #254
Labels
breaking changes
Changes that break compatibility with older versions
enhancement
New feature or request
Milestone
Following #250
RefinedTypeOps
leaks its implementation inapply
method, forcing users to haveio.github.iltotore.iron.autoRefine
in their scope.This is because
apply
requires aA :| C
and relies onautoRefine
to refine the non-iron values at compile-time.A potential solution would be to separate
apply(A :| C)
into two methods (like it used to in earlier versions):apply(A)
checking the passed value at compile-time or aborts (likeautoRefine
but embedded in the method)fromIronType(A :| C)
, equivalent to currentapply
This way, it is possible to make compile-time checked newtype instances without requiring Iron in the scope so libraries can use Iron in their datatypes without exposing it.
While harder to achieve, finding a solution with only an
apply
method might be doable by checking if the passed value's type is an Iron type:This approach has the pro of being source-retrocompatible but it has two cons:
apply
's signature is less trivialSince it is pretty straightforward to rewrite the code to fit the new definition of
apply
or even make a Scalafix rewriting rule, I'm in favor of the first approach which is simpler and less prone to some metaprogramming corner cases.The text was updated successfully, but these errors were encountered: