gini-math-0.1.0.0

Safe HaskellNone
LanguageHaskell2010

Gini.Math.Amount.Internal

Contents

Synopsis

Documentation

data Amount #

Instances
Bounded Amount # 
Instance details

Defined in Gini.Math.Amount.Internal

Eq Amount # 
Instance details

Defined in Gini.Math.Amount.Internal

Methods

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

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

Ord Amount # 
Instance details

Defined in Gini.Math.Amount.Internal

Show Amount # 
Instance details

Defined in Gini.Math.Amount.Internal

Storable Amount # 
Instance details

Defined in Gini.Math.Amount.Internal

Persist Amount # 
Instance details

Defined in Gini.Math.Amount.Internal

Methods

put :: Amount -> Put ()

get :: Get Amount

Prim Amount # 
Instance details

Defined in Gini.Math.Amount.Internal

Validity Amount # 
Instance details

Defined in Gini.Math.Amount.Internal

Methods

validate :: Amount -> Validation

PersistField Amount # 
Instance details

Defined in Gini.Math.Amount.Internal

Methods

toPersistValue :: Amount -> PersistValue

fromPersistValue :: PersistValue -> Either Text Amount

PersistFieldSql Amount # 
Instance details

Defined in Gini.Math.Amount.Internal

Methods

sqlType :: Proxy Amount -> SqlType

MonadThrow m => Fractional (m Amount) # 
Instance details

Defined in Gini.Math.Amount.Internal

Methods

(/) :: m Amount -> m Amount -> m Amount #

recip :: m Amount -> m Amount #

fromRational :: Rational -> m Amount #

MonadThrow m => Num (m Amount) # 
Instance details

Defined in Gini.Math.Amount.Internal

Methods

(+) :: m Amount -> m Amount -> m Amount #

(-) :: m Amount -> m Amount -> m Amount #

(*) :: m Amount -> m Amount -> m Amount #

negate :: m Amount -> m Amount #

abs :: m Amount -> m Amount #

signum :: m Amount -> m Amount #

fromInteger :: Integer -> m Amount #

type AmountScale = 30 #

amountScale :: Int #

Value level scaling.

plusAmounts :: MonadThrow m => Amount -> Amount -> m Amount #

Sum two amounts together while checking that the result is valid.

minusAmounts :: MonadThrow m => Amount -> Amount -> m Amount #

Sum two amounts while checking that the result is valid.

timesAmount :: MonadThrow m => Amount -> Integer -> m Amount #

Multiply an amount by an Integer.

>>> pia <- 3.141592653589793238462643 :: IO Amount
>>> pia `timesAmount` 10
31.415926535897932384626430
>>> pia `timesAmount` 100000
314159.265358979323846264300000
>>> pia `timesAmount` 10000000000
*** Exception: arithmetic overflow

quotRemAmount :: MonadThrow m => Amount -> Integer -> m (Amount, Amount) #

Divide the amount and keep the remainder.

>>> pia <- 3.141592653589793238462643 :: IO Amount
>>> pia `quotRemAmount` 1000000
(0.000003141592653589793238,0.000000000000000000462643)
>>> pia `quotRemAmount` (-7) :: Either SomeException (Amount, Amount)
Left arithmetic underflow
>>> pia `quotRemAmount` 0 :: Either SomeException (Amount, Amount)
Left divide by zero

zeroAmount :: Amount #

Just a convenience constructor for an amount with value 0

oneAmount :: Amount #

This is one: 1.0

Conversion

data FixedAmount #

Instances
HasResolution FixedAmount # 
Instance details

Defined in Gini.Math.Amount.Internal