currency-codes: ISO-4217 Currency Codes

[ data, library, mit ] [ Propose Tags ] [ Report a vulnerability ]

ISO-4217 Currency Codes


[Skip to Readme]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 1.0.0.0, 1.0.0.1, 1.0.0.2, 1.0.0.3, 2.0.0.0, 3.0.0.0, 3.0.0.1 (info)
Change log CHANGELOG.md
Dependencies aeson (>=0.7.0.0), base (>=4 && <5), bson (>=0.2.0), deepseq, random (>=1.0.0.0), safe (>=0.2), text (>=1.0.0.0) [details]
License MIT
Copyright (c) 2017-2018 Chordify
Author Chordify
Maintainer Matthias Benkort <matthias.benkort@gmail.com>
Category Data
Home page https://github.com/chordify/currency-codes
Bug tracker https://github.com/chordify/currency-codes/issues
Uploaded by KtorZ at 2018-03-19T17:22:58Z
Distributions NixOS:3.0.0.1
Reverse Dependencies 3 direct, 0 indirect [details]
Downloads 4831 total (26 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-03-19 [all 1 reports]

Readme for currency-codes-3.0.0.1

[back to package description]

Currency Codes (ISO-4217)

Overview

This package mainly provides 2 data types to represent and manipulate currencies according to the ISO 4217 standard.

It also provides a handful of instances for common typeclasses (Show, Read, Random, ToJSON, FromJSON, Val, Data, Typeable, Generic, NFData).

Example

import           Data.Aeson     (ToJSON(..))
import           Data.Currency  (Currency, Alpha(..))
import           GHC.Generics   (Generic)
import qualified Safe
import qualified Data.Aeson     as Aeson
import qualified Data.Currency  as Currency


myCurrencies :: [Currency]
myCurrencies =
  [ Currency.fromAlpha EUR
  , Currency.fromAlpha USD
  ]

data Transaction = Transaction
  { amount   :: Integer
  , currency :: Currency
  } deriving (Eq, Show, Generic)

instance ToJSON Transaction where
  toJSON = 
    Aeson.genericToJSON Aeson.defaultOptions

License

MIT © 2017-2018 Chordify