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

Implement InvariantCoyoneda #3987

Merged
merged 9 commits into from
Sep 10, 2021

Conversation

armanbilge
Copy link
Member

This came up in typelevel/vault#264, but @tpolecat's stack was about to overflow 😝

Comment on lines 32 to 40
/**
* The list of transformer functions composed into a single function, to be lifted into `F` by `run`.
*/
final def k0: Pivot => A = Function.chain(ks0.reverse)(_).asInstanceOf[A]

/**
* The composed transformer function, to be lifted into `F` by `run`.
*/
final def k1: A => Pivot = Function.chain(ks1)(_).asInstanceOf[Pivot]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there better names for these? Also, I see the comments are broken, will fix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine, just to keep it consistent with the co/contravariant versions.

LukaJCB
LukaJCB previously approved these changes Sep 2, 2021
tpolecat
tpolecat previously approved these changes Sep 2, 2021
/**
* `F[A]` converts to `InvariantCoyoneda[F,A]` for any `F`
*/
def lift[F[_], A](fa: F[A]): InvariantCoyoneda[F, A] =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not preserve the Aux type here but do so in other places?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I don't see the reason to ever preserve the Aux type. I can't see how anyone can use it. Isn't it better to use the type that hides the Pivot?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just following the style of the other Coyonedas, happy to make this change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is worth it if we have AndThen designed explicitly for this purpose but it is probably binary incompatible on the existing ones since you will change List to AndThen.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are going to retain the Aux in other places I think this should be Aux[F, A, A].

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I made this change to all the Coyonedas.

/**
* The list of the `Pivot => *` halves of the transformer functions, to be composed and lifted into `F` by `run`.
*/
private[cats] val ks0: List[Any => Any]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not want to use AndThen here so we know the function composition is safe (since we control it)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so too, I was just following the style of the other Coyonedas. Should I make the change across the board?

@armanbilge armanbilge dismissed stale reviews from tpolecat and LukaJCB via 94e51a3 September 5, 2021 21:25
@armanbilge
Copy link
Member Author

@johnynek I reworked all the Coyonedas to use AndThen. Seems binary compatible to me, what do you think?

Re Aux, I'm a little less clear about this change?

@johnynek
Copy link
Contributor

johnynek commented Sep 5, 2021

I don't follow your comment "seems binary compatible" since you had to add mima exclusions. It seems binary incompatible to me, but I believe it is safe because: 1. these types are sealed 2. the changed values were private[cats].

@armanbilge
Copy link
Member Author

is safe because: 1. these types are sealed 2. the changed values were private[cats].

Apologies, "safe" is what I meant, I'll be more precise next time. Or, binary-compatible from the perspective of users anyway :)

@tpolecat
Copy link
Member

tpolecat commented Sep 8, 2021

This looks good, are we waiting on anything else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants