-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use comparator field of Comparable.By atom
- Loading branch information
1 parent
280b7a7
commit e908a32
Showing
2 changed files
with
28 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Ordering_Helpers.enso
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
private | ||
|
||
import project.Any.Any | ||
from project.Data.Boolean import Boolean, False, True | ||
from project.Data.Ordering import all | ||
import project.Errors.Common.Incomparable_Values | ||
import project.Error.Error | ||
import project.Meta | ||
|
||
## PRIVATE | ||
Checks if the comparators for the given objects are both of the same type. If so, | ||
proceeds with the given action, and if not, throws `Incomparable_Values` error. | ||
assert_same_comparators : Any -> Any -> (Any -> Any) -> Any ! Incomparable_Values | ||
assert_same_comparators this that ~action = | ||
comp_this = Comparable.from this | ||
comp_that = Comparable.from that | ||
case Meta.is_same_object comp_this.comparator comp_that.comparator of | ||
True -> action comp_this.comparator | ||
False -> Error.throw (Incomparable_Values.Error this that) |