currencies-0.1.1.0: Currencies representation, pretty printing and conversion

Safe HaskellSafe
LanguageHaskell2010

Data.Currency.Pretty

Contents

Description

Pretty print monetary amounts like:

  • $ 34.50
  • USD 3,456.29
  • € 32 433 938.23

Using default printing settings

>>> prettyPrint (Amount USD 2342.2)
"USD 2,342.20"
>>> prettyPrint (Amount EUR 45827.346)
"EUR 45,827.35"

Using custom printing settings

>>> prettyPrintWith (defaultConfig { useCurrencySymbol = True }) (Amount USD 2342.2)
"$ 2,342.20"
>>> prettyPrintWith (defaultConfig { useCurrencySymbol = True }) (Amount EUR 2342.2)
"€ 2,342.20"
>>> prettyPrintWith (defaultConfig { showDecimals = False }) (Amount USD 25.50)
"USD 25"

For more printing settings see PrettyConfig

Synopsis

Pretty printing

prettyPrint :: Currency c => Amount c -> String Source #

Pretty print a monetary amount using defaultConfig

prettyPrintWith :: Currency c => PrettyConfig -> Amount c -> String Source #

Pretty print a monetary amount with a custom PrettyConfig configuration

Configuration

data PrettyConfig Source #

Constructors

PrettyConfig 

Fields

defaultConfig :: PrettyConfig Source #

Default PrettyConfig used in prettyPrint

  • Show decimals
  • Compact four digit amounts
  • Use ISO code
  • Separate large amounts with comma
  • Separate decimals with dot