fin-0.1.1: Nat and Fin: peano naturals and finite numbers
Safe Haskell Safe-Inferred
Language Haskell2010

Data.Nat

Description

Nat numbers.

This module is designed to be imported qualified.

Synopsis

Natural, Nat numbers

data Nat Source #

Nat natural numbers.

Better than GHC's built-in Nat for some use cases.

Constructors

Z
S Nat

Instances

Instances details
Enum Nat Source #
Instance details

Defined in Data.Nat

Eq Nat Source #
Instance details

Defined in Data.Nat

Integral Nat Source #
Instance details

Defined in Data.Nat

Data Nat Source #
Instance details

Defined in Data.Nat

Methods

gfoldl :: ( forall d b. Data d => c (d -> b) -> d -> c b) -> ( forall g. g -> c g) -> Nat -> c Nat Source #

gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c Nat Source #

toConstr :: Nat -> Constr Source #

dataTypeOf :: Nat -> DataType Source #

dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c Nat ) Source #

dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c Nat ) Source #

gmapT :: ( forall b. Data b => b -> b) -> Nat -> Nat Source #

gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> Nat -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> Nat -> r Source #

gmapQ :: ( forall d. Data d => d -> u) -> Nat -> [u] Source #

gmapQi :: Int -> ( forall d. Data d => d -> u) -> Nat -> u Source #

gmapM :: Monad m => ( forall d. Data d => d -> m d) -> Nat -> m Nat Source #

gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> Nat -> m Nat Source #

gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> Nat -> m Nat Source #

Num Nat Source #
Instance details

Defined in Data.Nat

Ord Nat Source #
Instance details

Defined in Data.Nat

Real Nat Source #
Instance details

Defined in Data.Nat

Show Nat Source #

Nat is printed as Natural .

To see explicit structure, use explicitShow or explicitShowsPrec

Instance details

Defined in Data.Nat

Function Nat Source #
Instance details

Defined in Data.Nat

Arbitrary Nat Source #
Instance details

Defined in Data.Nat

CoArbitrary Nat Source #
Instance details

Defined in Data.Nat

NFData Nat Source #
Instance details

Defined in Data.Nat

Methods

rnf :: Nat -> () Source #

Hashable Nat Source #
Instance details

Defined in Data.Nat

TestEquality SNat Source #
Instance details

Defined in Data.Type.Nat

Methods

testEquality :: forall (a :: k) (b :: k). SNat a -> SNat b -> Maybe (a :~: b) Source #

toNatural :: Nat -> Natural Source #

Convert Nat to Natural

>>> toNatural 0
0
>>> toNatural 2
2
>>> toNatural $ S $ S $ Z
2

fromNatural :: Natural -> Nat Source #

Convert Natural to Nat

>>> fromNatural 4
4
>>> explicitShow (fromNatural 4)
"S (S (S (S Z)))"

cata :: a -> (a -> a) -> Nat -> a Source #

Fold Nat .

>>> cata [] ('x' :) 2
"xx"

Showing

explicitShow :: Nat -> String Source #

show displaying a structure of Nat .

>>> explicitShow 0
"Z"
>>> explicitShow 2
"S (S Z)"

Aliases