ash/lib/comparable/comparable.ex
Zach Daniel 58065c31cd improvement: remove :comparable as a dependency
It all compiles conditionally, so that if an explicit dependency exists
on `comp` it will still be used
2024-08-05 16:04:47 -04:00

16 lines
388 B
Elixir

unless Code.ensure_loaded?(Comparable) do
defprotocol Comparable do
@moduledoc """
Protocol which describes ordering relation for pair of types
"""
@type t :: Comparable.t()
@type ord :: :gt | :lt | :eq
@doc """
Accepts struct with fields :left and :right and returns ord value
"""
@spec compare(t) :: ord
def compare(left_and_right)
end
end