evnu / closed_intervals

Storing a set of closed intervals
Apache License 2.0
0 stars 1 forks source link

Alternative API using compare? #9

Open turion opened 5 years ago

turion commented 5 years ago

I think that some parts of the code could be simplified by passing a compare function with @spec compare(data, data) :: :lt | :eq | :gt when data: var instead of order and eq.

evnu commented 5 years ago

Would you suggest to drop :order and :eq then?

turion commented 4 years ago

Yes. If order and eq are both lawful, then the information contained in compare is the same.

The only case for keeping order and eq around I can think of is non-lawful ones, e.g. when eq(x,y) does not imply order(x, y) && order(y, x). But I'd argue that such situations are confusing anyways and should be worked around in a different way (e.g. using #10 or #8).