Packages

Comparable (aka Orderable) Elixir protocol

Current section

Files

Jump to
comparable lib comparable.ex
Raw

lib/comparable.ex

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