Safe Haskell | None |
---|---|
Language | Haskell2010 |
Documentation
An Ordinal can only hold m different values, ususally corresponding to 0 .. m - 1. We store it here using a Proxy
of a type level number and use constraints to keep the required invariants.
Desprite represeting a number, Ordinal is not an instance of Num and many functions (such as negate) would only be partial
((<=) 1 m, KnownNat m) => Bounded (Ordinal m) Source # | |
((<=) 1 m, KnownNat m) => Enum (Ordinal m) Source # | |
Eq (Ordinal m) Source # | |
Ord (Ordinal m) Source # | |
Show (Ordinal m) Source # | |
((<=) 1 m, KnownNat m) => Random (Ordinal m) Source # | |
KnownNat m => ToJSONKey (Ordinal m) Source # | |
KnownNat m => ToJSON (Ordinal m) Source # | |
KnownNat m => FromJSONKey (Ordinal m) Source # | |
KnownNat m => FromJSON (Ordinal m) Source # | |
((<=) 1 n, KnownNat n) => IsCoord (Ordinal n) Source # | |
type CoordSized (Ordinal n) Source # | |
numToOrdinal :: forall a m. (KnownNat m, Integral a) => a -> Maybe (Ordinal m) Source #
Convert a normal integral to an ordinal. If it is outside the range (or= m), Nothing is returned.
ordinalToNum :: Num a => Ordinal m -> a Source #
Transform an ordinal to a given number