base-4.20.2.0: Core data structures and operations

License | BSD-style (see the LICENSE file in the distribution)
Maintainer | libraries@haskell.org
Stability | stable
Portability | not portable
Safe Haskell | Safe
Language | Haskell2010

Data.Type.Ord

Description

Basic operations on type-level Orderings.

Since: base-4.16.0.0

Synopsis

- type family Compare (a :: k) (b :: k) :: Ordering
- data OrderingI (a :: k) (b :: k) where
  - LTI :: forall {k} (a :: k) (b :: k). Compare a b ~ 'LT => OrderingI a b
  - EQI :: forall {k} (a :: k). Compare a a ~ 'EQ => OrderingI a a
  - GTI :: forall {k} (a :: k) (b :: k). Compare a b ~ 'GT => OrderingI a b
- type (<=) (x :: t) (y :: t) = Assert (x <=? y) (LeErrMsg x y :: Constraint)
- type (<=?) (m :: k) (n :: k) = OrdCond (Compare m n) 'True 'True 'False
- type (>=) (x :: t) (y :: t) = Assert (x >=? y) (GeErrMsg x y :: Constraint)
- type (>=?) (m :: k) (n :: k) = OrdCond (Compare m n) 'False 'True 'True
- type (>) (x :: t) (y :: t) = Assert (x >? y) (GtErrMsg x y :: Constraint)
- type (>?) (m :: k) (n :: k) = OrdCond (Compare m n) 'False 'False 'True
- type (<) (x :: t) (y :: t) = Assert (x <? y) (LtErrMsg x y :: Constraint)
- type (<?) (m :: k) (n :: k) = OrdCond (Compare m n) 'True 'False 'False
- type Max (m :: k) (n :: k) = OrdCond (Compare m n) n n m
- type Min (m :: k) (n :: k) = OrdCond (Compare m n) m m n
- type family OrdCond (o :: Ordering) (lt :: k) (eq :: k) (gt :: k) :: k where ...

# Documentation

type family Compare (a :: k) (b :: k) :: Ordering Source #

`Compare` branches on the kind of its arguments to either compare by `Symbol` or `Nat`.

Since: base-4.16.0.0

#### Instances

Instances details

type Compare (a :: Natural) (b :: Natural) |
Instance details Defined in GHC.Internal.Data.Type.Ord type Compare (a :: Natural) (b :: Natural) = CmpNat a b
type Compare (a :: Char) (b :: Char) |
Instance details Defined in GHC.Internal.Data.Type.Ord type Compare (a :: Char) (b :: Char) = CmpChar a b
type Compare (a :: Symbol) (b :: Symbol) |
Instance details Defined in GHC.Internal.Data.Type.Ord type Compare (a :: Symbol) (b :: Symbol) = CmpSymbol a b

data OrderingI (a :: k) (b :: k) where Source #

Ordering data type for type literals that provides proof of their ordering.

Since: base-4.16.0.0

Constructors

LTI :: forall {k} (a :: k) (b :: k). Compare a b ~ 'LT => OrderingI a b |
EQI :: forall {k} (a :: k). Compare a a ~ 'EQ => OrderingI a a |
GTI :: forall {k} (a :: k) (b :: k). Compare a b ~ 'GT => OrderingI a b |

#### Instances

Instances details

Show (OrderingI a b) |
Instance details Defined in GHC.Internal.Data.Type.Ord Methods showsPrec :: Int -> OrderingI a b -> ShowS Source # show :: OrderingI a b -> String Source # showList :: [OrderingI a b] -> ShowS Source #
Eq (OrderingI a b) |
Instance details Defined in GHC.Internal.Data.Type.Ord Methods (==) :: OrderingI a b -> OrderingI a b -> Bool Source # (/=) :: OrderingI a b -> OrderingI a b -> Bool Source #

type (<=) (x :: t) (y :: t) = Assert (x <=? y) (LeErrMsg x y :: Constraint) infix 4 Source #

Comparison (<=) of comparable types, as a constraint.

Since: base-4.16.0.0

type (<=?) (m :: k) (n :: k) = OrdCond (Compare m n) 'True 'True 'False infix 4 Source #

Comparison (<=) of comparable types, as a function.

Since: base-4.16.0.0

type (>=) (x :: t) (y :: t) = Assert (x >=? y) (GeErrMsg x y :: Constraint) infix 4 Source #

Comparison (>=) of comparable types, as a constraint.

Since: base-4.16.0.0

type (>=?) (m :: k) (n :: k) = OrdCond (Compare m n) 'False 'True 'True infix 4 Source #

Comparison (>=) of comparable types, as a function.

Since: base-4.16.0.0

type (>) (x :: t) (y :: t) = Assert (x >? y) (GtErrMsg x y :: Constraint) infix 4 Source #

Comparison (>) of comparable types, as a constraint.

Since: base-4.16.0.0

type (>?) (m :: k) (n :: k) = OrdCond (Compare m n) 'False 'False 'True infix 4 Source #

Comparison (>) of comparable types, as a function.

Since: base-4.16.0.0

type (<) (x :: t) (y :: t) = Assert (x <? y) (LtErrMsg x y :: Constraint) infix 4 Source #

Comparison (<) of comparable types, as a constraint.

Since: base-4.16.0.0

type (<?) (m :: k) (n :: k) = OrdCond (Compare m n) 'True 'False 'False infix 4 Source #

Comparison (<) of comparable types, as a function.

Since: base-4.16.0.0

type Max (m :: k) (n :: k) = OrdCond (Compare m n) n n m Source #

Maximum between two comparable types.

Since: base-4.16.0.0

type Min (m :: k) (n :: k) = OrdCond (Compare m n) m m n Source #

Minimum between two comparable types.

Since: base-4.16.0.0

type family OrdCond (o :: Ordering) (lt :: k) (eq :: k) (gt :: k) :: k where ... Source #

A case statement on `Ordering`.

`OrdCond c l e g` is `l` when `c ~ LT`, `e` when `c ~ EQ`, and `g` when `c ~ GT`.

Since: base-4.16.0.0

Equations

OrdCond 'LT (lt :: k) (eq :: k) (gt :: k) = lt |
OrdCond 'EQ (lt :: k) (eq :: k) (gt :: k) = eq |
OrdCond 'GT (lt :: k) (eq :: k) (gt :: k) = gt |