96677aa499
I know this is dumb, but it's the best way for be to crystalise my thoughts about how this will work.
39 lines
830 B
Text
39 lines
830 B
Text
deftrait Ordering, as: ->
|
|
typedoc """
|
|
This trait defines ordering comparisons for types.
|
|
"""
|
|
|
|
def <Ordering.Result> compare_with other: Any
|
|
|
|
def equals? other: Any, as: ->
|
|
match compare_with(other),
|
|
Ordering.Equal: true,
|
|
Any: false
|
|
end
|
|
|
|
def greater_than? other: Any, as: ->
|
|
match compare_with(other),
|
|
Ordering.Greater: true,
|
|
Any: false
|
|
end
|
|
|
|
def greater_than_or_equal_to? other: Any, as: ->
|
|
match compare_with(other),
|
|
Ordering.Greater: true,
|
|
Ordering.Equal: true,
|
|
Any: false
|
|
end
|
|
|
|
def less_than? other: Any, as: ->
|
|
match compare_with(other),
|
|
Ordering.Less: true,
|
|
_: false
|
|
end
|
|
|
|
def less_than_or_equal_to? other: Any, as: ->
|
|
match compare_with(other),
|
|
Ordering.Less: true,
|
|
Ordering.Equal: true,
|
|
Any: false
|
|
end
|
|
end
|