| Portability | non-portable |
|---|---|
| Stability | experimental |
| Maintainer | Nicola Squartini <tensor5@gmail.com> |
| Safe Haskell | Safe-Inferred |
Data.Ordinal
Description
In this module we provide a way to canonically define a totally ordered set
with a given number of elements. These types have a custom
instances so that their elements are displayed with usual decimal number.
Show
= {Succ One, First} = {1,2}
Succ One
= {Succ Succ One, First, Succ First} = {1,2,3}
Succ
Succ One
...
- data One = One
- data Succ n
- type Two = Succ One
- type Three = Succ Two
- type Four = Succ Three
- type Five = Succ Four
- type Six = Succ Five
- type Seven = Succ Six
- type Eight = Succ Seven
- type Nine = Succ Eight
- type Ten = Succ Nine
- class (Cardinality n, Ord n) => Ordinal n where
- fromOrdinal :: Num i => n -> i
- toOrdinal :: (Eq i, Num i) => i -> n
- module Data.TypeAlgebra
Documentation
A set with one element.
Constructors
| One |
Instances
| Bounded One | |
| Enum One | |
| Eq One | |
| Ord One | |
| Show One | |
| Generic One | |
| Cardinality One | |
| Random One | |
| Ordinal One | |
| Ordinal m => Prod m One | |
| Ordinal m => Sum m One | |
| (MultiIndex is, Functor (Tensor is)) => Functor (Tensor (:|: One is)) | |
| (MultiIndex is, Applicative (Tensor is)) => Applicative (Tensor (:|: One is)) | |
| (FromList (Tensor is), MultiIndex is) => FromList (Tensor (:|: One is)) | |
| (MultiIndex is, Eq (Tensor is e)) => Eq (Tensor (:|: One is) e) | |
| (MultiIndex is, Show (Tensor is e)) => Show (Tensor (:|: One is) e) | |
| (MultiIndex is, Tensor (Tensor is e), ~ * e (Elem (Tensor is e)), ~ * is (Index (Tensor is e))) => Tensor (Tensor (:|: One is) e) | |
| Dimensions (Tensor is e) => Dimensions (Tensor (:|: One is) e) |
If n is a set with n elements, is a set with n+1 elements.
Succ n
Instances
class (Cardinality n, Ord n) => Ordinal n whereSource
Class of ordered sets with n elements. The methods in this class provide a convenient way to convert to and from a numeric type.
module Data.TypeAlgebra