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

Add Order#fromLessThan #2477

Merged
merged 1 commit into from
Sep 12, 2018
Merged

Add Order#fromLessThan #2477

merged 1 commit into from
Sep 12, 2018

Conversation

vlovgr
Copy link
Contributor

@vlovgr vlovgr commented Sep 7, 2018

I sometimes find myself writing Order instances using a 'less than' function. There is no such helper function for Order, but there is one for Ordering, which means that you currently have to rely on the fromOrdering function as follows.

import cats.Order
import java.time.Instant

implicit val orderInstant: Order[Instant] =
  Order.fromOrdering(Ordering.fromLessThan(_ isBefore _))

This pull request adds a fromLessThan function to Order, so we don't have to use Ordering.

implicit val orderInstant: Order[Instant] =
  Order.fromLessThan(_ isBefore _)

@codecov-io
Copy link

codecov-io commented Sep 7, 2018

Codecov Report

Merging #2477 into master will decrease coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2477      +/-   ##
==========================================
- Coverage   95.38%   95.35%   -0.03%     
==========================================
  Files         357      357              
  Lines        6517     6525       +8     
  Branches      279      281       +2     
==========================================
+ Hits         6216     6222       +6     
- Misses        301      303       +2
Impacted Files Coverage Δ
kernel/src/main/scala/cats/kernel/Order.scala 90.9% <100%> (+2.02%) ⬆️
testkit/src/main/scala/cats/tests/Helpers.scala 96% <0%> (-4%) ⬇️
...rc/main/scala/cats/kernel/instances/function.scala 96.96% <0%> (-3.04%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update caa54cb...836d330. Read the comment docs.

Copy link
Contributor

@kailuowang kailuowang left a comment

Choose a reason for hiding this comment

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

nice! thanks!

@LukaJCB LukaJCB merged commit f44eb11 into typelevel:master Sep 12, 2018
@kailuowang kailuowang added this to the 1.4 milestone Sep 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants