Commit Graph

182 Commits

Author SHA1 Message Date
Simon Michael
e8c934ab33 bin: paypaljson, paypaljson2csv - download txns from paypal API 2022-06-10 12:52:02 +01:00
Stephen Morgan
9155d679fe fix!: Revert "fix!: utf-8: Use with-utf8 to ensure all files are read and written with utf8 encoding. (#1619)"
This reverts commit e233f001c5.

This would break at least some people's workflow. A lighter touch is
probably sufficient.
2022-06-01 09:35:18 +10:00
Stephen Morgan
e233f001c5 fix!: utf-8: Use with-utf8 to ensure all files are read and written with utf8 encoding. (#1619)
May also fix #1154, #1033, #708, #536, #73: testing is needed.

This aims to solve all problems where misconfigured locales lead to
parsers failing on utf8-encoded data. This should hopefully avoid
encoding issues, but since it fundamentally alters how encoding is dealt
with it may lead to unexpected outcomes. Widespread testing on a number
of different platforms would be useful.
2022-05-22 13:12:19 +10:00
Simon Michael
2bf18540c2 ;bin: drop old tests 2022-04-21 21:33:28 -10:00
Simon Michael
e30634e6ad bin: readme: cleanup 2022-04-20 23:36:58 -10:00
Simon Michael
c783ebcee6 bin: hledger-simplebal.sh -> hledger-simplebal 2022-04-20 23:36:43 -10:00
Simon Michael
a7d4c3ad1e bin: hledger-git, hledger-pijul 2022-04-20 23:23:36 -10:00
Simon Michael
7440075903 ;bin: hledger-number.sh -> hledger-simplebal.sh 2022-04-20 18:58:38 -10:00
Simon Michael
5e735b4faf scripts: bin: exclude non-executable files 2022-04-05 10:05:04 -10:00
Simon Michael
326a314052 scripts: tweak 2022-04-05 09:31:26 -10:00
Simon Michael
6d02e9ef57 bin: aliases.sh -> bashrc, added fin/bin/gnused/gnudate 2022-04-05 09:19:38 -10:00
Stephen Morgan
28b52fcca5 fix: bin: Remove old function in hledger-print-location. 2022-03-26 15:35:19 -10:00
Stephen Morgan
603b2e9f09 ref: Use ExceptT String IO a instead of IO (Either String a).
This increases composability and avoids some ugly case handling. We
re-export runExceptT in Hledger.Read.

The final return types of the following functions has been changed from
IO (Either String a) to ExceptT String IO a. If this causes a problem,
you can get the old behaviour by calling runExceptT on the output:
readJournal, readJournalFiles, readJournalFile

Or, you can use the easy functions readJournal', readJournalFiles', and
readJournalFile', which assume default options and return in the IO
monad.
2022-03-25 14:23:27 -10:00
Stephen Morgan
852ba7b100 fix: bin: Get hledger-print-location working. 2022-03-10 16:56:46 -10:00
Simon Michael
5a0d61998a bin: check-fancyassertions: add docs to --help output 2022-02-10 08:20:54 -10:00
Simon Michael
0317f71c05 ;tools: changelog: move to tools/ 2022-01-01 08:25:16 -10:00
Simon Michael
09009cbb1c ;tools: bump resolver in more places 2021-12-16 13:34:59 -10:00
Simon Michael
16124eba14 dev: move commitlint to tools, keeping bin/ for user tools 2021-12-10 16:52:19 -10:00
Simon Michael
580ce7af46 bin: hledger-number tweak 2021-12-02 10:58:21 -10:00
Simon Michael
50142a0aec bin: hledger-number 2021-12-02 10:54:23 -10:00
Simon Michael
d2081e5d8f ;tools: changelog: updates 2021-11-26 21:06:40 -10:00
Simon Michael
8464fed4f6 ;tools: changelog: a silly tool that makes changelog work more pleasant 2021-11-26 12:31:36 -10:00
Pranesh Prakash
b7e79ef3b2
Update description of hledger-check-tagfiles.hs
Made it clear that it's a `/` and not "containing / exist" (i.e., containing or exist).
2021-11-23 03:10:05 +05:30
Stephen Morgan
1bc04685b7 pkg: Drop base-compat-batteries dependency.
Our supported stackage versions are now new enough that we don't need
any of the compatibility features anymore.
2021-10-31 07:56:07 -10:00
ShrykeWindgrace
72e94f4d80 ; imp: use megaparsec's prettyprinter for assertion parse errors 2021-10-31 07:40:37 -10:00
Stephen Morgan
e53e95540e ci: Recognise any commit starting with ‘Merge’ as a merge commit, which
is ignored by commitlint.
2021-09-27 09:40:24 -10:00
Stephen Morgan
04c35e1519 fix: bin: Allow hledger-check-fancyassertions to parse predicates (#1464). 2021-09-08 13:19:31 -10:00
Stephen Morgan
8fcdc22a45 fix: bin: Get scripts compiling with current hledger-lib. 2021-09-08 13:19:31 -10:00
Stephen Morgan
b7bf780c52 dev: hlint: Avoid use of reverse.
Note that this is semantically different, and will produce different
results. In particular, the sort is now stable, i.e. account names with
the same balance will not have their order reversed relative to each
other. In this context there doesn't seem to be a reason to prefer one
order to the other, so I'm making this change.
2021-08-27 06:13:56 -10:00
Stephen Morgan
d248aec313 cln: hlint: Remove eta reduce warnings. 2021-08-27 06:13:56 -10:00
Stephen Morgan
8bf7c95697 cln: hlint: Clean up Functor related hlint warnings, and NOINLINE warning. 2021-08-27 06:13:56 -10:00
Stephen Morgan
21e62ffcbd cln: hlint: Remove unless and $> warnings. 2021-08-27 06:13:56 -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
Simon Michael
4d04da94fb ci: commitlint: ignore boring commits: github merge commit (#1606) 2021-07-13 12:35:48 -10:00
Simon Michael
7f2ad64e7b bin:commitlint:doc, policy: allow more spaces, slash/comma in topics 2021-07-11 14:24:54 -10:00
Simon Michael
f7f88a4a9a bin: commitlint: don't exit successfully if a command fails (#1602) 2021-07-10 22:05:32 -10:00
Simon Michael
ec2436025c ;dev: bin: commitlint: advertise how to use it locally 2021-07-06 16:06:07 -10:00
Simon Michael
103813f116 ;dev: bin: commitlint: also work a git commit-msg hook 2021-07-06 15:33:18 -10:00
Simon Michael
215e90ad78 ;dev: bin: commitlint: check for preferred style in commit messages 2021-07-06 11:54:35 -10:00
Stephen Morgan
0a019e2167 lib,cli,web,bin: Replace journalSelectingAmountFromOpts with journalApplyValuationFromOpts.
This also has the effect of allowing valuation in more reports, for
example the transactionReport.
2021-06-08 14:55:05 +10:00
Stephen Morgan
7cb621b82f lib,cli,ui,bin: Remove unnecessary normalisedMixedAmount, replace
normaliseMixedAmountSquashPricesForDisplay with mixedAmountStripPrices.
2021-05-01 09:45:29 -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
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
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
a477aa95b0 ;bin: ignore stderr in func tests, check only exit code
This avoids failures when stack prints to stderr, eg when fetching
hackage index.
2021-01-29 12:09:58 -08:00
Simon Michael
db3fe16645 ;bin: readme updates 2021-01-12 15:11:20 -08:00