connections-0.2.0: Orders, Galois connections, and lattices.
Safe HaskellSafe
LanguageHaskell2010

Data.Order

Synopsis

Constraint kinds

type Order a = (Eq a, Preorder a) Source #

An order on a.

Note: ideally this would be a subclass of Preorder.

We instead use a constraint kind in order to retain compatibility with the downstream users of Eq.

type Total a = (Ord a, Preorder a) Source #

A total order on a.

Note: ideally this would be a subclass of Order, without instances for Float, Double, Rational, etc.

We instead use a constraint kind in order to retain compatibility with the downstream users of Ord.

Preorders

class Preorder a where Source #

A preorder on a.

A preorder relation <~ must satisfy the following two axioms:

\( \forall x: x \leq x \) (reflexivity)

\( \forall a, b, c: ((a \leq b) \wedge (b \leq c)) \Rightarrow (a \leq c) \) (transitivity)

Given a preorder on a one may define an equivalence relation ~~ such that a ~~ b if and only if a <~ b and b <~ a.

If no partion induced by ~~ contains more than a single element, then a is a partial order and we may define an Eq instance such that the following holds:

x == y = x ~~ y
x <= y = x < y || x ~~ y

Minimal complete definition: either pcompare or <~. Using pcompare can be more efficient for complex types.

Minimal complete definition

(<~) | pcompare

Methods

(<~) :: a -> a -> Bool infix 4 Source #

A non-strict preorder order relation on a.

Is x less than or equal to y?

<~ is reflexive, anti-symmetric, and transitive.

x <~ y = x < y || x ~~ y
x <~ y = maybe False (<~ EQ) (pcompare x y)

for all x, y in a.

(>~) :: a -> a -> Bool infix 4 Source #

A converse non-strict preorder relation on a.

Is x greater than or equal to y?

>~ is reflexive, anti-symmetric, and transitive.

x >~ y = x > y || x ~~ y
x >~ y = maybe False (>~ EQ) (pcompare x y)

for all x, y in a.

(?~) :: a -> a -> Bool infix 4 Source #

An equivalence relation on a.

Are x and y comparable?

?~ is reflexive, symmetric, and transitive.

If a implements Ord then we should have x ?~ y = True.

(~~) :: a -> a -> Bool infix 4 Source #

An equivalence relation on a.

Are x and y equivalent?

~~ is reflexive, symmetric, and transitive.

x ~~ y = x <~ y && y <~ x
x ~~ y = maybe False (~~ EQ) (pcompare x y)

Use this as a lawful substitute for == when comparing floats, doubles, or rationals.

(/~) :: a -> a -> Bool infix 4 Source #

Negation of ~~.

Are x and y not equivalent?

plt :: a -> a -> Bool infix 4 Source #

A strict preorder relation on a.

Is x less than y?

plt is irreflexive, asymmetric, and transitive.

x `plt` y = x <~ y && not (y <~ x)
x `plt` y = maybe False (< EQ) (pcompare x y)

When <~ is antisymmetric then a is a partial order and we have:

x `plt` y = x <~ y && x /~ y

for all x, y in a.

pgt :: a -> a -> Bool infix 4 Source #

A converse strict preorder relation on a.

Is x greater than y?

pgt is irreflexive, asymmetric, and transitive.

x `pgt` y = x >~ y && not (y >~ x)
x `pgt` y = maybe False (> EQ) (pcompare x y)

When <~ is antisymmetric then a is a partial order and we have:

x `pgt` y = x >~ y && x /~ y

for all x, y in a.

similar :: a -> a -> Bool Source #

A similarity relation on a.

Are x and y either equivalent or incomparable?

similar is reflexive and symmetric, but not necessarily transitive.

Note this is only equivalent to == in a total order:

similar (0/0 :: Float) 5 = True

If a implements Ord then we should have (~~) = similar = (==).

pmax :: a -> a -> Maybe a infix 4 Source #

A partial version of max.

Returns the left-hand argument in the case of equality.

pmin :: a -> a -> Maybe a infix 4 Source #

A partial version of min.

Returns the left-hand argument in the case of equality.

pcompare :: a -> a -> Maybe Ordering infix 4 Source #

A partial version of compare.

x <  y = maybe False (<  EQ) $ pcompare x y
x >  y = maybe False (>  EQ) $ pcompare x y
x <~ y = maybe False (<~ EQ) $ pcompare x y
x >~ y = maybe False (>~ EQ) $ pcompare x y
x ~~ y = maybe False (~~ EQ) $ pcompare x y
x ?~ y = maybe False (const True) $ pcompare x y
similar x y = maybe True (~~ EQ) $ pcompare x y

If a implements Ord then we should have pcompare x y = Just $ compare x y.

Instances

Instances details
Preorder Bool Source # 
Instance details

Defined in Data.Order

Preorder Char Source # 
Instance details

Defined in Data.Order

Preorder Double Source # 
Instance details

Defined in Data.Order

Preorder Float Source # 
Instance details

Defined in Data.Order

Preorder Int Source # 
Instance details

Defined in Data.Order

Preorder Int8 Source # 
Instance details

Defined in Data.Order

Preorder Int16 Source # 
Instance details

Defined in Data.Order

Preorder Int32 Source # 
Instance details

Defined in Data.Order

Preorder Int64 Source # 
Instance details

Defined in Data.Order

Preorder Integer Source # 
Instance details

Defined in Data.Order

Preorder Natural Source # 
Instance details

Defined in Data.Order

Preorder Ordering Source # 
Instance details

Defined in Data.Order

Preorder Rational Source # 
Instance details

Defined in Data.Order

Preorder Word Source # 
Instance details

Defined in Data.Order

Preorder Word8 Source # 
Instance details

Defined in Data.Order

Preorder Word16 Source # 
Instance details

Defined in Data.Order

Preorder Word32 Source # 
Instance details

Defined in Data.Order

Preorder Word64 Source # 
Instance details

Defined in Data.Order

Preorder () Source # 
Instance details

Defined in Data.Order

Methods

(<~) :: () -> () -> Bool Source #

(>~) :: () -> () -> Bool Source #

(?~) :: () -> () -> Bool Source #

(~~) :: () -> () -> Bool Source #

(/~) :: () -> () -> Bool Source #

plt :: () -> () -> Bool Source #

pgt :: () -> () -> Bool Source #

similar :: () -> () -> Bool Source #

pmax :: () -> () -> Maybe () Source #

pmin :: () -> () -> Maybe () Source #

pcompare :: () -> () -> Maybe Ordering Source #

Preorder Void Source # 
Instance details

Defined in Data.Order

Preorder All Source # 
Instance details

Defined in Data.Order

Preorder Any Source # 
Instance details

Defined in Data.Order

Preorder IntSet Source # 
Instance details

Defined in Data.Order

Preorder Positive Source # 
Instance details

Defined in Data.Order

Preorder a => Preorder [a] Source # 
Instance details

Defined in Data.Order

Methods

(<~) :: [a] -> [a] -> Bool Source #

(>~) :: [a] -> [a] -> Bool Source #

(?~) :: [a] -> [a] -> Bool Source #

(~~) :: [a] -> [a] -> Bool Source #

(/~) :: [a] -> [a] -> Bool Source #

plt :: [a] -> [a] -> Bool Source #

pgt :: [a] -> [a] -> Bool Source #

similar :: [a] -> [a] -> Bool Source #

pmax :: [a] -> [a] -> Maybe [a] Source #

pmin :: [a] -> [a] -> Maybe [a] Source #

pcompare :: [a] -> [a] -> Maybe Ordering Source #

Preorder a => Preorder (Maybe a) Source # 
Instance details

Defined in Data.Order

Methods

(<~) :: Maybe a -> Maybe a -> Bool Source #

(>~) :: Maybe a -> Maybe a -> Bool Source #

(?~) :: Maybe a -> Maybe a -> Bool Source #

(~~) :: Maybe a -> Maybe a -> Bool Source #

(/~) :: Maybe a -> Maybe a -> Bool Source #

plt :: Maybe a -> Maybe a -> Bool Source #

pgt :: Maybe a -> Maybe a -> Bool Source #

similar :: Maybe a -> Maybe a -> Bool Source #

pmax :: Maybe a -> Maybe a -> Maybe (Maybe a) Source #

pmin :: Maybe a -> Maybe a -> Maybe (Maybe a) Source #

pcompare :: Maybe a -> Maybe a -> Maybe Ordering Source #

(Preorder a, Num a) => Preorder (Complex a) Source # 
Instance details

Defined in Data.Order

Preorder a => Preorder (Min a) Source # 
Instance details

Defined in Data.Order

Methods

(<~) :: Min a -> Min a -> Bool Source #

(>~) :: Min a -> Min a -> Bool Source #

(?~) :: Min a -> Min a -> Bool Source #

(~~) :: Min a -> Min a -> Bool Source #

(/~) :: Min a -> Min a -> Bool Source #

plt :: Min a -> Min a -> Bool Source #

pgt :: Min a -> Min a -> Bool Source #

similar :: Min a -> Min a -> Bool Source #

pmax :: Min a -> Min a -> Maybe (Min a) Source #

pmin :: Min a -> Min a -> Maybe (Min a) Source #

pcompare :: Min a -> Min a -> Maybe Ordering Source #

Preorder a => Preorder (Max a) Source # 
Instance details

Defined in Data.Order

Methods

(<~) :: Max a -> Max a -> Bool Source #

(>~) :: Max a -> Max a -> Bool Source #

(?~) :: Max a -> Max a -> Bool Source #

(~~) :: Max a -> Max a -> Bool Source #

(/~) :: Max a -> Max a -> Bool Source #

plt :: Max a -> Max a -> Bool Source #

pgt :: Max a -> Max a -> Bool Source #

similar :: Max a -> Max a -> Bool Source #

pmax :: Max a -> Max a -> Maybe (Max a) Source #

pmin :: Max a -> Max a -> Maybe (Max a) Source #

pcompare :: Max a -> Max a -> Maybe Ordering Source #

Preorder a => Preorder (Identity a) Source # 
Instance details

Defined in Data.Order

Preorder a => Preorder (Dual a) Source # 
Instance details

Defined in Data.Order

Methods

(<~) :: Dual a -> Dual a -> Bool Source #

(>~) :: Dual a -> Dual a -> Bool Source #

(?~) :: Dual a -> Dual a -> Bool Source #

(~~) :: Dual a -> Dual a -> Bool Source #

(/~) :: Dual a -> Dual a -> Bool Source #

plt :: Dual a -> Dual a -> Bool Source #

pgt :: Dual a -> Dual a -> Bool Source #

similar :: Dual a -> Dual a -> Bool Source #

pmax :: Dual a -> Dual a -> Maybe (Dual a) Source #

pmin :: Dual a -> Dual a -> Maybe (Dual a) Source #

pcompare :: Dual a -> Dual a -> Maybe Ordering Source #

Preorder a => Preorder (Down a) Source # 
Instance details

Defined in Data.Order

Methods

(<~) :: Down a -> Down a -> Bool Source #

(>~) :: Down a -> Down a -> Bool Source #

(?~) :: Down a -> Down a -> Bool Source #

(~~) :: Down a -> Down a -> Bool Source #

(/~) :: Down a -> Down a -> Bool Source #

plt :: Down a -> Down a -> Bool Source #

pgt :: Down a -> Down a -> Bool Source #

similar :: Down a -> Down a -> Bool Source #

pmax :: Down a -> Down a -> Maybe (Down a) Source #

pmin :: Down a -> Down a -> Maybe (Down a) Source #

pcompare :: Down a -> Down a -> Maybe Ordering Source #

Preorder a => Preorder (NonEmpty a) Source # 
Instance details

Defined in Data.Order

Preorder a => Preorder (IntMap a) Source # 
Instance details

Defined in Data.Order

Ord a => Preorder (Set a) Source # 
Instance details

Defined in Data.Order

Methods

(<~) :: Set a -> Set a -> Bool Source #

(>~) :: Set a -> Set a -> Bool Source #

(?~) :: Set a -> Set a -> Bool Source #

(~~) :: Set a -> Set a -> Bool Source #

(/~) :: Set a -> Set a -> Bool Source #

plt :: Set a -> Set a -> Bool Source #

pgt :: Set a -> Set a -> Bool Source #

similar :: Set a -> Set a -> Bool Source #

pmax :: Set a -> Set a -> Maybe (Set a) Source #

pmin :: Set a -> Set a -> Maybe (Set a) Source #

pcompare :: Set a -> Set a -> Maybe Ordering Source #

(Ord a, Fractional a) => Preorder (N5 a) Source # 
Instance details

Defined in Data.Order

Methods

(<~) :: N5 a -> N5 a -> Bool Source #

(>~) :: N5 a -> N5 a -> Bool Source #

(?~) :: N5 a -> N5 a -> Bool Source #

(~~) :: N5 a -> N5 a -> Bool Source #

(/~) :: N5 a -> N5 a -> Bool Source #

plt :: N5 a -> N5 a -> Bool Source #

pgt :: N5 a -> N5 a -> Bool Source #

similar :: N5 a -> N5 a -> Bool Source #

pmax :: N5 a -> N5 a -> Maybe (N5 a) Source #

pmin :: N5 a -> N5 a -> Maybe (N5 a) Source #

pcompare :: N5 a -> N5 a -> Maybe Ordering Source #

Ord a => Preorder (Base a) Source # 
Instance details

Defined in Data.Order

Methods

(<~) :: Base a -> Base a -> Bool Source #

(>~) :: Base a -> Base a -> Bool Source #

(?~) :: Base a -> Base a -> Bool Source #

(~~) :: Base a -> Base a -> Bool Source #

(/~) :: Base a -> Base a -> Bool Source #

plt :: Base a -> Base a -> Bool Source #

pgt :: Base a -> Base a -> Bool Source #

similar :: Base a -> Base a -> Bool Source #

pmax :: Base a -> Base a -> Maybe (Base a) Source #

pmin :: Base a -> Base a -> Maybe (Base a) Source #

pcompare :: Base a -> Base a -> Maybe Ordering Source #

Preorder a => Preorder (Interval a) Source #

A containment order

Instance details

Defined in Data.Order.Interval

Preorder a => Preorder (Extended a) Source # 
Instance details

Defined in Data.Order.Extended

(Preorder a, Preorder b) => Preorder (Either a b) Source # 
Instance details

Defined in Data.Order

Methods

(<~) :: Either a b -> Either a b -> Bool Source #

(>~) :: Either a b -> Either a b -> Bool Source #

(?~) :: Either a b -> Either a b -> Bool Source #

(~~) :: Either a b -> Either a b -> Bool Source #

(/~) :: Either a b -> Either a b -> Bool Source #

plt :: Either a b -> Either a b -> Bool Source #

pgt :: Either a b -> Either a b -> Bool Source #

similar :: Either a b -> Either a b -> Bool Source #

pmax :: Either a b -> Either a b -> Maybe (Either a b) Source #

pmin :: Either a b -> Either a b -> Maybe (Either a b) Source #

pcompare :: Either a b -> Either a b -> Maybe Ordering Source #

(Preorder a, Preorder b) => Preorder (a, b) Source # 
Instance details

Defined in Data.Order

Methods

(<~) :: (a, b) -> (a, b) -> Bool Source #

(>~) :: (a, b) -> (a, b) -> Bool Source #

(?~) :: (a, b) -> (a, b) -> Bool Source #

(~~) :: (a, b) -> (a, b) -> Bool Source #

(/~) :: (a, b) -> (a, b) -> Bool Source #

plt :: (a, b) -> (a, b) -> Bool Source #

pgt :: (a, b) -> (a, b) -> Bool Source #

similar :: (a, b) -> (a, b) -> Bool Source #

pmax :: (a, b) -> (a, b) -> Maybe (a, b) Source #

pmin :: (a, b) -> (a, b) -> Maybe (a, b) Source #

pcompare :: (a, b) -> (a, b) -> Maybe Ordering Source #

(Ord k, Preorder a) => Preorder (Map k a) Source # 
Instance details

Defined in Data.Order

Methods

(<~) :: Map k a -> Map k a -> Bool Source #

(>~) :: Map k a -> Map k a -> Bool Source #

(?~) :: Map k a -> Map k a -> Bool Source #

(~~) :: Map k a -> Map k a -> Bool Source #

(/~) :: Map k a -> Map k a -> Bool Source #

plt :: Map k a -> Map k a -> Bool Source #

pgt :: Map k a -> Map k a -> Bool Source #

similar :: Map k a -> Map k a -> Bool Source #

pmax :: Map k a -> Map k a -> Maybe (Map k a) Source #

pmin :: Map k a -> Map k a -> Maybe (Map k a) Source #

pcompare :: Map k a -> Map k a -> Maybe Ordering Source #

(Preorder a, Preorder b, Preorder c) => Preorder (a, b, c) Source # 
Instance details

Defined in Data.Order

Methods

(<~) :: (a, b, c) -> (a, b, c) -> Bool Source #

(>~) :: (a, b, c) -> (a, b, c) -> Bool Source #

(?~) :: (a, b, c) -> (a, b, c) -> Bool Source #

(~~) :: (a, b, c) -> (a, b, c) -> Bool Source #

(/~) :: (a, b, c) -> (a, b, c) -> Bool Source #

plt :: (a, b, c) -> (a, b, c) -> Bool Source #

pgt :: (a, b, c) -> (a, b, c) -> Bool Source #

similar :: (a, b, c) -> (a, b, c) -> Bool Source #

pmax :: (a, b, c) -> (a, b, c) -> Maybe (a, b, c) Source #

pmin :: (a, b, c) -> (a, b, c) -> Maybe (a, b, c) Source #

pcompare :: (a, b, c) -> (a, b, c) -> Maybe Ordering Source #

(Preorder a, Preorder b, Preorder c, Preorder d) => Preorder (a, b, c, d) Source # 
Instance details

Defined in Data.Order

Methods

(<~) :: (a, b, c, d) -> (a, b, c, d) -> Bool Source #

(>~) :: (a, b, c, d) -> (a, b, c, d) -> Bool Source #

(?~) :: (a, b, c, d) -> (a, b, c, d) -> Bool Source #

(~~) :: (a, b, c, d) -> (a, b, c, d) -> Bool Source #

(/~) :: (a, b, c, d) -> (a, b, c, d) -> Bool Source #

plt :: (a, b, c, d) -> (a, b, c, d) -> Bool Source #

pgt :: (a, b, c, d) -> (a, b, c, d) -> Bool Source #

similar :: (a, b, c, d) -> (a, b, c, d) -> Bool Source #

pmax :: (a, b, c, d) -> (a, b, c, d) -> Maybe (a, b, c, d) Source #

pmin :: (a, b, c, d) -> (a, b, c, d) -> Maybe (a, b, c, d) Source #

pcompare :: (a, b, c, d) -> (a, b, c, d) -> Maybe Ordering Source #

(Preorder a, Preorder b, Preorder c, Preorder d, Preorder e) => Preorder (a, b, c, d, e) Source # 
Instance details

Defined in Data.Order

Methods

(<~) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool Source #

(>~) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool Source #

(?~) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool Source #

(~~) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool Source #

(/~) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool Source #

plt :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool Source #

pgt :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool Source #

similar :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool Source #

pmax :: (a, b, c, d, e) -> (a, b, c, d, e) -> Maybe (a, b, c, d, e) Source #

pmin :: (a, b, c, d, e) -> (a, b, c, d, e) -> Maybe (a, b, c, d, e) Source #

pcompare :: (a, b, c, d, e) -> (a, b, c, d, e) -> Maybe Ordering Source #

pcomparing :: Preorder a => (b -> a) -> b -> b -> Maybe Ordering Source #

A partial version of comparing.

pcomparing p x y = pcompare (p x) (p y)

The partial application pcomparing f induces a lawful preorder for any total function f.

DerivingVia

newtype Base a Source #

Constructors

Base 

Fields

Instances

Instances details
Functor Base Source # 
Instance details

Defined in Data.Order

Methods

fmap :: (a -> b) -> Base a -> Base b #

(<$) :: a -> Base b -> Base a #

Applicative Base Source # 
Instance details

Defined in Data.Order

Methods

pure :: a -> Base a #

(<*>) :: Base (a -> b) -> Base a -> Base b #

liftA2 :: (a -> b -> c) -> Base a -> Base b -> Base c #

(*>) :: Base a -> Base b -> Base b #

(<*) :: Base a -> Base b -> Base a #

Eq a => Eq (Base a) Source # 
Instance details

Defined in Data.Order

Methods

(==) :: Base a -> Base a -> Bool #

(/=) :: Base a -> Base a -> Bool #

Ord a => Ord (Base a) Source # 
Instance details

Defined in Data.Order

Methods

compare :: Base a -> Base a -> Ordering #

(<) :: Base a -> Base a -> Bool #

(<=) :: Base a -> Base a -> Bool #

(>) :: Base a -> Base a -> Bool #

(>=) :: Base a -> Base a -> Bool #

max :: Base a -> Base a -> Base a #

min :: Base a -> Base a -> Base a #

Show a => Show (Base a) Source # 
Instance details

Defined in Data.Order

Methods

showsPrec :: Int -> Base a -> ShowS #

show :: Base a -> String #

showList :: [Base a] -> ShowS #

Ord a => Preorder (Base a) Source # 
Instance details

Defined in Data.Order

Methods

(<~) :: Base a -> Base a -> Bool Source #

(>~) :: Base a -> Base a -> Bool Source #

(?~) :: Base a -> Base a -> Bool Source #

(~~) :: Base a -> Base a -> Bool Source #

(/~) :: Base a -> Base a -> Bool Source #

plt :: Base a -> Base a -> Bool Source #

pgt :: Base a -> Base a -> Bool Source #

similar :: Base a -> Base a -> Bool Source #

pmax :: Base a -> Base a -> Maybe (Base a) Source #

pmin :: Base a -> Base a -> Maybe (Base a) Source #

pcompare :: Base a -> Base a -> Maybe Ordering Source #

newtype N5 a Source #

Constructors

N5 

Fields

Instances

Instances details
Functor N5 Source # 
Instance details

Defined in Data.Order

Methods

fmap :: (a -> b) -> N5 a -> N5 b #

(<$) :: a -> N5 b -> N5 a #

Applicative N5 Source # 
Instance details

Defined in Data.Order

Methods

pure :: a -> N5 a #

(<*>) :: N5 (a -> b) -> N5 a -> N5 b #

liftA2 :: (a -> b -> c) -> N5 a -> N5 b -> N5 c #

(*>) :: N5 a -> N5 b -> N5 b #

(<*) :: N5 a -> N5 b -> N5 a #

Eq a => Eq (N5 a) Source # 
Instance details

Defined in Data.Order

Methods

(==) :: N5 a -> N5 a -> Bool #

(/=) :: N5 a -> N5 a -> Bool #

Show a => Show (N5 a) Source # 
Instance details

Defined in Data.Order

Methods

showsPrec :: Int -> N5 a -> ShowS #

show :: N5 a -> String #

showList :: [N5 a] -> ShowS #

(Ord a, Fractional a) => Preorder (N5 a) Source # 
Instance details

Defined in Data.Order

Methods

(<~) :: N5 a -> N5 a -> Bool Source #

(>~) :: N5 a -> N5 a -> Bool Source #

(?~) :: N5 a -> N5 a -> Bool Source #

(~~) :: N5 a -> N5 a -> Bool Source #

(/~) :: N5 a -> N5 a -> Bool Source #

plt :: N5 a -> N5 a -> Bool Source #

pgt :: N5 a -> N5 a -> Bool Source #

similar :: N5 a -> N5 a -> Bool Source #

pmax :: N5 a -> N5 a -> Maybe (N5 a) Source #

pmin :: N5 a -> N5 a -> Maybe (N5 a) Source #

pcompare :: N5 a -> N5 a -> Maybe Ordering Source #

Re-exports

data Ordering #

Constructors

LT 
EQ 
GT 

Instances

Instances details
Bounded Ordering

Since: base-2.1

Instance details

Defined in GHC.Enum

Enum Ordering

Since: base-2.1

Instance details

Defined in GHC.Enum

Eq Ordering 
Instance details

Defined in GHC.Classes

Ord Ordering 
Instance details

Defined in GHC.Classes

Read Ordering

Since: base-2.1

Instance details

Defined in GHC.Read

Show Ordering

Since: base-2.1

Instance details

Defined in GHC.Show

Generic Ordering

Since: base-4.6.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep Ordering :: Type -> Type #

Methods

from :: Ordering -> Rep Ordering x #

to :: Rep Ordering x -> Ordering #

Semigroup Ordering

Since: base-4.9.0.0

Instance details

Defined in GHC.Base

Monoid Ordering

Since: base-2.1

Instance details

Defined in GHC.Base

Preorder Ordering Source # 
Instance details

Defined in Data.Order

Boolean Ordering Source # 
Instance details

Defined in Data.Lattice

Methods

boolean :: forall (k :: Kan). Conn k Ordering Ordering Source #

Symmetric Ordering Source # 
Instance details

Defined in Data.Lattice

Algebra 'L Ordering Source # 
Instance details

Defined in Data.Lattice

Algebra 'R Ordering Source # 
Instance details

Defined in Data.Lattice

Semilattice k Ordering Source # 
Instance details

Defined in Data.Lattice

Connection k () Ordering Source # 
Instance details

Defined in Data.Connection.Class

Methods

conn :: Conn k () Ordering Source #

Connection k Ordering Bool Source # 
Instance details

Defined in Data.Connection.Class

Connection k (Ordering, Ordering) Ordering Source # 
Instance details

Defined in Data.Connection.Class

type Rep Ordering 
Instance details

Defined in GHC.Generics

type Rep Ordering = D1 ('MetaData "Ordering" "GHC.Types" "ghc-prim" 'False) (C1 ('MetaCons "LT" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "EQ" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "GT" 'PrefixI 'False) (U1 :: Type -> Type)))

newtype Down a #

The Down type allows you to reverse sort order conveniently. A value of type Down a contains a value of type a (represented as Down a). If a has an Ord instance associated with it then comparing two values thus wrapped will give you the opposite of their normal sort order. This is particularly useful when sorting in generalised list comprehensions, as in: then sortWith by Down x

Since: base-4.6.0.0

Constructors

Down 

Fields

Instances

Instances details
Monad Down

Since: base-4.11.0.0

Instance details

Defined in Data.Ord

Methods

(>>=) :: Down a -> (a -> Down b) -> Down b #

(>>) :: Down a -> Down b -> Down b #

return :: a -> Down a #

Functor Down

Since: base-4.11.0.0

Instance details

Defined in Data.Ord

Methods

fmap :: (a -> b) -> Down a -> Down b #

(<$) :: a -> Down b -> Down a #

Applicative Down

Since: base-4.11.0.0

Instance details

Defined in Data.Ord

Methods

pure :: a -> Down a #

(<*>) :: Down (a -> b) -> Down a -> Down b #

liftA2 :: (a -> b -> c) -> Down a -> Down b -> Down c #

(*>) :: Down a -> Down b -> Down b #

(<*) :: Down a -> Down b -> Down a #

Foldable Down

Since: base-4.12.0.0

Instance details

Defined in Data.Foldable

Methods

fold :: Monoid m => Down m -> m #

foldMap :: Monoid m => (a -> m) -> Down a -> m #

foldMap' :: Monoid m => (a -> m) -> Down a -> m #

foldr :: (a -> b -> b) -> b -> Down a -> b #

foldr' :: (a -> b -> b) -> b -> Down a -> b #

foldl :: (b -> a -> b) -> b -> Down a -> b #

foldl' :: (b -> a -> b) -> b -> Down a -> b #

foldr1 :: (a -> a -> a) -> Down a -> a #

foldl1 :: (a -> a -> a) -> Down a -> a #

toList :: Down a -> [a] #

null :: Down a -> Bool #

length :: Down a -> Int #

elem :: Eq a => a -> Down a -> Bool #

maximum :: Ord a => Down a -> a #

minimum :: Ord a => Down a -> a #

sum :: Num a => Down a -> a #

product :: Num a => Down a -> a #

Traversable Down

Since: base-4.12.0.0

Instance details

Defined in Data.Traversable

Methods

traverse :: Applicative f => (a -> f b) -> Down a -> f (Down b) #

sequenceA :: Applicative f => Down (f a) -> f (Down a) #

mapM :: Monad m => (a -> m b) -> Down a -> m (Down b) #

sequence :: Monad m => Down (m a) -> m (Down a) #

Eq1 Down

Since: base-4.12.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftEq :: (a -> b -> Bool) -> Down a -> Down b -> Bool #

Ord1 Down

Since: base-4.12.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftCompare :: (a -> b -> Ordering) -> Down a -> Down b -> Ordering #

Read1 Down

Since: base-4.12.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Down a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Down a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Down a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Down a] #

Show1 Down

Since: base-4.12.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Down a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Down a] -> ShowS #

Bounded a => Bounded (Down a)

Since: base-4.14.0.0

Instance details

Defined in Data.Ord

Methods

minBound :: Down a #

maxBound :: Down a #

Enum a => Enum (Down a)

Since: base-4.14.0.0

Instance details

Defined in Data.Ord

Methods

succ :: Down a -> Down a #

pred :: Down a -> Down a #

toEnum :: Int -> Down a #

fromEnum :: Down a -> Int #

enumFrom :: Down a -> [Down a] #

enumFromThen :: Down a -> Down a -> [Down a] #

enumFromTo :: Down a -> Down a -> [Down a] #

enumFromThenTo :: Down a -> Down a -> Down a -> [Down a] #

Eq a => Eq (Down a)

Since: base-4.6.0.0

Instance details

Defined in Data.Ord

Methods

(==) :: Down a -> Down a -> Bool #

(/=) :: Down a -> Down a -> Bool #

Floating a => Floating (Down a)

Since: base-4.14.0.0

Instance details

Defined in Data.Ord

Methods

pi :: Down a #

exp :: Down a -> Down a #

log :: Down a -> Down a #

sqrt :: Down a -> Down a #

(**) :: Down a -> Down a -> Down a #

logBase :: Down a -> Down a -> Down a #

sin :: Down a -> Down a #

cos :: Down a -> Down a #

tan :: Down a -> Down a #

asin :: Down a -> Down a #

acos :: Down a -> Down a #

atan :: Down a -> Down a #

sinh :: Down a -> Down a #

cosh :: Down a -> Down a #

tanh :: Down a -> Down a #

asinh :: Down a -> Down a #

acosh :: Down a -> Down a #

atanh :: Down a -> Down a #

log1p :: Down a -> Down a #

expm1 :: Down a -> Down a #

log1pexp :: Down a -> Down a #

log1mexp :: Down a -> Down a #

Fractional a => Fractional (Down a)

Since: base-4.14.0.0

Instance details

Defined in Data.Ord

Methods

(/) :: Down a -> Down a -> Down a #

recip :: Down a -> Down a #

fromRational :: Rational -> Down a #

Integral a => Integral (Down a)

Since: base-4.14.0.0

Instance details

Defined in Data.Ord

Methods

quot :: Down a -> Down a -> Down a #

rem :: Down a -> Down a -> Down a #

div :: Down a -> Down a -> Down a #

mod :: Down a -> Down a -> Down a #

quotRem :: Down a -> Down a -> (Down a, Down a) #

divMod :: Down a -> Down a -> (Down a, Down a) #

toInteger :: Down a -> Integer #

Num a => Num (Down a)

Since: base-4.11.0.0

Instance details

Defined in Data.Ord

Methods

(+) :: Down a -> Down a -> Down a #

(-) :: Down a -> Down a -> Down a #

(*) :: Down a -> Down a -> Down a #

negate :: Down a -> Down a #

abs :: Down a -> Down a #

signum :: Down a -> Down a #

fromInteger :: Integer -> Down a #

Ord a => Ord (Down a)

Since: base-4.6.0.0

Instance details

Defined in Data.Ord

Methods

compare :: Down a -> Down a -> Ordering #

(<) :: Down a -> Down a -> Bool #

(<=) :: Down a -> Down a -> Bool #

(>) :: Down a -> Down a -> Bool #

(>=) :: Down a -> Down a -> Bool #

max :: Down a -> Down a -> Down a #

min :: Down a -> Down a -> Down a #

Read a => Read (Down a)

This instance would be equivalent to the derived instances of the Down newtype if the getDown field were removed

Since: base-4.7.0.0

Instance details

Defined in Data.Ord

Real a => Real (Down a)

Since: base-4.14.0.0

Instance details

Defined in Data.Ord

Methods

toRational :: Down a -> Rational #

RealFloat a => RealFloat (Down a)

Since: base-4.14.0.0

Instance details

Defined in Data.Ord

RealFrac a => RealFrac (Down a)

Since: base-4.14.0.0

Instance details

Defined in Data.Ord

Methods

properFraction :: Integral b => Down a -> (b, Down a) #

truncate :: Integral b => Down a -> b #

round :: Integral b => Down a -> b #

ceiling :: Integral b => Down a -> b #

floor :: Integral b => Down a -> b #

Show a => Show (Down a)

This instance would be equivalent to the derived instances of the Down newtype if the getDown field were removed

Since: base-4.7.0.0

Instance details

Defined in Data.Ord

Methods

showsPrec :: Int -> Down a -> ShowS #

show :: Down a -> String #

showList :: [Down a] -> ShowS #

Ix a => Ix (Down a)

Since: base-4.14.0.0

Instance details

Defined in Data.Ord

Methods

range :: (Down a, Down a) -> [Down a] #

index :: (Down a, Down a) -> Down a -> Int #

unsafeIndex :: (Down a, Down a) -> Down a -> Int #

inRange :: (Down a, Down a) -> Down a -> Bool #

rangeSize :: (Down a, Down a) -> Int #

unsafeRangeSize :: (Down a, Down a) -> Int #

Generic (Down a)

Since: base-4.12.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep (Down a) :: Type -> Type #

Methods

from :: Down a -> Rep (Down a) x #

to :: Rep (Down a) x -> Down a #

Semigroup a => Semigroup (Down a)

Since: base-4.11.0.0

Instance details

Defined in Data.Ord

Methods

(<>) :: Down a -> Down a -> Down a #

sconcat :: NonEmpty (Down a) -> Down a #

stimes :: Integral b => b -> Down a -> Down a #

Monoid a => Monoid (Down a)

Since: base-4.11.0.0

Instance details

Defined in Data.Ord

Methods

mempty :: Down a #

mappend :: Down a -> Down a -> Down a #

mconcat :: [Down a] -> Down a #

Storable a => Storable (Down a)

Since: base-4.14.0.0

Instance details

Defined in Data.Ord

Methods

sizeOf :: Down a -> Int #

alignment :: Down a -> Int #

peekElemOff :: Ptr (Down a) -> Int -> IO (Down a) #

pokeElemOff :: Ptr (Down a) -> Int -> Down a -> IO () #

peekByteOff :: Ptr b -> Int -> IO (Down a) #

pokeByteOff :: Ptr b -> Int -> Down a -> IO () #

peek :: Ptr (Down a) -> IO (Down a) #

poke :: Ptr (Down a) -> Down a -> IO () #

Bits a => Bits (Down a)

Since: base-4.14.0.0

Instance details

Defined in Data.Ord

Methods

(.&.) :: Down a -> Down a -> Down a #

(.|.) :: Down a -> Down a -> Down a #

xor :: Down a -> Down a -> Down a #

complement :: Down a -> Down a #

shift :: Down a -> Int -> Down a #

rotate :: Down a -> Int -> Down a #

zeroBits :: Down a #

bit :: Int -> Down a #

setBit :: Down a -> Int -> Down a #

clearBit :: Down a -> Int -> Down a #

complementBit :: Down a -> Int -> Down a #

testBit :: Down a -> Int -> Bool #

bitSizeMaybe :: Down a -> Maybe Int #

bitSize :: Down a -> Int #

isSigned :: Down a -> Bool #

shiftL :: Down a -> Int -> Down a #

unsafeShiftL :: Down a -> Int -> Down a #

shiftR :: Down a -> Int -> Down a #

unsafeShiftR :: Down a -> Int -> Down a #

rotateL :: Down a -> Int -> Down a #

rotateR :: Down a -> Int -> Down a #

popCount :: Down a -> Int #

FiniteBits a => FiniteBits (Down a)

Since: base-4.14.0.0

Instance details

Defined in Data.Ord

Preorder a => Preorder (Down a) Source # 
Instance details

Defined in Data.Order

Methods

(<~) :: Down a -> Down a -> Bool Source #

(>~) :: Down a -> Down a -> Bool Source #

(?~) :: Down a -> Down a -> Bool Source #

(~~) :: Down a -> Down a -> Bool Source #

(/~) :: Down a -> Down a -> Bool Source #

plt :: Down a -> Down a -> Bool Source #

pgt :: Down a -> Down a -> Bool Source #

similar :: Down a -> Down a -> Bool Source #

pmax :: Down a -> Down a -> Maybe (Down a) Source #

pmin :: Down a -> Down a -> Maybe (Down a) Source #

pcompare :: Down a -> Down a -> Maybe Ordering Source #

Generic1 Down

Since: base-4.12.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep1 Down :: k -> Type #

Methods

from1 :: forall (a :: k). Down a -> Rep1 Down a #

to1 :: forall (a :: k). Rep1 Down a -> Down a #

type Rep (Down a) 
Instance details

Defined in GHC.Generics

type Rep (Down a) = D1 ('MetaData "Down" "Data.Ord" "base" 'True) (C1 ('MetaCons "Down" 'PrefixI 'True) (S1 ('MetaSel ('Just "getDown") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))
type Rep1 Down 
Instance details

Defined in GHC.Generics

type Rep1 Down = D1 ('MetaData "Down" "Data.Ord" "base" 'True) (C1 ('MetaCons "Down" 'PrefixI 'True) (S1 ('MetaSel ('Just "getDown") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))

type Positive = Ratio Natural Source #

Positive rationals, extended with an absorbing zero.

Positive is the canonical semifield.