From 16157bc7119a4a669396cfd935d4d9e67eae2f35 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 1 Mar 2019 15:07:17 -0800 Subject: [PATCH] lib, web: tweaks to keep building with GHC 7 --- hledger-lib/Hledger/Data/Journal.hs | 3 ++- hledger-web/Hledger/Web/Json.hs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hledger-lib/Hledger/Data/Journal.hs b/hledger-lib/Hledger/Data/Journal.hs index 4a0b9cdfc..5e4fa9f04 100644 --- a/hledger-lib/Hledger/Data/Journal.hs +++ b/hledger-lib/Hledger/Data/Journal.hs @@ -732,7 +732,6 @@ addOrAssignAmountAndCheckAssertionB p@Posting{paccount=acc, pamount=amt, pbalanc newbal <- addAmountB acc amt whenM (R.reader bsAssrt) $ checkBalanceAssertionB p newbal return p - | Nothing <- mba = return p | Just BalanceAssertion{baamount,batotal} <- mba = do (diff,newbal) <- case batotal of True -> do @@ -750,6 +749,8 @@ addOrAssignAmountAndCheckAssertionB p@Posting{paccount=acc, pamount=amt, pbalanc let p' = p{pamount=diff, poriginal=Just $ originalPosting p} whenM (R.reader bsAssrt) $ checkBalanceAssertionB p' newbal return p' + -- no amount, no balance assertion (GHC 7 doesn't like Nothing <- mba here) + | otherwise = return p -- | Add the posting's amount to its account's running balance, and -- optionally check the posting's balance assertion if any. diff --git a/hledger-web/Hledger/Web/Json.hs b/hledger-web/Hledger/Web/Json.hs index c71726652..97d7250fb 100644 --- a/hledger-web/Hledger/Web/Json.hs +++ b/hledger-web/Hledger/Web/Json.hs @@ -120,7 +120,7 @@ instance FromJSON Account -- https://github.com/PaulJohnson/Haskell-Decimal/issues/6 --deriving instance Generic Decimal --instance FromJSON Decimal -deriving instance Generic (DecimalRaw Integer) +deriving instance Generic (DecimalRaw a) instance FromJSON (DecimalRaw Integer) -- -- @simonmichael, I think the code in your first comment should work if it compiles—though “work” doesn’t mean you can parse a JSON number directly into a `Decimal` using the generic instance, as you’ve discovered.