hledger/hledger-lib/Hledger
Stephen Morgan dabb3ef82e lib,cli,ui,bin: Create a new API for MixedAmount arithmetic. This should
supplant the old interface, which relied on the Num typeclass.

MixedAmount did not have a very good Num instance. The only functions
which were defined were fromInteger, (+), and negate. Furthermore, it
was not law-abiding, as 0 + a /= a in general. Replacements for used
functions are:
0 -> nullmixedamt / mempty
(+) -> maPlus / (<>)
(-) -> maMinus
negate -> maNegate
sum -> maSum
sumStrict -> maSum

Also creates some new constructors for MixedAmount:
mixedAmount :: Amount -> MixedAmount
maAddAmount :: MixedAmount -> Amount -> MixedAmount
maAddAmounts :: MixedAmount -> [Amount] -> MixedAmount

Add Semigroup and Monoid instances for MixedAmount.
Ideally we would remove the Num instance entirely.

The only change needed have nullmixedamt/mempty substitute for
0 without problems was to not squash prices in
mixedAmount(Looks|Is)Zero. This is correct behaviour in any case.
2021-03-18 09:47:21 +11:00
..
Data lib,cli,ui,bin: Create a new API for MixedAmount arithmetic. This should 2021-03-18 09:47:21 +11:00
Read lib,cli,ui,bin: Create a new API for MixedAmount arithmetic. This should 2021-03-18 09:47:21 +11:00
Reports lib,cli,ui,bin: Create a new API for MixedAmount arithmetic. This should 2021-03-18 09:47:21 +11:00
Utils lib: Expose textConcatBottomPadded. 2021-01-15 12:56:48 -08:00
Data.hs move JSON instances from hledger-web to hledger-lib 2019-12-16 17:17:00 -08:00
Query.hs lib: matchesDescription, matchesPayeeWIP 2021-01-17 16:37:38 -08:00
Read.hs lib,cli: Assorted fixes for older GHC. 2021-01-02 15:08:09 +11:00
Reports.hs lib,cli: Store parsed Query in ReportOpts, rather than an unparsed 2020-10-23 14:14:11 -07:00
Utils.hs lib,cli,ui,bin: Create a new API for MixedAmount arithmetic. This should 2021-03-18 09:47:21 +11:00