Skip to content
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

[refined4s-cats] Add contraCoercible to F[B] => F[A] with Contravariant[F] and Coercible[A, B] #152

Closed
kevin-lee opened this issue Dec 22, 2023 · 0 comments · Fixed by #153
Assignees
Labels
Milestone

Comments

@kevin-lee
Copy link
Owner

kevin-lee commented Dec 22, 2023

Summary

[refined4s-cats] Add contraCoercible to F[B] => F[A] with Contravariant[F] and Coercible[A, B]

Version

0.4.0

Description

This is useful to derive type-class instances for Newtype, Refined and InlinedRefined from the type-class instances of the actual types.

e.g.)

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 and A could be a newtype or a refined type.

@kevin-lee kevin-lee added the task label Dec 22, 2023
@kevin-lee kevin-lee added this to the m5 milestone Dec 22, 2023
@kevin-lee kevin-lee self-assigned this Dec 22, 2023
kevin-lee added a commit that referenced this issue Dec 23, 2023
kevin-lee added a commit that referenced this issue Dec 23, 2023
…h Contravariant[F] and Coercible[A, B]

- Now eqDerived and showDerived use contraCoercible
kevin-lee added a commit that referenced this issue Dec 23, 2023
…h Contravariant[F] and Coercible[A, B]

- Now eqDerived and showDerived use contraCoercible
@kevin-lee kevin-lee changed the title [refined4s-core] Add contraCoercible to F[B] => F[A] with Contravariant[F] and Coercible[A, B] [refined4s-cats] Add contraCoercible to F[B] => F[A] with Contravariant[F] and Coercible[A, B] Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant