View Source Interval.Point protocol (Interval v0.1.1)
The Interval.Point
protocol defines a set of functions the Interval
module needs to use a value as a point in an interval.
Implementing this protocol for a type allows you to use that type as a point in the Interval type.
point-types
Point Types
Interval
accepts two kinds of point types:
- Discrete
- Continuous
discrete
Discrete
A discrete point type is one where the number of points in a bounded interval is finite and knowable.
Every discrete point has a concept of the next/1
and previous/1
point
(in contrast to something like a real number where there exists an infinite
number of points between two other points)
continuous
Continuous
The continuous point type is for points where there exists (at least conceptually) an
infinite number of points between two other points.
Examples of this are floats, points in time, etc.
These points have no useful notion of the "next" and "previous" point, and implements these functions as raising an error.
default-implementations
Default Implementations
This library ships with implementations for
If you wish to implement the Interval.Point
protocol for one of
these types yourself, you can disable the built-in implementation by
setting the module to false under the :interval
OTP application:
import Config
config :interval, Date, false
Link to this section Summary
Functions
Compare two interval points (of the same time) and returns if a is
Return the largest (right-most) of the two points.
Return the smallest (left-most) of the two points.
Given a point A, return the next value after A.
If the point type is continuous then this function should return a
Given a point A, return the previous value after A.
If the point type is continuous then this function should return a
Returns if the Point lies on a discrete (like integer) or a continuous line (like floats).
Link to this section Types
@type t() :: term()
Link to this section Functions
Compare two interval points (of the same time) and returns if a is
- less than
- equal
- greater than
b
Return the largest (right-most) of the two points.
Return the smallest (left-most) of the two points.
Given a point A, return the next value after A.
If the point type is continuous then this function should return a
Given a point A, return the previous value after A.
If the point type is continuous then this function should return a
@spec type(t()) :: :discrete | :continuous
Returns if the Point lies on a discrete (like integer) or a continuous line (like floats).