summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRenzoCarbonara <>2019-03-21 16:06:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2019-03-21 16:06:00 (GMT)
commit806cbae03d68dc1fc9bb73176bdaa6385ab94987 (patch)
tree1cf765d5e55501abb0711a11d4d93c916c5404cd
parent6fe7432c72df2caf1e8e42e4cc80c4ee1fee12e3 (diff)
version 0.1.10.1.1
-rw-r--r--changelog.md9
-rw-r--r--safe-money-xmlbf.cabal4
-rw-r--r--src/Money/Xmlbf.hs5
-rw-r--r--test/Main.hs6
4 files changed, 14 insertions, 10 deletions
diff --git a/changelog.md b/changelog.md
index 89eab70..2aafa7d 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,4 +1,9 @@
+# Version 0.1.1
+
+* Require `safe-money>=0.8`.
+
+
# Version 0.1
-* This first release of @safe-money-xmlbf@ includes the same @xmlbf@
- support and tests that were present in @safe-money-0.6@.
+* This first release of `safe-money-xmlbf` includes the same `xmlbf`
+ support and tests that were present in `safe-money-0.6`.
diff --git a/safe-money-xmlbf.cabal b/safe-money-xmlbf.cabal
index 811b026..8038aad 100644
--- a/safe-money-xmlbf.cabal
+++ b/safe-money-xmlbf.cabal
@@ -1,5 +1,5 @@
name: safe-money-xmlbf
-version: 0.1
+version: 0.1.1
license: BSD3
license-file: LICENSE
copyright: Copyright (c) Renzo Carbonara 2016-2018
@@ -32,7 +32,7 @@ library
ghc-options: -Wall -O2
build-depends:
base (>=4.8 && <5.0),
- safe-money,
+ safe-money >=0.8,
text,
xmlbf
exposed-modules:
diff --git a/src/Money/Xmlbf.hs b/src/Money/Xmlbf.hs
index a710e46..e362d9f 100644
--- a/src/Money/Xmlbf.hs
+++ b/src/Money/Xmlbf.hs
@@ -78,7 +78,7 @@ instance
-- | Compatible with 'Money.Discrete''
instance Xmlbf.ToXml Money.SomeDiscrete where
toXml = \sd ->
- let r = Money.someDiscreteScale sd
+ let r = Money.scaleToRational (Money.someDiscreteScale sd)
as = [ ("c", Money.someDiscreteCurrency sd)
, ("n", T.pack (show (numerator r)))
, ("d", T.pack (show (denominator r)))
@@ -93,7 +93,8 @@ instance Xmlbf.FromXml Money.SomeDiscrete where
d <- Xmlbf.pRead =<< Xmlbf.pAttr "d"
when (d == 0) (fail "denominator is zero")
a <- Xmlbf.pRead =<< Xmlbf.pAttr "a"
- maybe empty pure (Money.mkSomeDiscrete c (n % d) a)
+ maybe empty pure (Money.mkSomeDiscrete c <$> Money.scaleFromRational (n % d)
+ <*> pure a)
-- | Compatible with 'Money..SomeExchangeRate'
--
diff --git a/test/Main.hs b/test/Main.hs
index 9a38c7c..68db52f 100644
--- a/test/Main.hs
+++ b/test/Main.hs
@@ -58,10 +58,8 @@ testCurrencies =
testCurrencyUnits :: Tasty.TestTree
testCurrencyUnits =
Tasty.testGroup "Currency units"
- [ testDiscrete (Proxy :: Proxy "BTC") (Proxy :: Proxy "BTC")
- , testDiscrete (Proxy :: Proxy "BTC") (Proxy :: Proxy "satoshi")
+ [ testDiscrete (Proxy :: Proxy "BTC") (Proxy :: Proxy "satoshi")
, testDiscrete (Proxy :: Proxy "BTC") (Proxy :: Proxy "bitcoin")
- , testDiscrete (Proxy :: Proxy "USD") (Proxy :: Proxy "USD")
, testDiscrete (Proxy :: Proxy "USD") (Proxy :: Proxy "cent")
, testDiscrete (Proxy :: Proxy "USD") (Proxy :: Proxy "dollar")
, testDiscrete (Proxy :: Proxy "VUV") (Proxy :: Proxy "vatu")
@@ -115,7 +113,7 @@ testExchange =
testDiscrete
:: forall (currency :: Symbol) (unit :: Symbol)
- . ( Money.GoodScale (Money.Scale currency unit)
+ . ( Money.GoodScale (Money.UnitScale currency unit)
, KnownSymbol currency
, KnownSymbol unit )
=> Proxy currency