The currency-codes package

[ Tags: data, library, mit ] [ Propose Tags ]

ISO-4217 Currency Codes

[Skip to Readme]


Versions,,,,, (info)
Change log
Dependencies aeson (>=, base (==4.*), bson (>=0.2.0), deepseq, random (>=, safe (>=0.2), text (>= [details]
License MIT
Copyright (c) 2017 Chordify
Author Chordify
Maintainer Matthias Benkort <>
Category Data
Home page
Bug tracker
Uploaded Tue Mar 13 17:27:56 UTC 2018 by KtorZ
Distributions NixOS:
Downloads 1226 total (37 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
Last success reported on 2018-03-13 [all 3 reports]
Hackage Matrix CI


  • Data
    • Data.Currency


Maintainer's Corner

For package maintainers and hackage trustees

Readme for currency-codes-

[back to package description]

Currency Codes (ISO-4217)


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).


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 ((==) α . Currency.alpha)

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

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


MIT © 2017 Chordify