hakaru-0.3.0: A probabilistic programming language

Data.Number.Natural

Description

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

Synopsis

# Documentation

data Natural Source #

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

Instances

 Source # MethodsenumFrom :: Natural -> [Natural] #enumFromThen :: Natural -> Natural -> [Natural] #enumFromTo :: Natural -> Natural -> [Natural] #enumFromThenTo :: Natural -> Natural -> Natural -> [Natural] # Source # Methods(==) :: Natural -> Natural -> Bool #(/=) :: Natural -> Natural -> Bool # Source # MethodsquotRem :: Natural -> Natural -> (Natural, Natural) #divMod :: Natural -> Natural -> (Natural, Natural) # Source # Methods Source # Methods(<) :: Natural -> Natural -> Bool #(<=) :: Natural -> Natural -> Bool #(>) :: Natural -> Natural -> Bool #(>=) :: Natural -> Natural -> Bool # Source # Methods Source # Methods Source # MethodsshowList :: [Natural] -> ShowS # Source # Methodsreify :: ABT Hakaru Term abt => Head abt HNat -> Natural Source #reflect :: ABT Hakaru Term abt => Natural -> Head abt HNat Source # Source # Methods

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 MaxNatural Source #

Constructors

 MaxNatural FieldsunMaxNatural :: Natural

Instances

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

Safely convert a non-negative rational to a rational.

Safely convert a rational to a non-negative rational. Returns Nothing if the argument is negative.

Unsafely convert a rational to a non-negative rational. Throws an error if the argument is negative.