Module

Data.Finance.Money

Package
purescript-money
Repository
TinkerTravel/purescript-money

#Discrete Source

newtype Discrete (c :: Currency)

An amount of money in the smallest discrete unit of a particular currency. For example, wrap 256 :: Discrete GBP would represent £2.56, whereas wrap 256 :: Discrete JPY would represent ¥256. If you want to work with higher granularity, you can define your own currency type.

Constructors

Instances

#formatDiscrete Source

formatDiscrete :: forall c. Currency c => Format -> Discrete c -> String

Apply a format to a discrete amount.

#showDiscrete Source

showDiscrete :: forall c. Currency c => Discrete c -> String

DEPRECATED: use formatDiscrete instead.

Show the discrete value with the correct number of decimals. Will not prepend the currency sign. Negative amounts are prefixed with a hyphen-minus.

Examples:

  • showDiscrete (Discrete 256 :: Discrete GBP) == "2.56"
  • showDiscrete (Discrete (-256) :: Discrete GBP) == "-2.56"

#Dense Source

newtype Dense (c :: Currency)

Amounts of money with exact arithmetic.

Constructors

Instances

#formatDense Source

formatDense :: forall c. Currency c => Rounding -> Format -> Dense c -> String

#Rounding Source

data Rounding

Rounding policy.

Constructors

Instances

#fromDiscrete Source

fromDiscrete :: forall c. Currency c => Discrete c -> Dense c

Convert a discrete amount to a dense amount.

#fromDense Source

fromDense :: forall c. Currency c => Rounding -> Dense c -> Discrete c

Convert a dense amount to a discrete amount, rounding accordingly.