packages feed

safe-money-aeson 0.1 → 0.1.1

raw patch · 4 files changed

+19/−13 lines, 4 filesdep ~safe-moneyPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: safe-money

API changes (from Hackage documentation)

Files

changelog.md view
@@ -1,4 +1,9 @@+# Version 0.1.1++* Require `safe-money>=0.8`.++ # Version 0.1 -* This first release of @safe-money-aeson@ includes the same @aeson@ support-  and tests that were present in @safe-money-0.6@.+* This first release of `safe-money-aeson` includes the same @aeson@ support+  and tests that were present in `safe-money-0.6`.
safe-money-aeson.cabal view
@@ -1,5 +1,5 @@ name: safe-money-aeson-version: 0.1+version: 0.1.1 license: BSD3 license-file: LICENSE copyright: Copyright (c) Renzo Carbonara 2016-2018@@ -34,7 +34,7 @@   build-depends:     aeson,     base >=4.8 && <5.0,-    safe-money >=0.7,+    safe-money >=0.8,     text   exposed-modules:     Money.Aeson
src/Money/Aeson.hs view
@@ -96,9 +96,9 @@ -- string was dropped from the rendered 'Ae.Array'). instance Ae.ToJSON Money.SomeDiscrete where   toJSON = \sd ->-    let r = Money.someDiscreteScale sd+    let rs = Money.scaleToRational (Money.someDiscreteScale sd)     in Ae.toJSON (MoneyI.someDiscreteCurrency' sd,-                  numerator r, denominator r,+                  numerator rs, denominator rs,                   Money.someDiscreteAmount sd)  -- | Compatible with 'Money.Discrete''@@ -112,7 +112,9 @@        ("Discrete" :: T.Text, c, n, d, a) <- Ae.parseJSON v        pure (c, n, d, a)     when (d == 0) (fail "denominator is zero")-    maybe empty pure (MoneyI.mkSomeDiscrete' c (n % d) a)+    maybe empty pure (MoneyI.mkSomeDiscrete' c+                        <$> Money.scaleFromRational (n % d)+                        <*> pure a)  -- | Compatible with 'Money.SomeExchangeRate' --
test/Main.hs view
@@ -58,10 +58,8 @@ 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")@@ -123,7 +121,7 @@  testDiscrete   :: forall (currency :: Symbol) (unit :: Symbol)-  .  ( Money.GoodScale (Money.Scale currency unit)+  .  ( Money.GoodScale (Money.UnitScale currency unit)      , KnownSymbol currency      , KnownSymbol unit )   => Proxy currency@@ -149,9 +147,10 @@       QC.forAll QC.arbitrary $ \(x :: Money.Discrete currency unit) ->         let sx = Money.toSomeDiscrete x             c = T.unpack (Money.someDiscreteCurrency sx)-            r = Money.someDiscreteScale sx+            rs = Money.scaleToRational (Money.someDiscreteScale sx)             a = Money.someDiscreteAmount sx-            bs = Ae.encode ("Discrete" :: String, c, numerator r, denominator r, a)+            bs = Ae.encode ("Discrete" :: String, c, numerator rs,+                            denominator rs, a)         in (Just  x === Ae.decode bs) .&&.            (Just sx === Ae.decode bs)   ]