tensor-0.1: A completely type-safe library for linear algebra

Safe HaskellSafe-Infered

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 Show instances so that their elements are displayed with usual decimal number.

One = {One} = {1}

Succ One = {First, Succ One} = {1,2}

Succ Succ One = {First, Succ First, Succ Succ One} = {1,2,3}

...

Synopsis

Documentation

data One Source

A set with one element.

Constructors

One 

data Succ n Source

If n is a set with n elements, Succ n is a set with n+1 elements.

Constructors

First

The first element of the type.

Succ n

The last n elements.

Instances

Monad Succ 
Functor Succ 
(Ordinal m, Ordinal n, Prod m n, Sum m (:*: m n), Ordinal (:+: m (:*: m n))) => Prod m (Succ n) 
(Ordinal m, Ordinal n, Ordinal (:+: m n), Sum m n) => Sum m (Succ n) 
Bounded n => Bounded (Succ n) 
(Bounded n, Enum n, Ordinal n) => Enum (Succ n) 
Eq n => Eq (Succ n) 
Ord n => Ord (Succ n) 
Ordinal n => Show (Succ n) 
Cardinality n => Cardinality (Succ n) 
Ordinal n => Ordinal (Succ n) 

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.

Methods

fromOrdinal :: Num i => n -> iSource

toOrdinal :: (Eq i, Num i) => i -> nSource

Instances