v0.5.0
0.5.0 - 2023-12-23
New Features
-
[
refined4s-cats
] AddcontraCoercible
toF[B] => F[A]
withContravariant[F]
andCoercible[A, B]
(#152)This is useful to derive type-class instances for
Newtype
,Refined
andInlinedRefined
from the type-class instances of the actual types.e.g.)
import refined4s.modules.cats.derivation.instances.contraCoercible inline given eqDerived[A, B](using coercible: Coercible[A, B], eqB: Eq[B]): Eq[A] = contraCoercible(eqB) inline given showDerived[A, B](using coercible: Coercible[A, B], showB: Show[B]): Show[A] = contraCoercible(showB)
where
B
is the actual type andA
could be a newtype or a refined type.
Improvement
- Add missing
inline
toinvalidReason
in the sub-types ofInlinedNumeric
(#146)
-
[
refined4s-pureconfig
] Add type name to the error message ofPureconfigRefinedConfigReader
andrefined4s.modules.pureconfig.derivation.instances.derivedRefinedConfigReader
(#150)So a message like this
Invalid value found: -2373683071661092303 with error: Invalid value: [-2373683071661092303]. It must be a positive Long
should be like this instead.
The value -2373683071661092303 cannot be created as the expected type, mytypes.blah.Id.Type, due to the following error: Invalid value: [-2373683071661092303]. It must be a positive Long
- [
refined4s-doobie
] Make type-classes inrefined4s.modules.doobie.derivation.instances
inline
(#156)
-
[
refined4s-core
] Improve compile-time error message forinline apply
method (#158)The old compile-time error for the constant value passed to the
inline
apply
method may look like this.[error] 2780 | NegBigInt(1) [error] | ^^^^^^^^^^^^ [error] |A literal string is expected as an argument to `compiletime.error`. Got "Invalid value: [BigInt.apply(1)]. ".+( [error] | { [error] | val a$proxy4: BigInt = BigInt.apply(1) [error] | "It must be a negative BigInt":String:String [error] | }:String [error] |) [error] one error found
It is not so readable, and it is hard to comprehend what is wrong with the input.
After this release, it will be like
[error] 2780 | NegBigInt(1) [error] | ^^^^^^^^^^^^ [error] | Invalid value: [BigInt.apply(1)]. It must be a negative BigInt [error] one error found
Internal Housekeeping
-
[
refined4s-circe
] Updaterefined4s.modules.circe.derivation.instances.derivedEncoder
to usecontraCoercible
and make itinline
(#154)The old code has the following issue if it's turned into an
inline
method.[error] 13 | a => encoder(coercible(a)) [error] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ [error] |An inline given alias with a function value as right-hand side can significantly increase [error] |generated code size. You should either drop the `inline` or rewrite the given with an [error] |explicit `apply` method.
- Rename
Coercible
methods and type parameters (#160)wrap
andunwrap
suffixed withM
:M
toTC
(type constructor)wrap
andunwrap
suffixed withMOfM
:MOfM
toHKT
(higher-kinded type)M[*]
toF[*]
M1[*]
toF[*]
andM2[*]
toG[*]
e.g.)M1[M2[A]]
toF[G[A]]