Common type classes
The Haskell standard library features a range of other type classes that are frequently used in Haskell applications. We provide an overview here.
Ord
The Ord
type class captures types that have a total ordering. This means that for any two values of the type, we can determine which one is less than the other. The type class itself comes with a slew of methods based on this ordering:
Prelude
class Eq a => Ord a where
compare :: a -> a -> Ordering
(<) :: a -> a -> Bool
(<=) :: a -> a -> Bool
(>) :: a -> a -> Bool
(>=) :: a -> a -> Bool
max :: a -> a -> a
min :: a -> a -> a
Besides the four well-known comparison operators, we see three additional methods....