haspara-0.0.0.10: A library providing definitions to work with monetary values.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Haspara.TH

Description

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

Synopsis

Documentation

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

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

>>> :set -XDataKinds
>>> :set -XOverloadedStrings
>>> :set -XTemplateHaskell
>>> $$(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 -> Code Q Currency Source #

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

>>> :set -XOverloadedStrings
>>> :set -XTemplateHaskell
>>> $$(currencyTH "USD")
USD
>>> $$(currencyTH "usd")
...
...Currency code error! Expecting at least 3 uppercase ASCII letters, but received: usd
...

currencyPairTH :: Text -> Text -> Code Q CurrencyPair Source #

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

>>> :set -XOverloadedStrings
>>> :set -XTemplateHaskell
>>> $$(currencyPairTH "EUR" "USD")
EUR/USD
>>> $$(currencyPairTH "USD" "USD")
USD/USD
>>> $$(currencyPairTH "USD" "eur")
...
... Currency code error! Expecting at least 3 uppercase ASCII letters, but received: eur
...