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
Added Ordering instance to HttpDate class #5189
Conversation
@rossabaker , have added |
@rossabaker , it is surprising that formatting checks have passed (I never ran
But it is showing error :
Is it because there is no
|
@rossabaker I added import
Does it mean that I have to add it as a function like this ?http4s/core/shared/src/main/scala/org/http4s/ResponsePrelude.scala Lines 105 to 106 in a942a83
|
I made the change but once again the formatting checks are failing. , the compiles checks are also failing with the following errors
@isomarcte @rossabaker , looks like I am at a dead-end, what do I do now |
My mistake. I thought we had a Add this to implicit val catsOrderForHttp4sHttpDate: Order[HttpDate] =
new Order[HttpDate] {
} You'll need to add an import of |
Alright thanks @rossabaker , I will look into it , but @isomarcte had suggested a method to implement Ordering instance even when we don't have cats.kernel.Order instance I tried this with the Ordering definition that you suggested , but that was giving error, Now I will try implementing |
Yes, what he suggested should work. I got you in trouble because I mistook that we already had the Cats instance. |
Hey @rossabaker , I have also overridden compare method, is that needed? what all should inside the catsOrderForHttp4sHttpDate instance {} |
Looks like Compile check are failing because
|
So, what should I put inside instance, usually I have seen the compare function, but I added compare and it gave the above error
|
@@ -54,6 +55,11 @@ class HttpDate private (val epochSecond: Long) extends Renderable with Ordered[H | |||
object HttpDate { | |||
private val MinEpochSecond = -2208988800L | |||
private val MaxEpochSecond = 253402300799L | |||
implicit val catsOrderForHttp4sHttpDate: Order[HttpDate] = |
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.
@san-coding if you are going to add add an Order
can you also add a Hash
with it? Something like we do here https://github.com/http4s/http4s/blob/main/core/shared/src/main/scala/org/http4s/RequestPrelude.scala#L102
Sorry, this is extra confusing and weird. The reason we have to do this is that both Order and Hash extend Eq and if they aren't both in the concrete instance we get into an ambiguous implicit context.
So, if we don't add a Hash
instance at the same time we add an Order
we'll have to do a deprecation in the future if we ever want to add a Hash
.
I hope that makes sense....I'm sorry, it's very confusing.
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.
@isomarcte @rossabaker , Ok I will add Hash, but can you tell me what I should put inside the instance definition
implicit val catsOrderForHttp4sHttpDate: Order[HttpDate] =
new Order[HttpDate] {
What should add here
}
Hey @rossabaker @isomarcte ,
I think http4s/core/shared/src/main/scala/org/http4s/HttpVersion.scala Lines 30 to 32 in a942a83
ContentCoding also requires http4s/core/shared/src/main/scala/org/http4s/ContentCoding.scala Lines 37 to 40 in a942a83
There are many more classes which require |
@rossabaker @isomarcte
It gave this error :
Then I removed the
Now it says
Should it be x.epochSecond.compare(y.epochSecond) |
Hurray 🎉, finally it is compiling , so this is the cats instance definition I added
@isomarcte @rossabaker , only formatting checks are failing ,I will add |
Hey @isomarcte @rossabaker , I have made the changes you requested: added |
Do you have sbt working yet? Or Metals? Either of those should be able to do the formatting for you. I took care of this one. |
Thanks @rossabaker @isomarcte , should I make anymore changes or is this PR ready to be merged |
Which classes should I next add |
I have installed metals, but set doesn't seem to be working |
I think I have figured it out on VSCode 🎉 |
This should have tests, too. Look at |
Ohh okay, I will make the required changes @rossabaker , thanks |
You mean I have to add a EDIT: just noticed that should I create that file in branch @rossabaker which branch should I be working on in the future |
Adding tests like this to the existing |
Ok , I will add the HttpDateSuite.scala to branch |
Signed-off-by: Sandeep Rajakrishnan <sandur43@gmail.com>
@rossabaker I have added test and made the requested changes |
Signed-off-by: Sandeep Rajakrishnan <sandur43@gmail.com>
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.
👍 if green
@rossabaker Thanks, is this ready to be merged ? What should I work on next @rossabaker , want to contribute more, which files need |
if you can search for files that have |
Thanks , will start working on it immediately 🎉 |
Contributing to #5017
Added
Ordering
instance toHttpDate
, in branchseries/0.22