Skip to content

Conversation

@sritchie
Copy link
Collaborator

Moves the Ordering inputs from the constructor to the methods that need it, as discussed in #600 .

@sritchie sritchie added this to the 0.13.0 milestone Dec 11, 2016
def apply(t: T) = contains(t)
def &&(that: Interval[T]) = intersect(that)
def intersect(that: Interval[T])(implicit ord: Ordering[T]): Interval[T]
def apply(t: T)(implicit ord: Ordering[T]) = contains(t)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's make apply and && final

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

* TODO: It might be good to have types for these properties in algebird.
*/
def mapNonDecreasing[U: Ordering](fn: T => U): Interval[U]
def mapNonDecreasing[U](fn: T => U): Interval[U]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Think we need a test for mapNonDecreasing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So a law might be: forAll intervals and values t, if we map t and the interval, contains returns the same value.

To make the function non-decreasing we will need to do something like make a new fn and apple the first and if the result is less return the input.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

*/
def toLeftClosedRightOpen(implicit s: Successible[T]): Option[Intersection[InclusiveLower, ExclusiveUpper, T]] = {
implicit val ord = lower.ordering
def toLeftClosedRightOpen(implicit s: Successible[T]): Option[Intersection[InclusiveLower, ExclusiveUpper, T]] =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's try to see if we can just jump Successible and Predecessible up to Ordering. I can't think of a good reason to have Partial there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it works great!

* that are contained in this Intersection
*/
def leastToGreatest(implicit s: Successible[T]): Iterable[T] = {
def leastToGreatest(implicit s: Successible[T], ord: Ordering[T]): Iterable[T] = {

Choose a reason for hiding this comment

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

don't need ord now that Successible has an Ordering right?

* that are contained in this Intersection
*/
def greatestToLeast(implicit p: Predecessible[T]): Iterable[T] = {
def greatestToLeast(implicit p: Predecessible[T], ord: Ordering[T]): Iterable[T] = {

Choose a reason for hiding this comment

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

we don't need ord here, right?

* The law is:
* prev(t)
* .map { n => partialOrdering.lteq(n, t) && (!partialOrdering.equiv(t, n)) }
* .map { n => ordering.lteq(n, t) && (!ordering.equiv(t, n)) }

Choose a reason for hiding this comment

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

this can be more succinct now: prev(t).map(ordering.lt(_, t)).getOrElse(true)

* The law is:
* next(t)
* .map { n => partialOrdering.lteq(t, n) && (!partialOrdering.equiv(t, n)) }
* .map { n => ordering.lteq(t, n) && (!ordering.equiv(t, n)) }

Choose a reason for hiding this comment

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

similar: next(t).map(ordering.lt(t, _)).getOrElse(true)

@sritchie sritchie force-pushed the sritchie/interval_update branch from 200139d to d9deab1 Compare December 13, 2016 00:04
@codecov-io
Copy link

codecov-io commented Dec 13, 2016

Current coverage is 80.64% (diff: 73.21%)

Merging #605 into develop will increase coverage by 0.40%

@@            develop       #605   diff @@
==========================================
  Files           110        110          
  Lines          4924       4940    +16   
  Methods        4468       4502    +34   
  Messages          0          0          
  Branches        456        438    -18   
==========================================
+ Hits           3951       3984    +33   
+ Misses          973        956    -17   
  Partials          0          0          

Powered by Codecov. Last update d14c81a...d9deab1

@johnynek johnynek merged commit 031e55c into develop Dec 13, 2016
@johnynek johnynek deleted the sritchie/interval_update branch December 13, 2016 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants