Ord – ordered types
The Ord
class requires any type that wants to be an instance of it to first be an instance of the Eq
class by using a class constraint, and additionally, to support the following methods:
In other words, the Ord
class extends the Eq
class and supports additional methods (<)
, (<=)
, (>)
, (>=)
, min
and max
. The min
and max
methods are defined by default as:
And for a minimal definition of the class, we just need to define the (<=)
method because the other ones also have default definitions:
All the basic types of Haskell are also instances of the Ord
class.
Last updated