ISO-4217 Currency Codes

Latest on Hackage:

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow to host generated Haddocks.

MIT licensed by Chordify
Maintained by Matthias Benkort

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, Data, Typeable, Generic, NFData).


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


MIT © 2017-2018 Chordify



v3.0.0.0 (2018-03-13)

  • Review Currency strictness
  • Add deepseq’s NFData instance for Currency & Alpha
  • Manually write Show & Read instance for Alpha (compile-time & performance gain)
  • Remove currency constructors in favor of helper fromAlpha
  • Add property tests to verify various instances

v2.0.0.0 (2017-09-11)

  • Remove Swagger instances. It would be better to push them upstream to the swagger2 repository.

v1.0.0.0 (2017-08-29)

  • Provide 2 types Currency and Alpha
  • Provide constructors for each currency and Alpha code listed in the standard
  • Provide a list of all Currency
  • Provide instances for:
    • Show
    • Eq
    • Read
    • Generic
    • Data
    • Typeable
    • FromJSON (aeson)
    • ToJSON (aeson)
    • ToSchema (swagger2)
    • Val (bson)
    • Random (random)
    • Ord (Alpha only)
    • Enum (Alpha only
    • Bounded (Alpha only)
Depends on 7 packages:
Used by 1 package:
comments powered byDisqus