hakaru-0.3.0: A probabilistic programming language

CopyrightCopyright (c) 2016 the Hakaru team
LicenseBSD3
Maintainerwren@community.haskell.org
Stabilityexperimental
PortabilityHaskell98 + CPP
Safe HaskellSafe
LanguageHaskell2010

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

Enum Natural Source # 
Eq Natural Source # 

Methods

(==) :: Natural -> Natural -> Bool #

(/=) :: Natural -> Natural -> Bool #

Integral Natural Source # 
Num Natural Source # 
Ord Natural Source # 
Read Natural Source # 
Real Natural Source # 
Show Natural Source # 
Interp HNat Natural Source # 

Methods

reify :: ABT Hakaru Term abt => Head abt HNat -> Natural Source #

reflect :: ABT Hakaru Term abt => Natural -> Head abt HNat Source #

Interp HProb NonNegativeRational Source # 

fromNatural :: Natural -> Integer Source #

Safely convert a natural number to an integer.

toNatural :: Integer -> Maybe Natural Source #

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

unsafeNatural :: Integer -> Natural Source #

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

fromNonNegativeRational :: NonNegativeRational -> Rational Source #

Safely convert a non-negative rational to a rational.

toNonNegativeRational :: Rational -> Maybe NonNegativeRational Source #

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

unsafeNonNegativeRational :: Rational -> NonNegativeRational Source #

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