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

Haspara.Currency

Description

This module provides base data definitions and functions for Haspara library.

Synopsis

Currency

Data Definition

data Currency Source #

Type encoding for currencies.

Instances

Instances details
Eq Currency Source # 
Instance details

Defined in Haspara.Internal.Currency

Ord Currency Source # 
Instance details

Defined in Haspara.Internal.Currency

Show Currency Source #

Show instance for Currency.

>>> MkCurrency "USD"
USD
Instance details

Defined in Haspara.Internal.Currency

IsString Currency Source #

IsString instance for Currency.

>>> "USD" :: Currency
USD
Instance details

Defined in Haspara.Internal.Currency

Hashable Currency Source # 
Instance details

Defined in Haspara.Internal.Currency

Methods

hashWithSalt :: Int -> Currency -> Int #

hash :: Currency -> Int #

ToJSON Currency Source #

ToJSON instance for Currency.

>>> Aeson.encode (MkCurrency "USD")
"\"USD\""
Instance details

Defined in Haspara.Internal.Currency

FromJSON Currency Source #

FromJSON instance for Currency.

>>> Aeson.eitherDecode "\"\"" :: Either String Currency
Left "Error in $: Currency code error! Expecting at least 3 uppercase characters, but received: \"\""
>>> Aeson.eitherDecode "\"ABC\"" :: Either String Currency
Right ABC
Instance details

Defined in Haspara.Internal.Currency

Lift Currency Source # 
Instance details

Defined in Haspara.Internal.Currency

Constructors

currency :: MonadError String m => Text -> m Currency Source #

Smart constructor for Currency values within MonadError context.

>>> currency "" :: Either String Currency
Left "Currency code error! Expecting at least 3 uppercase characters, but received: \"\""
>>> currency " " :: Either String Currency
Left "Currency code error! Expecting at least 3 uppercase characters, but received: \" \""
>>> currency "AB" :: Either String Currency
Left "Currency code error! Expecting at least 3 uppercase characters, but received: \"AB\""
>>> currency " ABC " :: Either String Currency
Left "Currency code error! Expecting at least 3 uppercase characters, but received: \" ABC \""
>>> currency "ABC" :: Either String Currency
Right ABC

currencyFail :: MonadFail m => Text -> m Currency Source #

Smart constructor for Currency values within MonadFail context.

>>> currencyFail "" :: Maybe Currency
Nothing
>>> currencyFail "US" :: Maybe Currency
Nothing
>>> currencyFail "usd" :: Maybe Currency
Nothing
>>> currencyFail "USD" :: Maybe Currency
Just USD

Currency Pair

Data Definition

Constructors