currency-codes: ISO-4217 Currency Codes

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]


ISO-4217 Currency Codes

[Skip to Readme]


Change log
Dependencies aeson, base (>=4.7 && <5), bson, lens, random, safe, swagger2, text [details]
License MIT
Copyright (c) 2017 Chordify
Author Chordify
Maintainer Matthias Benkort <>
Category Data
Home page
Bug tracker
Uploaded by KtorZ at 2017-08-28T14:43:34Z



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

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

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



MIT © 2017 Chordify