Simon Michael
58f989715a
Replace our stringly Regex with a safer compiled Regexp type
...
This PR #1330 , addressing #1312 (parseQuery is partial) and #1245
(internal server error).
User-visible changes:
- hledger-web now handles malformed regular expressions
(eg, a query consisting of the single character `?`) gracefully,
showing a tidy error message instead "internal server error".
API/internal changes:
- The Regex type alias has been replaced by the Regexp ADT, which
contains both the compiled regular expression (so is guaranteed to
be usable at runtime) and the original string (so can be serialised,
printed, compared, etc.) A Regexp also knows whether is it case
sensitive or case insensitive. The Hledger.Utils.Regex api has changed.
- Typeable and Data instances are no longer derived for hledger's
data types; they were redundant/no longer needed
- NFData instances are no longer derived for hledger's data types.
This speeds up a full build by roughly 7%. But it means we can't
deep-evaluate hledger values, or time hledger code with Criterion.
https://github.com/simonmichael/hledger/pull/1330#issuecomment-684075129
has some ideas on this.
- Query no longer has a custom Show instance
- Some internal use of regexps was replaced by text replacement or
parsers.
- Hledger.Utils.String: quoteIfNeeded now actually escapes quotes in
strings; dropped escapeQuotes
- Hledger.Utils.Tree: dropped some old utilities
- dropped some obsolete code for the old --display option
Merge branch 'regexp' into master
2020-09-01 10:33:33 -07:00
Stephen Morgan
7d1e6d7d12
lib: Fix quoteIfNeeded so it actually escapes quotes.
2020-09-01 11:41:55 +10:00
Stephen Morgan
07dd30c1e5
lib,cli,ui: Change to consistent naming scheme for Hledger.Utils.Regex.
2020-09-01 11:36:34 +10:00
Stephen Morgan
5b647902c9
lib: Filter starting balances by subreport query in compoundBalanceReportWith.
2020-08-31 09:07:11 -07:00
Stephen Morgan
b91b391d08
lib: Replace some regex functions with parsers.
2020-08-31 22:44:41 +10:00
Stephen Morgan
20b39a5dd0
lib: Remove unused --display code.
...
This was dropped back in 2014, and getting rid of this removes a use of
regular expressions.
2020-08-31 20:45:37 +10:00
Stephen Morgan
8dfffb1e61
lib,web: Replace regex functions with simple text replacement.
2020-08-31 20:45:28 +10:00
Stephen Morgan
2cd7877c46
lib: Remove unnecessary NFData instances.
2020-08-31 15:41:36 +10:00
Stephen Morgan
af31d6e140
lib,cli,ui: Remove redundant Typeable and Data instances.
...
Also add some explicit import lists.
2020-08-31 15:41:30 +10:00
Stephen Morgan
01f5a92761
lib: Improve Read and Show instances for Regexp, get rid of custom show instance for Query.
2020-08-31 12:04:47 +10:00
Stephen Morgan
e3b2c94353
lib: Remove unneeded total Query code.
2020-08-31 12:04:47 +10:00
Stephen Morgan
e5371d5a6a
lib,cli,ui,web: Make Regexp a wrapper for Regex.
2020-08-31 12:04:45 +10:00
Stephen Morgan
ccd6fdd7b9
lib: Remove unused Tree functions.
2020-08-31 11:51:25 +10:00
Stephen Morgan
7182fa4746
lib: Improve documentation for amountRoundedQuantity, fix a typo.
2020-08-30 23:01:04 +10:00
Stephen Morgan
f6fa76bba7
lib,cli: Get rid of magic values for asprecision, use a sum type instead.
2020-08-30 23:00:35 +10:00
Stephen Morgan
ee1ef9606b
lib: Fail when parsing number with more than 255 decimal places.
2020-08-30 22:30:24 +10:00
Stephen Morgan
ba59fed6b2
lib: Replace more instances of fromIntegral with safer versions.
2020-08-30 22:20:58 +10:00
Stephen Morgan
ca2e55c954
lib: Replace some fromIntegral with toInteger.
2020-08-30 22:20:58 +10:00
Stephen Morgan
b5ed2067d9
lib: Make aprecision and DigitGroupStyle use Word8 instead of Int. exponentp now parses an Integer rather than an Int.
2020-08-30 22:20:53 +10:00
Stephen Morgan
371b349b2e
lib,cli: Replace parsedate and mkdatespan with direct applications of fromGregorian, transaction now takes Day instead of a date string.
2020-08-29 15:08:28 -07:00
Stephen Morgan
2fd678e415
lib,cli,ui: Remove old CPP directives made redundant by version bounds.
2020-08-29 15:08:28 -07:00
Simon Michael
c3d8857ae5
;doc: clarify csv file extensions and separator inferring
2020-08-21 09:01:23 -07:00
Simon Michael
a3c749f9e7
csv: fix inferring separator from .ssv/.tsv file extensions
...
This was documented but untested and may have never worked.
2020-08-21 08:59:55 -07:00
Stephen Morgan
32e184f9a8
lib: Elide boring parents in tree mode even when using --empty.
2020-08-11 17:24:50 -07:00
Simon Michael
542052478d
;lib: Types pragmas
2020-08-10 06:22:40 -07:00
Simon Michael
87e570290b
;doc: note mislabelled change
2020-08-08 12:07:26 -07:00
Simon Michael
b76caae338
fix doctest breakage ( #1312 )
2020-08-08 08:53:55 -07:00
Stephen Morgan
f2dcbd2fee
lib: Make ill-formed SmartDates unrepresentable.
2020-08-07 14:20:08 -07:00
Simon Michael
27d6b21dff
lib: Hledger.Query: add total variants of matches* functions ( #1312 )
...
matchesAccount_
matchesAmount_
matchesCommodity_
matchesPosting_
matchesPriceDirective_
matchesTags_
matchesTransaction_
These don't yet have tests of their own, but were converted
mechanically from the originals which should help.
2020-08-07 07:53:00 -07:00
Simon Michael
108c548240
journal: when an account alias contains a bad regexp, show details
...
lib: accountNameApplyAliases, accountNameApplyAliasesMemo are now
total
2020-08-06 15:27:40 -07:00
Simon Michael
3822c27bfe
;lib: regex: rename & export RegexError, export toRegex_, docs ( #1312 )
2020-08-06 15:25:58 -07:00
Simon Michael
4957008890
;lib: regex utilities: cleanup ( #1312 )
2020-08-06 11:35:04 -07:00
Simon Michael
a112085092
lib: add alternate regex utilities that don't call error ( #1312 )
2020-08-06 11:18:08 -07:00
Simon Michael
ede4bfd5b4
;mark more partial functions ( #1312 )
2020-08-05 17:29:43 -07:00
Simon Michael
3f55c23603
;review, tag all error calls with an easier to find PARTIAL: comment ( #1312 )
2020-08-05 16:08:33 -07:00
Simon Michael
242c05fc9a
lib, journal: parseQuery, modifyTransactions are now total ( #1312 )
...
modifyTransactions now also requires a reference date, for parsing queries.
Relative dates are now permitted in auto posting rules.
2020-08-05 13:44:04 -07:00
Simon Michael
7751d6947c
lib: parseAmountQueryTerm: allow whitespace around arg parts ( #1312 )
...
Whitespace around the operator, sign, or number is now tolerated.
2020-08-05 13:44:04 -07:00
Simon Michael
38a4704641
lib: make parseAmountQueryTerm total, improve docs/tests ( #1312 )
2020-08-05 13:44:04 -07:00
Stephen Morgan
08ad220448
lib: In quarterdatespanp, use yearp and allow uppercase Q.
2020-08-04 09:10:53 -07:00
Simon Michael
5d40b54043
;doc: regen manuals
2020-08-01 12:41:54 -07:00
Henning Thielemann
9c9701fe7d
lib: quarterdatespanp ( fixes #1247 )
2020-07-31 17:37:41 -07:00
Henning Thielemann
ccac09fb1b
lib: doubledatespanp: fix and re-enable doctest
2020-07-31 17:37:41 -07:00
Stephen Morgan
dc41cee2b0
lib: datep now requires years to be at least four digits.
2020-07-31 17:22:27 -07:00
Stephen Morgan
ffb5cf0773
lib: Ensure parsed years have at least 4 digits.
2020-07-31 17:22:27 -07:00
Stephen Morgan
7b9f9ae49c
lib: Refactor reportingintervalp to be more compact and do less backtracking.
2020-07-31 17:22:27 -07:00
Stephen Morgan
696d9c73b0
lib: Remove unnecessary try in parsers, replace unnecessary string' with string, rewrite some parsers in applicative style.
2020-07-31 17:22:27 -07:00
Dmitry Astapov
a82c383370
lib: disallow tabs in simplecommoditysymbolp ( fixes #1301 )
2020-07-28 15:33:47 -07:00
Martin Michlmayr
76b04ceb4f
doc: fix regex in example for regex aliases
2020-07-27 17:20:40 -07:00
Martin Michlmayr
76cb45def6
doc: clarify virtual prices
2020-07-25 06:32:31 -07:00
Stephen Morgan
081ee390ab
lib: Change skipMany spacenonewline to takeWhileP Nothing isNonNewlineSpace.
2020-07-22 14:58:53 -07:00
Simon Michael
d738ca8c60
;lib: cleanups
2020-07-19 06:13:38 -07:00
Simon Michael
21b91f17cb
;regen manuals
2020-07-18 12:37:06 -07:00
Simon Michael
e057857c04
;lib: CBCSubreportSpec note
2020-07-17 10:02:14 -07:00
Simon Michael
e4f8b80d3b
;journal: account types: fix detection of Cash as an Asset, add tests
2020-07-17 10:02:14 -07:00
Simon Michael
6a772fb94e
;journal: account types: doc fix
2020-07-17 08:22:01 -07:00
Simon Michael
fd9171df07
journal: account types: add Cash, tweak fallback regexp, rewrite docs
2020-07-17 08:02:12 -07:00
Stephen Morgan
30f02b0882
lib: account name clipping takes Maybe Int as depth.
2020-07-17 07:41:27 -07:00
Stephen Morgan
51ea6d9f25
lib: Make queryDepth return Maybe Int.
2020-07-16 10:05:53 -07:00
Stephen Morgan
dc076b0d5b
lib: Use text library functions for stripping.
2020-07-16 10:03:25 -07:00
Stephen Morgan
ed99aea7d5
lib: Introduce takeEnd to get rid of some reverse . take n . reverse.
2020-07-16 10:03:25 -07:00
Simon Michael
403cb457b7
;cabal files
2020-07-14 12:09:45 -07:00
Simon Michael
3452270241
cli: --color/--colour option; smart emacs, windows autodetection ( #1296 )
2020-07-14 12:08:36 -07:00
Simon Michael
4f7bee7abf
;regen help, manuals
2020-07-14 10:25:04 -07:00
Simon Michael
9198449ee3
areg: an account transaction register like the ones in ui/web ( #1294 )
...
;areg: debug output
;areg: show a title indicating which account was picked
This might be a bit of a pain for scripting, but otherwise it can be
quite confusing if your argument matches an account you didn't expect.
;areg: improve CSV headings
;areg: show at most two commodities per amount
2020-07-14 10:24:57 -07:00
Simon Michael
3f86bd545f
lib, ui, web: stricter accountTransactionsReport filtering
...
accountTransactionsReport now filters transactions more thoroughly, so
eg transactions dated outside the report period will not be shown.
Previously the transaction would be shown if it had any posting dated
inside the report period. Possibly some other filter criteria now get
applied that didn't before. I think on balance this will give slightly
preferable results.
2020-07-14 10:22:14 -07:00
Simon Michael
bf2fe3d88e
;lib: valuation debug output note
2020-07-14 10:21:45 -07:00
Simon Michael
febd8bb457
lib: postingsReport: follow debug levels policy
2020-07-13 11:53:05 -07:00
Simon Michael
0489622a3f
;csv: doc: subheadings
2020-07-10 16:36:15 -07:00
Stephen Morgan
fd729beabf
lib: Work around hiding deprecation warnings, don't traverse zeros twice in normaliseHelper.
2020-07-10 12:18:51 -07:00
Stephen Morgan
ee3ed6acdf
lib: Simplify and speed up amountLooksZero.
2020-07-10 12:18:51 -07:00
Stephen Morgan
99b74dc389
lib: Refactor sortAccountTreeByAmount
2020-07-10 09:08:03 -07:00
Stephen Morgan
463eee7bf4
lib: Replace {pr,prr}Negate with fmap negate.
2020-07-10 09:08:03 -07:00
Simon Michael
f518da747c
balcmds: avoid short month names in multi-year monthly reports
2020-07-09 12:56:46 -07:00
Simon Michael
f4991d05b4
lib: list exports of Hledger.Reports.BudgetReport
2020-07-09 12:55:04 -07:00
Simon Michael
23bef9a01b
;refactor: extracted reportPeriodName for making report headings
2020-07-09 12:54:20 -07:00
Simon Michael
4b9a76068f
lib: spanStartYear, spanEndYear, spanYears DateSpan helpers
2020-07-09 12:52:40 -07:00
Simon Michael
a89a4e1b42
bal --budget: show end-date column headings when appropriate
...
bal --budget was always showing the period as column heading,
as if for a change report. With --cumulative or --historical
it should show the end date, like other balance reports. Cf
https://hledger.org/hledger.html#multicolumn-balance-report .
2020-07-09 11:49:19 -07:00
Stephen Morgan
f5e1fb2625
lib: Refactor BudgetReport to re-use MultiBalanceReport code.
2020-07-07 18:46:34 -07:00
Stephen Morgan
bfda10ff20
lib: Refactor MultiBalanceReport row sorting, make sure totals are calculated after pruning.
2020-07-07 18:46:34 -07:00
Stephen Morgan
bde4d7e2e4
lib: Use last column of historical balance as total. Use totals for balanceReport.
2020-07-07 17:56:38 -07:00
Stephen Morgan
1425301a8c
lib, cli: Use --flat as the default mode for all reports.
2020-07-07 15:49:08 -07:00
Stephen Morgan
df84a417d7
doc: Remove references to old limitations of boring parent ellision.
2020-07-07 15:49:08 -07:00
Simon Michael
ae4fce8077
;regen manuals
2020-07-07 13:42:11 -07:00
Michael Sanders
278032bc8d
;doc: Revise doc for & operator
2020-07-07 12:51:01 -07:00
Michael Sanders
868c6fdbac
csv: Add docs and integration test for & operator
2020-07-07 12:51:01 -07:00
Michael Sanders
5ec0a518da
csv: Add support for & operators in conditional blocks
2020-07-07 12:51:01 -07:00
Simon Michael
95ee601548
;regen manuals
2020-07-07 10:19:56 -07:00
Simon Michael
81d3ac7d66
;csv: doc: fix some if-related links
2020-07-06 15:03:06 -07:00
Simon Michael
0bbd88fe7f
;doc: changelogs
2020-07-05 09:24:16 -07:00
Simon Michael
25c15d4bab
bal --budget: elide multicommodity amounts
2020-07-05 06:59:16 -07:00
Simon Michael
44c3eb1904
add a color argument to most amount show helpers, drop cshow variants
...
This is an API change, but it seems better than having additional
colour-supporting variants and trying to avoid duplicated code.
I stopped short of changing showAmount, so cshowAmount still exists.
2020-07-05 06:59:16 -07:00
Simon Michael
2739a70a38
balcmds: elide amounts with 3 or more commodities, unless --no-elide
...
Multicolumn balance reports showing many commodities tend to become
unreadably wide, especially in tree mode. Now by default we show at
most two commodities, and a count of the rest if there are more than
two. This should help keep reports somewhat readable by default.
2020-07-05 06:59:16 -07:00
Simon Michael
3d57d4793d
;doc: regen manuals
2020-07-04 16:17:13 -07:00
Stephen Morgan
c811ea4c7b
lib, cli, ui, web: intopt and friends now make sure their arguments fit
...
inside bounds.
2020-07-03 12:35:51 -07:00
Stephen Morgan
c96947284e
lib: Minor refactor.
2020-07-03 12:35:51 -07:00
Simon Michael
765fb732c9
debug: move command parsing debug output down to level 8
2020-07-03 11:37:01 -07:00
Simon Michael
6cc896a8fe
debug: show aliasing and auto postings with other reading (level 7)
2020-07-03 11:30:52 -07:00
Stephen Morgan
4fc72328d2
lib, cli: Introduce convienience function compoundBalanceReport.
2020-06-28 07:29:49 -07:00
Stephen Morgan
604868cea5
lib, cli: Move CompoundBalanceReport into ReportTypes, compoundReportWith into MultiBalanceReport, share postings amongst subreports.
2020-06-28 07:29:49 -07:00
Stephen Morgan
d09a90b38b
lib: Refactor multiBalanceReportWith into getPostingsbyColumn and generateMultiBalanceReport.
2020-06-28 07:29:49 -07:00