Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Documentation
class Eq a => Ord a where Source #
Linear Orderings
Linear orderings provide a strict order. The laws for (<=)
for
all \(a,b,c\):
- reflexivity: \(a \leq a \)
- antisymmetry: \((a \leq b) \land (b \leq a) \rightarrow (a = b) \)
- transitivity: \((a \leq b) \land (b \leq c) \rightarrow (a \leq c) \)
and these "agree" with <
:
x <= y
=not (y > x)
x >= y
=not (y < x)
Unlike in the non-linear setting, a linear compare
doesn't follow from
<=
since it requires calls: one to <=
and one to ==
. However,
from a linear compare
it is easy to implement the others. Hence, the
minimal complete definition only contains compare
.
compare :: a %1 -> a %1 -> Ordering infix 4 Source #
compare x y
returns an Ordering
which is
one of GT
(greater than), EQ
(equal), or LT
(less than)
which should be understood as "x is (compare x y)
y".
(<=) :: a %1 -> a %1 -> Bool infix 4 Source #
(<) :: a %1 -> a %1 -> Bool infix 4 Source #
Instances
Ord Int16 Source # | |
Ord Int32 Source # | |
Ord Int64 Source # | |
Ord Int8 Source # | |
Ord Word16 Source # | |
Ord Word32 Source # | |
Ord Word64 Source # | |
Ord Word8 Source # | |
Ord Ordering Source # | |
Defined in Data.Ord.Linear.Internal.Ord | |
Ord () Source # | |
Ord Bool Source # | |
Ord Char Source # | |
Ord Double Source # | |
Ord Int Source # | |
Ord a => Ord (Ur a) Source # | |
(Consumable a, Ord a) => Ord (Maybe a) Source # | |
(Consumable a, Ord a) => Ord [a] Source # | |
(Consumable a, Consumable b, Ord a, Ord b) => Ord (Either a b) Source # | |
Defined in Data.Ord.Linear.Internal.Ord | |
(Ord a, Ord b) => Ord (a, b) Source # | |
(Ord a, Ord b, Ord c) => Ord (a, b, c) Source # | |
Defined in Data.Ord.Linear.Internal.Ord | |
(Ord a, Ord b, Ord c, Ord d) => Ord (a, b, c, d) Source # | |
Instances
Monoid Ordering | Since: base-2.1 |
Semigroup Ordering | Since: base-4.9.0.0 |
Bounded Ordering | Since: base-2.1 |
Enum Ordering | Since: base-2.1 |
Generic Ordering | |
Ix Ordering | Since: base-2.1 |
Defined in GHC.Ix | |
Read Ordering | Since: base-2.1 |
Show Ordering | Since: base-2.1 |
Eq Ordering | |
Ord Ordering | |
Defined in GHC.Classes | |
Hashable Ordering | |
Defined in Data.Hashable.Class | |
Monoid Ordering Source # | |
Defined in Data.Monoid.Linear.Internal.Monoid | |
Semigroup Ordering Source # | |
Eq Ordering Source # | |
Ord Ordering Source # | |
Defined in Data.Ord.Linear.Internal.Ord | |
Consumable Ordering Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
Dupable Ordering Source # | |
Movable Ordering Source # | |
type Rep Ordering | Since: base-4.6.0.0 |
type Rep Ordering | |
Defined in Generics.Linear.Instances.Base |
min :: (Dupable a, Ord a) => a %1 -> a %1 -> a Source #
min x y
returns the smaller input, or y
in case of a tie.
max :: (Dupable a, Ord a) => a %1 -> a %1 -> a Source #
max x y
returns the larger input, or y
in case of a tie.
Testing equality on values.
The laws are that (==) and (/=) are compatible
and (==) is an equivalence relation. So, for all x
, y
, z
,
x == x
alwaysx == y
impliesy == x
x == y
andy == z
impliesx == z
(x == y)
≌not (x /= y)
Instances
Eq Int16 Source # | |
Eq Int32 Source # | |
Eq Int64 Source # | |
Eq Int8 Source # | |
Eq Word16 Source # | |
Eq Word32 Source # | |
Eq Word64 Source # | |
Eq Word8 Source # | |
Eq Ordering Source # | |
Eq () Source # | |
Eq Bool Source # | |
Eq Char Source # | |
Eq Double Source # | |
Eq Int Source # | |
Eq a => Eq (Ur a) Source # | |
(Consumable a, Eq a) => Eq (Maybe a) Source # | |
(Consumable a, Eq a) => Eq [a] Source # | |
(Consumable a, Consumable b, Eq a, Eq b) => Eq (Either a b) Source # | |
(Eq a, Eq b) => Eq (a, b) Source # | |
(Eq a, Eq b, Eq c) => Eq (a, b, c) Source # | |
(Eq a, Eq b, Eq c, Eq d) => Eq (a, b, c, d) Source # | |