View Source Interval.Intervalable protocol (Interval v0.3.4)
Implementing this protocol allows Interval
to infer the implementation
to use for a value, which allows you to pass the values to Interval.new/1
without specifying a module
option:
iex> Interval.new(left: 1, right: 2)
Instead of
iex> Interval.new(module: Interval.Integer, left: 1, right: 2)
# or equivalent
iex> Interval.Integer.new(left: 1, right: 2)
This functionality is purely for ergonomic reasons, and is not required to be able to define custom intervals, or to use the builtin ones.
Explicitly calling Interval.Integer.new/1
could be preferred in certain
situations because you know exactly what implementation you are getting.
Link to this section Summary
Functions
Return the Interval.Behaviour implementation to use for this value type
Link to this section Types
@type t() :: term()
Link to this section Functions
Return the Interval.Behaviour implementation to use for this value type