currency-codes: ISO-4217 Currency Codes

[ data, library, mit ] [ Propose Tags ]
This version is deprecated.

ISO-4217 Currency Codes


[Skip to Readme]

Modules

[Last Documentation]

  • Data
    • Data.Currency

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

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, base (>=4.7 && <5), bson, lens, random, safe, swagger2, text [details]
License MIT
Copyright (c) 2017 Chordify
Author Chordify
Maintainer Matthias Benkort <matthias@chordify.net>
Revised Revision 1 made by KtorZ at 2017-08-29T08:22:02Z
Category Data
Home page https://gitlab.com/chordify/currency-codes
Bug tracker https://gitlab.com/chordify/currency-codes/issues
Uploaded by KtorZ at 2017-08-28T14:44:04Z
Distributions NixOS:3.0.0.1
Reverse Dependencies 3 direct, 0 indirect [details]
Downloads 4643 total (29 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2017-08-28 [all 2 reports]

Readme for currency-codes-1.0.0.0

[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, ToSchema).

Example

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


myCurrencies :: [Currency]
myCurrencies =
  [Currency.eur, Currency.usdDollar]

fromAlpha :: Alpha -> [Currency] -> Maybe Currency
fromAlpha α =
  Safe.headMay . filter (== α)


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

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

Changelog

CHANGELOG.md

License

MIT © 2017 Chordify