-
Notifications
You must be signed in to change notification settings - Fork 803
Fix Client#translate
and relax constraints
#6139
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
Fix Client#translate
and relax constraints
#6139
Conversation
run( | ||
req.mapK(gK) | ||
).mapK(fk) | ||
.map(_.mapK(fk)) | ||
) | ||
} | ||
|
||
private def liftMonadCancel[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.
It seems that the MonadCancel
can have the mapK
method or even this lift
method. Did that discuss on discord or somewhere? I will be grateful for the link 🙏🏻
Anyway, I feel that this lift
method is super-specific to have it within the client
package. Maybe there is a more appropriate fp.utils
package?
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.
Yes, MonadCancel
can have an imapK
method :)
Yeah, bit of long discussion 😅
I propose my idea for this PR here:
https://discord.com/channels/632277896739946517/839254871646404638/954226420601716736
Then we discuss it here:
https://discord.com/channels/632277896739946517/839254871646404638/954238156767625266
I do agree this is weird one for Client
😆 @ChristopherDavenport is very suspicious about it though, which suggests we should keep it private-scoped to a small area. I can ask if CE will accept imapK
addition.
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.
Can anyone summarize the objection? Neither PR has a unit test: it would be great to see evidence that they satisfy the aim. Or if this approach doesn't work, a test that shows how it fails.
This one better fits the golden rule of software quality if it indeed works.
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.
@ChristopherDavenport on Discord:
So I agree that will work, but I have been told and so practice that it is bad to override a typeclass like that.
As canonically a typeclass should have a single implementation for a type.
https://discord.com/channels/632277896739946517/839254871646404638/954238688676704328
He said he will throw up a unit test today.
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.
Tests are push to my branch, feel free to steal them over here.
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.
My implementation passes @ChristopherDavenport's tests.
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.
On the theoretical question, is it any worse than:
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 believe private[this] is more private than private. As mentioned before I'm not theory person and this version is much cleaner than mine.
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.
private def liftMonadCancel[G[_]]( | |
private[this] def liftMonadCancel[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.
private
is also accessible from other instances of Client
. private[this]
is accessible only from the same instance of Client
. Furthermore, private[this]
is direct field access instead of through an accessor method. I think that change is conservative, and therefore good, until everyone is comfortable with it.
On theory, there's a nice Haskell discussion of Applicative.monoid
by Gabriella Gonzalez.
I think there's nothing wrong with providing explicit derived instances like this, and let users promote them to implicit if they are judged to be the canonical instance for the type, or tuck them away as done here when they do the right thing.
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.
This looks good to me. It does what it says on the tin, and the controversial bits are private in case the theoretical objection manifests in a practical way.
Co-authored-by: Ross A. Baker <ross@rossabaker.com>
Alternative to #6137 that also manages to relax the constraints on
Client#translate
.