Commit Graph

30 Commits

Author SHA1 Message Date
Simon Michael
c80c72d7cd dev: lib, cli, bin: enable/fix name shadowing warnings
And a few other cleanups.
2022-08-23 12:16:15 +01:00
Stephen Morgan
8fcdc22a45 fix: bin: Get scripts compiling with current hledger-lib. 2021-09-08 13:19:31 -10:00
Stephen Morgan
e13239386f cln: hlint: Clean up == and elem related hlint warnings. 2021-08-27 06:13:56 -10:00
Stephen Morgan
7edcbe4be8 cln: hlint: Remove rendundant guard warnings. 2021-08-26 07:23:11 -10:00
Stephen Morgan
5e7b69356f lib: Change internal representation of MixedAmount to use a strict Map
instead of a list of Amounts. No longer export Mixed constructor, to
keep API clean (if you really need it, you can import it directly from
Hledger.Data.Types). We also ensure the JSON representation of
MixedAmount doesn't change: it is stored as a normalised list of
Amounts.

This commit improves performance. Here are some indicative results.

hledger reg -f examples/10000x1000x10.journal
- Maximum residency decreases from 65MB to 60MB (8% decrease)
- Total memory in use decreases from 178MiB to 157MiB (12% decrease)

hledger reg -f examples/10000x10000x10.journal
- Maximum residency decreases from 69MB to 60MB (13% decrease)
- Total memory in use decreases from 198MiB to 153MiB (23% decrease)

hledger bal -f examples/10000x1000x10.journal
- Total heap usage decreases from 6.4GB to 6.0GB (6% decrease)
- Total memory in use decreases from 178MiB to 153MiB (14% decrease)

hledger bal -f examples/10000x10000x10.journal
- Total heap usage decreases from 7.3GB to 6.9GB (5% decrease)
- Total memory in use decreases from 196MiB to 185MiB (5% decrease)

hledger bal -M -f examples/10000x1000x10.journal
- Total heap usage decreases from 16.8GB to 10.6GB (47% decrease)
- Total time decreases from 14.3s to 12.0s (16% decrease)

hledger bal -M -f examples/10000x10000x10.journal
- Total heap usage decreases from 108GB to 48GB (56% decrease)
- Total time decreases from 62s to 41s (33% decrease)

If you never directly use the constructor Mixed or pattern match against
it then you don't need to make any changes. If you do, then do the
following:

- If you really care about the individual Amounts and never normalise
  your MixedAmount (for example, just storing `Mixed amts` and then
  extracting `amts` as a pattern match, then use should switch to using
  [Amount]. This should just involve removing the `Mixed` constructor.
- If you ever call `mixed`, `normaliseMixedAmount`, or do any sort of
  amount arithmetic (+), (-), then you should replace the constructor
  `Mixed` with the function `mixed`. To extract the list of Amounts, use
  the function `amounts`.
- If you ever call `normaliseMixedAmountSquashPricesForDisplay`, you can
  replace that with `mixedAmountStripPrices`. (N.B. this does something
  slightly different from `normaliseMixedAmountSquashPricesForDisplay`,
  but I don't think there's any use case for squashing prices and then
  keeping the first of the squashed prices around. If you disagree let
  me know.)
- Any remaining calls to `normaliseMixedAmount` can be removed, as that
  is now the identity function.
2021-05-01 09:45:29 -10:00
Simon Michael
c8bc9c7088 bin: more robust --package syntax, comma form sometimes fails 2021-02-12 13:55:31 -08:00
Simon Michael
37290eec04 ;bin: smooth: note beancount tool 2021-01-30 17:27:46 -08:00
Simon Michael
fef0e3a3bf ;bin: ensure required packages (string-qq) are visible (#1453) 2021-01-12 12:24:08 -08:00
Simon Michael
3fc3914e14 ;bin: doc 2021-01-12 11:07:29 -08:00
Simon Michael
32ccbba805 bin: switch to "runghc", drop "env -S" (#1453)
env -S isn't a thing on linux of course. Go back to using standard
env, which means using a stack options line, which means not using
"ghc". This new setup is probably simpler anyway. I've just had to
give up on the goal of having each script's required packages being
defined in one place; now (to they extent they are required) they
must be defined both in the script header and in compile.sh.
2021-01-12 10:55:00 -08:00
Simon Michael
2db87333d7 bin: switch scripts to "stack ghc" and "env -S" (#1453)
Using stack's script command meant that the scripts needed to be
compatible, and regularly tested, with a hledger release in stackage,
rather than the latest hledger source. This created hassles for
maintainers, contributors and sometimes for users.

To simplify things overall, we now require script users to check out
the hledger source tree and run the scripts (or, bin/compile.sh) from
there once so they compile themselves. Some notes on alternative
setups are included (in one of the scripts, and referenced by the
others). This ensures that users and our CI tests are building scripts
the same way.

Current stack does not allow a stack options line to be used with the
"stack ghc" command, unfortunately, so instead we are using env's -S
flag, which hopefully has sufficiently wide support by now, and
putting all arguments in the shebang line.

This method will probably require complete explicit --package options,
unlike "stack script", so more testing and tweaking is expected.
Probably we're going to end up with some long shebang lines.

This isn't pretty but seems like a possible way to keep things
manageable.
2021-01-11 21:04:07 -08:00
Stephen Morgan
ef250e5673 bin: Update bin scripts for new API. 2021-01-02 15:08:09 +11:00
Stephen Morgan
a64d1aa6d0 bin: Update bin scripts for current hledger-lib.
(cherry picked from commit bc4aef17b7fa13ec0754b93325e1c5e5ee04f1e7)
2020-12-30 08:59:03 -08:00
Simon Michael
d17d92b338 ;stack, bin: bump all to lts-16.25 2020-12-08 12:59:25 -08:00
Stephen Morgan
19ab222599 lib,cli: Remove old impure ReportOpts date functions. 2020-10-23 14:14:11 -07:00
Simon Michael
c2929939e4 make account type autodetection (& hledger-smooth) case insensitive again (#1341)
lib: added case-insensitive variants of the accountNameToRegex functions.
2020-09-03 09:52:00 -07:00
Stephen Morgan
ba59fed6b2 lib: Replace more instances of fromIntegral with safer versions. 2020-08-30 22:20:58 +10:00
Simon Michael
5405a63aad ;bin: print-location, smooth, swap-dates: update _FLAG marker 2020-08-15 11:29:35 -07:00
Simon Michael
99789bd4de bin: drop explicit --package options from stack scripts, not needed
If there are no --package options, stack's script command infers them
from the imports.
2020-08-15 09:59:59 -07:00
Simon Michael
4747e2eacf ;bin: consistent use of stack script, package updates 2020-08-15 09:51:59 -07:00
Simon Michael
76776e28b2 ;bin: smooth: link to #1171
[ci skip]
2020-01-23 12:53:43 -08:00
Simon Michael
21fec478d4 ;bin: smooth: note/warn about date-order requirement (#1171)
[ci skip]
2020-01-23 12:40:25 -08:00
Simon Michael
4589ec51ba ;bin: smooth: fix Text "Empty stream" error (#1171)
[ci skip]
2020-01-23 12:22:24 -08:00
Simon Michael
82421d0eab ;bin: smooth: doesn't use hledger-lib
[ci skip]
2020-01-23 12:04:36 -08:00
Simon Michael
db74540280 ;bin: smooth: here -> string-qq, save several minutes of build time
[ci skip]
2020-01-23 12:04:28 -08:00
Simon Michael
8efae769c0 bin: smooth: update for current lib (RawOpts)
[ci skip]
2020-01-23 10:28:57 -08:00
Simon Michael
45bb513eb8 bin: smooth, swap-dates: fix compile.sh warnings (#1072)
[ci skip]
2019-07-17 00:01:06 +01:00
Simon Michael
cb5334c8df bin: hledger-smooth: update for latest hledger-lib (#1072)
[ci skip]
2019-07-16 23:36:37 +01:00
Caleb Maclennan
11d9e5eb6a code: Strip extraneous trailing whitespace from Haskell sources 2019-07-15 16:40:49 +01:00
Simon Michael
aebd6c50d6 smooth: smoothes out irregular transactions (experimental addon) 2018-07-16 23:36:06 +01:00