haspara-0.0.0.0: A library providing definitions to work with monetary values.
Safe HaskellNone
LanguageHaskell2010

Haspara.TH

Description

This module provides template-haskell functions for various Base definitions.

Synopsis

Documentation

quantityTH :: KnownNat s => Scientific -> Q (TExp (Quantity s)) Source #

Constructs a Quantity value at compile-time using -XTemplateHaskell.

>>> :set -XDataKinds
>>> $$(quantityTH 0.00) :: Quantity 2
0.00
>>> $$(quantityTH 0.09) :: Quantity 2
0.09
>>> $$(quantityTH 0.009) :: Quantity 2
...
..."Underflow while trying to create quantity: 9.0e-3"
...
>>> $$(quantityTH 0.009) :: Quantity 3
0.009

currencyTH :: Text -> Q (TExp Currency) Source #

Constructs a Currency value at compile-time using -XTemplateHaskell.

>>> $$(currencyTH "USD")
USD
>>> $$(currencyTH "usd")
...
...Currency code error! Expecting at least 3 uppercase characters, but received: "usd"
...

currencyPairTH :: Text -> Text -> Q (TExp CurrencyPair) Source #

Constructs a CurrencyPair value at compile-time using -XTemplateHaskell.

>>> $$(currencyPairTH "EUR" "USD")
EUR/USD
>>> $$(currencyPairTH "USD" "USD")
...
...Can not create currency pair from same currencies: USD and USD
...
>>> $$(currencyPairTH "USD" "eur")
...
...Currency code error! Expecting at least 3 uppercase characters, but received: "eur"
...