pkg: add support for aeson 2.2, add upper bound
This commit is contained in:
parent
e3bf66755a
commit
1a0b745c28
@ -2,6 +2,7 @@
|
|||||||
JSON instances. Should they be in Types.hs ?
|
JSON instances. Should they be in Types.hs ?
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
{-# LANGUAGE FlexibleInstances #-}
|
{-# LANGUAGE FlexibleInstances #-}
|
||||||
{-# LANGUAGE LambdaCase #-}
|
{-# LANGUAGE LambdaCase #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
@ -67,7 +68,13 @@ instance (Integral a, ToJSON a) => ToJSON (DecimalRaw a) where
|
|||||||
toJSON = object . decimalKV
|
toJSON = object . decimalKV
|
||||||
toEncoding = pairs . mconcat . decimalKV
|
toEncoding = pairs . mconcat . decimalKV
|
||||||
|
|
||||||
decimalKV :: (KeyValue kv, Integral a, ToJSON a) => DecimalRaw a -> [kv]
|
decimalKV :: (
|
||||||
|
#if MIN_VERSION_aeson(2,2,0)
|
||||||
|
KeyValue e kv,
|
||||||
|
#else
|
||||||
|
KeyValue kv,
|
||||||
|
#endif
|
||||||
|
Integral a, ToJSON a) => DecimalRaw a -> [kv]
|
||||||
decimalKV d = let d' = if decimalPlaces d <= 10 then d else roundTo 10 d in
|
decimalKV d = let d' = if decimalPlaces d <= 10 then d else roundTo 10 d in
|
||||||
[ "decimalPlaces" .= decimalPlaces d'
|
[ "decimalPlaces" .= decimalPlaces d'
|
||||||
, "decimalMantissa" .= decimalMantissa d'
|
, "decimalMantissa" .= decimalMantissa d'
|
||||||
@ -102,7 +109,13 @@ instance ToJSON Posting where
|
|||||||
toJSON = object . postingKV
|
toJSON = object . postingKV
|
||||||
toEncoding = pairs . mconcat . postingKV
|
toEncoding = pairs . mconcat . postingKV
|
||||||
|
|
||||||
postingKV :: KeyValue kv => Posting -> [kv]
|
postingKV ::
|
||||||
|
#if MIN_VERSION_aeson(2,2,0)
|
||||||
|
KeyValue e kv
|
||||||
|
#else
|
||||||
|
KeyValue kv
|
||||||
|
#endif
|
||||||
|
=> Posting -> [kv]
|
||||||
postingKV Posting{..} =
|
postingKV Posting{..} =
|
||||||
[ "pdate" .= pdate
|
[ "pdate" .= pdate
|
||||||
, "pdate2" .= pdate2
|
, "pdate2" .= pdate2
|
||||||
@ -144,7 +157,13 @@ instance ToJSON Account where
|
|||||||
toJSON = object . accountKV
|
toJSON = object . accountKV
|
||||||
toEncoding = pairs . mconcat . accountKV
|
toEncoding = pairs . mconcat . accountKV
|
||||||
|
|
||||||
accountKV :: KeyValue kv => Account -> [kv]
|
accountKV ::
|
||||||
|
#if MIN_VERSION_aeson(2,2,0)
|
||||||
|
KeyValue e kv
|
||||||
|
#else
|
||||||
|
KeyValue kv
|
||||||
|
#endif
|
||||||
|
=> Account -> [kv]
|
||||||
accountKV a =
|
accountKV a =
|
||||||
[ "aname" .= aname a
|
[ "aname" .= aname a
|
||||||
, "aebalance" .= aebalance a
|
, "aebalance" .= aebalance a
|
||||||
|
|||||||
@ -34,7 +34,7 @@ extra-source-files:
|
|||||||
dependencies:
|
dependencies:
|
||||||
- base >=4.14 && <4.19
|
- base >=4.14 && <4.19
|
||||||
- base-compat
|
- base-compat
|
||||||
- aeson >=1
|
- aeson >=1 && <2.3
|
||||||
- aeson-pretty
|
- aeson-pretty
|
||||||
- ansi-terminal >=0.9
|
- ansi-terminal >=0.9
|
||||||
- array
|
- array
|
||||||
|
|||||||
@ -104,7 +104,7 @@ library:
|
|||||||
dependencies:
|
dependencies:
|
||||||
- hledger-lib >=1.30.99 && <1.31
|
- hledger-lib >=1.30.99 && <1.31
|
||||||
- hledger >=1.30.99 && <1.31
|
- hledger >=1.30.99 && <1.31
|
||||||
- aeson >=1
|
- aeson >=1 && <2.3
|
||||||
- base64
|
- base64
|
||||||
- blaze-html
|
- blaze-html
|
||||||
- blaze-markup
|
- blaze-markup
|
||||||
|
|||||||
@ -101,7 +101,7 @@ ghc-options:
|
|||||||
dependencies:
|
dependencies:
|
||||||
- base >=4.14 && <4.19
|
- base >=4.14 && <4.19
|
||||||
- hledger-lib >=1.30.99 && <1.31
|
- hledger-lib >=1.30.99 && <1.31
|
||||||
- aeson >=1
|
- aeson >=1 && <2.3
|
||||||
- ansi-terminal >=0.9
|
- ansi-terminal >=0.9
|
||||||
- bytestring
|
- bytestring
|
||||||
- cmdargs >=0.10
|
- cmdargs >=0.10
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user