Commit Graph

9776 Commits

Author SHA1 Message Date
Stephen Morgan
7488140608 lib: Do not call showAmount twice for every posting.
For print -f examples/10000x10000x10.journal, this results in
- A 7.7% reduction in heap allocations, from 7.6GB to 7.1GB.
2021-03-21 07:10:27 -07:00
Stephen Morgan
7aa3d3e760 lib,cli: Some efficiency improvements in register reports.
Strip prices after valuing postings in PostingsReport.
Use renderRow interface for Register report.

For reg -f examples/10000x10000x10.journal, this results in:
- Heap allocations decreasing by 55%, from 68.6GB to 31.2GB
- Resident memory decreasing by 75%, from 254GB to 65GB
- Total (profiled) time decreasing by 55%, from 37s to 20s
2021-03-21 07:10:27 -07:00
Stephen Morgan
d54e276658 lib: Split showMixedAmountB into showMixedAmountB and showAmountsB, the
former being a simple wrapper around the latter.

This removes the need for the showNormalised option, as showMixedAmountB
will always showNormalised and showAmountsB will never do so.

We also strip prices from MixedAmount before displaying if not displaying prices.
2021-03-21 07:10:27 -07:00
Simon Michael
16f8ed3d0f shake webmanuals: include the TOC comment 2021-03-19 08:21:28 -07:00
Simon Michael
7fad876014 ;update manuals 2021-03-18 07:22:42 -07:00
Simon Michael
0c56d3ffa3 shake mandates: update .date.m4 source files to current month/year 2021-03-18 07:21:51 -07:00
Simon Michael
941574423a ;shake: drop ".webmanuals" from website markdown filenames 2021-03-18 06:48:07 -07:00
Simon Michael
5ff6e0b618 ;make copy-bins-to-X: use period instead of hyphen 2021-03-17 18:15:09 -07:00
Simon Michael
cef9aede93 new API for MixedAmount arithmetic (#1491)
Previously we relied on MixedAmount being a Num, which allows +, -,
sum, negate, fromInteger etc. to be used with MixedAmounts. While
convenient, this Num instance is not (and can't be) fully implemented
or law abiding, so it's possible to misuse it, potentially leading to
bugs.

Now, MixedAmount is a lawful Monoid (and a Semigroup), so you can
combine (add) MixedAmounts with <> or mconcat and represent zero with
mempty.

However, we recommend using the following more abstract API, which
will insulate you from future implementation changes:

maPlus       (instead of +)
maMinus      (instead of -)
maNegate     (instead of negate)
maSum        (instead of sum/sumStrict)
nullmixedamt (instead of 0)

And when constructing MixedAmounts, avoid the Mixed constructor,
instead use:

mixed        :: [Amount] -> MixedAmount
mixedAmount  :: Amount -> MixedAmount
maAddAmount  :: MixedAmount -> Amount -> MixedAmount
maAddAmounts :: MixedAmount -> [Amount] -> MixedAmount

For now the Num instance remains, as a convenience for scripters and
for backward compatibility, but for production code you should
probably consider it deprecated.
2021-03-17 17:36:23 -07:00
Stephen Morgan
d6a4310d8f lib,cli,ui,bin: Eliminate all uses of Mixed outside of Hledger.Data.Amount.
Exceptions are for dealing with the pamount field, which is really just
dealing with an unnormalised list of amounts.

This creates an API for dealing with MixedAmount, so we never have to
access the internals outside of Hledger.Data.Amount.

Also remove a comment, since it looks like #1207 has been resolved.
2021-03-18 09:47:59 +11:00
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
Simon Michael
4b2c943867 ;bin: hledger-combine-balances: fix haddock error 2021-03-16 07:20:01 -07:00
Simon Michael
cca765de72 install: hledger-iadd 1.3.14 2021-03-14 10:16:09 -07:00
Simon Michael
f54f2b3b72 ;doc: also update manual source files (#1504) 2021-03-13 07:28:14 -08:00
Felix Yan
a2266e35d9
Remove more reference to old man page stuff
They are not cleaned up in 9824c9683a
2021-03-13 18:03:11 +08:00
Simon Michael
f0e73909fa ;cabal: fix cabal.project error with cabal 3.4 2021-03-12 07:01:48 -08:00
Simon Michael
c83970422c cli: fix a build failure with ghc 9.0 (#1503)
Also remove the obsolete shebang line.
2021-03-12 06:59:43 -08:00
Simon Michael
ae57e76cb3 ;update cabal files 2021-03-12 06:59:30 -08:00
Simon Michael
36cbc2b068 bump base upper bound to allow GHC 9.0 2021-03-12 06:58:46 -08:00
Simon Michael
8f5fcac834 install: hledger-interest 1.6.1 2021-03-12 06:14:59 -08:00
Simon Michael
48f2dc8be7 ;announce: tweak 2021-03-10 15:12:47 -08:00
Simon Michael
422fd57bd2 install: hledger-iadd 1.3.13 2021-03-10 15:03:04 -08:00
Simon Michael
5573538fdc ;update cabal files 2021-03-10 13:50:50 -08:00
Simon Michael
e050790d4c ;bump version to 1.21.99 2021-03-10 13:50:49 -08:00
Simon Michael
e0d525c6fa ;make tag: simplify 2021-03-10 11:55:20 -08:00
Simon Michael
7690b85e51 ;announce: 1.21 2021-03-10 11:52:31 -08:00
Simon Michael
5cdbd04974 ;finalise manuals 2021-03-10 11:12:06 -08:00
Simon Michael
532a4622ac ;finalise changelogs 2021-03-10 11:10:13 -08:00
Simon Michael
240d14672c install: bump to 1.21 2021-03-10 08:27:23 -08:00
Simon Michael
00beaf1423 ;update cabal files 2021-03-10 08:24:59 -08:00
Simon Michael
eeddfc2509 ;bump version to 1.21 2021-03-10 08:24:58 -08:00
Simon Michael
f82bdb15e4 ;update changelogs 2021-03-10 08:24:12 -08:00
Simon Michael
40d1d7f7a7 ;update manuals 2021-03-10 08:22:39 -08:00
Simon Michael
be50572d97 shake: bump to lts-17.4, like the rest 2021-03-10 08:19:10 -08:00
Stephen Morgan
fb02d86884 lib: Do not do any valuation with --value=cost, perform AtEnd valuation with --value=cost,COMM. 2021-03-10 12:42:01 +11:00
Stephen Morgan
1702b8cca4 Revert "fix valuation tests after #1499"
This reverts commit 696114cfa8.
2021-03-10 12:29:06 +11:00
Simon Michael
696114cfa8 fix valuation tests after #1499 2021-03-09 10:17:26 -08:00
Simon Michael
ae435fd33e ;doc: changelog tweaks 2021-03-09 10:16:02 -08:00
Simon Michael
269b25bc8d doc: edited changelogs 2021-03-09 09:31:28 -08:00
Simon Michael
51d582e845 also keep supporting --value=cost,COMM for now (#1499) 2021-03-09 07:37:52 -08:00
Simon Michael
4ae401cbec ;bal: cli help tweaks 2021-03-09 07:29:40 -08:00
Simon Michael
346429d070 ;bal: doc tweaks 2021-03-09 07:29:12 -08:00
Simon Michael
faf68f3def ;doc: bump changelogs to latest revision 2021-03-08 15:16:54 -08:00
Simon Michael
ec4d131d22 ;doc: cherry pick recent edited changelogs from 1.21-branch 2021-03-08 15:15:57 -08:00
Simon Michael
325aa15f74 ;doc: restore changelogs up to a5f9f8ce0 2021-03-08 15:14:47 -08:00
Simon Michael
54b95af9ff ;doc: merge 1.20.3, 1.20.4 changelogs from 1.20-branch 2021-03-08 15:12:39 -08:00
Simon Michael
72a9b612c1 ;cli: fix "hledger CMD --info" with older info
This should open the info node for CMD, but was giving an
error with info 4.8 on macs. Now it's more robust.
2021-03-07 17:40:50 -08:00
Simon Michael
36aa01f67a ;update manuals 2021-03-07 10:25:13 -08:00
Simon Michael
5dc644d280 ;update CLI usage texts 2021-03-07 10:25:08 -08:00
Simon Michael
fce0a690dd ;doc: contributing: draftprs.hledger.org, readyprs.hledger.org 2021-03-07 10:02:24 -08:00