-
-
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
Consider Reader-style instance for MonoidK of Kleisli #1928
Comments
MonoidK[Kleisli]
I can obviously open a PR as well if this gets approved |
Agree. The "EndoT" instance is interesting but I don't think it should be the default one. In scalaz I believe you get there via |
Before http4s is used as the justification for this, @aeons is changing the @ChristopherDavenport offered to implement it if we decide to proceed. |
I also agree that the second instance is more useful in general. I'm a bit afraid of too many breaking changes in RC1 but I think this one should be quite minor and not a big issue for most :) |
The point of |
big +1 on this. |
Looks like we should proceed with it. @ChristopherDavenport still interested? |
|
I'm worried that we can't change this instance in place without changing behavior silently for users. |
I think silently breaking users is possible but probably rare. Someone would have to have an endo which also has a I'd be surprised if even one person will be in this boat. |
Don't |
I'm interested, and will get an initial version up this evening. |
I can update #1098 if needed? |
Yeah it seems like most of the code is already in #1098 |
Cool, I can back down in favor of an existing PR. |
Added in #1098 |
The current instance of
MonoidK
forKleisli
(which I will refer to asEndo instance
) looks like:as opposed to what I'd call a
Reader instance
:which imo should be preferred.
Concrete, driving use case
In http4s, we need to model an http service as
Kleisli[OptionT[F, ?], Request, Response]
, and the proposed instance would allow composing services with<+>
, getting the correct prioritised choice behaviour.Rationale
An instance for
Kleisli[A, ?]
is more general than one forλ[α => Kleisli[F, α, α]]
, and therefore should be the instance, using a newtype for the other one. This is consistent with both Scalaz and Haskell, whereA => B
gets instances andA => A
gets newtyped asEndo
, and also internally consistent with the other instances forKleisli
, which are prevalentlyReader
style.There is some discussion about this in #247, but I believe the use case in http4s is important enough to reconsider
@rossabaker
The text was updated successfully, but these errors were encountered: