-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
SemigroupK consistency and fix; added compose tests. #751
Conversation
+ Renamed SemigroupK composedWith to compose for consistency with Applicative, Foldable, Reducible. + Fixed non-termination bug in SemigroupK compose(dWith). + Added tests for Applicative, Foldable, Reducible, SemigroupK composition.
@@ -31,9 +31,9 @@ import simulacrum.{op, typeclass} | |||
/** | |||
* Compose two SemigroupK intsances. | |||
*/ | |||
def composedWith[G[_]: SemigroupK]: SemigroupK[λ[α => F[G[α]]]] = | |||
def compose[G[_]: SemigroupK]: SemigroupK[λ[α => F[G[α]]]] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have Alternative which extends both Applicative
and MonoidK
. Not that calling it composedWith
is a particularly elegant solution, but do we run the risk of overloading ambiguities/annoyances with both compose
s being on the same instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the right thing to do here is to add a compose
to Alternative
which composes a pair of Alternatives
to an Alternative
. I can add that to this PR or follow up afterwards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds like a good solution to me. It might also mean we want to add something similar to MonoidK
. I'm okay with that either going into this PR or a follow up one.
Current coverage is
|
new SemigroupK[λ[α => F[G[α]]]] { | ||
def combine[A](x: F[G[A]], y: F[G[A]]): F[G[A]] = combine(x, y) | ||
def combine[A](x: F[G[A]], y: F[G[A]]): F[G[A]] = self.combine(x, y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
👍 As mentioned here, there are probably some additional |
I'll do a couple of follow up PRs for the issues that @ceedubs raised. |
I agree with @ceedubs' comments, and also his 👍 Thanks! |
SemigroupK consistency and fix; added compose tests.
Thanks, @milessabin! |
Applicative, Foldable, Reducible.
composition.