hakaru-0.3.0: A probabilistic programming language

Data.Number.Nat

Description

A data type for natural numbers (aka non-negative integers).

Synopsis

# Documentation

data Nat Source #

Natural numbers, with fixed-width à la Int. N.B., the Num instance will throw errors on subtraction, negation, and fromInteger when the result is not a natural number.

Instances

 Source # Methodssucc :: Nat -> Nat #pred :: Nat -> Nat #toEnum :: Int -> Nat #fromEnum :: Nat -> Int #enumFrom :: Nat -> [Nat] #enumFromThen :: Nat -> Nat -> [Nat] #enumFromTo :: Nat -> Nat -> [Nat] #enumFromThenTo :: Nat -> Nat -> Nat -> [Nat] # Source # Methods(==) :: Nat -> Nat -> Bool #(/=) :: Nat -> Nat -> Bool # Source # Methodsquot :: Nat -> Nat -> Nat #rem :: Nat -> Nat -> Nat #div :: Nat -> Nat -> Nat #mod :: Nat -> Nat -> Nat #quotRem :: Nat -> Nat -> (Nat, Nat) #divMod :: Nat -> Nat -> (Nat, Nat) # Source # Methods(+) :: Nat -> Nat -> Nat #(-) :: Nat -> Nat -> Nat #(*) :: Nat -> Nat -> Nat #negate :: Nat -> Nat #abs :: Nat -> Nat #signum :: Nat -> Nat # Source # Methodscompare :: Nat -> Nat -> Ordering #(<) :: Nat -> Nat -> Bool #(<=) :: Nat -> Nat -> Bool #(>) :: Nat -> Nat -> Bool #(>=) :: Nat -> Nat -> Bool #max :: Nat -> Nat -> Nat #min :: Nat -> Nat -> Nat # Source # Methods Source # Methods Source # MethodsshowsPrec :: Int -> Nat -> ShowS #show :: Nat -> String #showList :: [Nat] -> ShowS #

Safely convert a natural number to an integer.

Safely convert an integer to a natural number. Returns Nothing if the integer is negative.

Unsafely convert an integer to a natural number. Throws an error if the integer is negative.

newtype MaxNat Source #

Constructors

 MaxNat FieldsunMaxNat :: Nat

Instances

 Source # Methodsmconcat :: [MaxNat] -> MaxNat #