Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This provides "kindclasses" (actually open type families) with functionality
analogous to that provided by the typeclasses Ord
and Num
. Since
type-level typeclasses don't exist, instead we translate each would-be
method to its own open type family; then "instances" are implemented by
providing clauses for each type family "method". Unfortunately this means
we can't group methods into classes that must be implemented all-or-none,
but in practice this seems to be okay.
Synopsis
- type family Cmp (x :: k) (y :: k) :: Ordering
- type (<?) x y = IsLT (Cmp x y)
- type (<=?) x y = IsLE (Cmp x y)
- type (==?) x y = IsEQ (Cmp x y)
- type (/=?) x y = IsNE (Cmp x y)
- type (>=?) x y = IsGE (Cmp x y)
- type (>?) x y = IsGT (Cmp x y)
- type (<) x y = Cmp x y ~ 'LT
- type (<=) x y = Proven (x <=? y)
- type (==) x y = Cmp x y ~ 'EQ
- type (/=) x y = Proven (x /=? y)
- type (>=) x y = Proven (x >=? y)
- type (>) x y = Cmp x y ~ 'GT
- type family FromNat (n :: Nat) :: k
- type family ToInteger (n :: k) :: Integer
- type family (x :: k) + (y :: k) :: k
- type family (x :: k) - (y :: k) :: k
- type family (x :: k) * (y :: k) :: k
- type Proven b = b ~ 'True
- type family IsLT o where ...
- type family IsLE o where ...
- type family IsGT o where ...
- type family IsGE o where ...
- type family IsEQ o where ...
- type family IsNE o where ...
Comparisons
type family Cmp (x :: k) (y :: k) :: Ordering Source #
Type-level Ord "kindclass".
Note this has an invisible dependent k
parameter that makes the
textually-identical instances for different kinds actually different. Neat!
Inequality Constraints
Conversions
type family FromNat (n :: Nat) :: k Source #
Type-level numeric conversion from Nat
. Like fromInteger
in Num
.