Commit Graph

2441 Commits

Author SHA1 Message Date
Simon Michael
8b97d31db4 ;update manuals 2020-10-25 18:50:37 -10:00
Simon Michael
d42070ee87 ;csv: doc: rewrite currency tip (#1089) 2020-10-25 18:50:37 -10:00
Stephen Morgan
db97fae348 lib: Add documentation for CBCSubreportSpec. 2020-10-23 16:15:41 -07:00
Stephen Morgan
795134777c lib: Add Functor instance for CompoundPeriodicReport. 2020-10-23 16:15:41 -07:00
Stephen Morgan
affc8d10f2 lib: Generalise CBCSubreportSpec to allow more subreport control. 2020-10-23 16:15:41 -07:00
Stephen Morgan
6e65d4e071 lib: Export some MultiBalanceReport helper functions. 2020-10-23 16:15:41 -07:00
Stephen Morgan
c5abefc72f lib: Add documentation for ReportSpec. 2020-10-23 14:14:11 -07:00
Stephen Morgan
260283e2f1 lib,cli,ui,web: Introduce ReportSpec, which holds ReportOpts, the day of
the report, and the parsed Query.
2020-10-23 14:14:11 -07:00
Stephen Morgan
19ab222599 lib,cli: Remove old impure ReportOpts date functions. 2020-10-23 14:14:11 -07:00
Stephen Morgan
2aaab4b1b7 lib: Make Default instances clearer, remove Default instance for Bool. 2020-10-23 14:14:11 -07:00
Stephen Morgan
ff0c5bc743 lib,ui: Store the original query string in ReportOpts, provide a function for regenerating ReportOpts. 2020-10-23 14:14:11 -07:00
Stephen Morgan
64e3e5c54d lib: Improve documentation for StringFormat, remove type alias for Valuation. 2020-10-23 14:14:11 -07:00
Stephen Morgan
1171c23eee lib,cli,ui: Ensure ReportOpts always has today_ set. 2020-10-23 14:14:11 -07:00
Stephen Morgan
efc9758f82 lib: Make sure reportspan doesn't interfere with correctly determining valuation date. 2020-10-23 14:14:11 -07:00
Stephen Morgan
c45663d41d lib,cli: Store parsed Query in ReportOpts, rather than an unparsed
String.
2020-10-23 14:14:11 -07:00
Stephen Morgan
103308e795 lib,cli: Store StringFormat in ReportOpts, rather than unparsed String.
StringFormat now also takes an optional overline width, which is
currently only used by defaultBalanceLineFormat.
2020-10-23 14:14:11 -07:00
Stephen Morgan
f76cdc4317 lib: Remove checkReportOpts and checkRawOpts.
checkRawOpts has been a no-op for at least four years, and
checkReportOpts only makes sure that depth_ is positive, which is taken
care of by the maybeposintopt parser.
2020-10-23 14:14:11 -07:00
Stephen Morgan
5a6d38fdf2 lib: For ymd date parsing, don't consume invalid date components. 2020-10-18 21:28:46 -07:00
Stephen Morgan
97545018f4 lib: quoteIfNeeded should not escape the backslashes in unicode code points. 2020-10-18 21:08:25 -07:00
Simon Michael
08ee311875 journal: fix error when P directive has a zero price (#1373) 2020-10-18 20:48:14 -07:00
Simon Michael
f0db3fb157 ;update manuals 2020-10-18 16:01:59 -07:00
Simon Michael
3fb3c9c19f ;doc: journal: directives: simpler wording, not possible issue 2020-10-18 15:56:52 -07:00
Simon Michael
c35f05f6fc ;doc: journal: note that directives table should be scrolled 2020-10-18 15:56:52 -07:00
Stephen Morgan
7808aae682 lib: Remove un-necessary silencing of deprecation warning (relevant functions are no longer used) 2020-10-09 01:47:57 -07:00
Stephen Morgan
e57d911355 lib: Export OrdPlus and constructors. 2020-10-09 01:47:57 -07:00
Simon Michael
83087daa40 ;update manuals 2020-09-29 17:32:51 -07:00
Simon Michael
c5513ba722 ;tweak a few parse errors for clarity, consistency (#1329) 2020-09-19 08:10:39 -07:00
Simon Michael
f78dc639a5 fix a slowdown with report rendering in 1.19.1 (#1350)
stripAnsi is called many times during rendering (by strWidth), so
should be fast. It was originally a regex replacement, and more
recently a custom parser. The parser was slower, particularly the one
in 1.19.1. See #1350, and this rough test:

time118ish = timeIt $ print $ length $ concat $ map (fromRight undefined . regexReplace (toRegex' "\ESC\\[([0-9]+;)*([0-9]+)?[ABCDHJKfmsu]") "") testdata
time119    = timeparser (many (takeWhile1P Nothing (/='\ESC') <|> "" <$ ansi))
time1191   = timeparser (many ("" <$ try ansi <|> pure <$> anySingle))
timeparser p = timeIt $ print $ length $ concat $ map (concat . fromJust . parseMaybe p) testdata
testdata = concat $ replicate 10000
    [ "2008-01-01 income               assets🏦checking            $1            $1"
    , "2008-06-01 gift                 assets🏦checking            $1            $2"
    , "2008-06-02 save                 assets🏦saving              $1            $3"
    , "                                assets🏦checking  ..m$-1\ESC[m\ESC[m            $2"
    , "2008-06-03 eat & shop           assets:cash           ..m$-2\ESC[m\ESC[m             0"
    , "2008-12-31 pay off              assets🏦checking  ..m$-1\ESC[m\ESC[m  ..m$-1\ESC[m\ESC[m"
    ]

ghci> time118ish
4560000
CPU time:   0.17s
ghci> time119
4560000
CPU time:   0.91s
ghci> time1191
4560000
CPU time:   2.76s

Possibly a more careful parser could beat regexReplace. Note the
latter does memoisation, which could be faster and/or could also use
more resident memory in some situations.

Ideally we would calculate all widths before adding ANSI colour codes,
so we wouldn't have to wastefully strip them.
2020-09-10 18:07:40 -07:00
Simon Michael
8e1b5e784b ;doc: journal: redundant budget report link 2020-09-08 07:55:07 -07:00
Simon Michael
73de12c264 ;update changelogs 2020-09-07 16:17:58 -07:00
Simon Michael
2b715fbe0d ;update changelogs 2020-09-07 16:13:21 -07:00
Simon Michael
018bf8f474 ;update manuals 2020-09-07 12:17:35 -07:00
Simon Michael
90adb95983 ;update cabal files 2020-09-07 12:17:35 -07:00
Simon Michael
a151bcaec7 ; bump hledger-lib, hledger, hledger-ui, hledger-web version to 1.19.99 2020-09-07 12:16:12 -07:00
Simon Michael
8599eda37c allow megaparsec 9 2020-09-07 11:41:57 -07:00
Simon Michael
a5fcb19bb0 ;doc: changelog updates 2020-09-07 09:23:42 -07:00
Stephen Morgan
600dab3976 lib: Correctly strip ansi sequences with no numbers/semicolons. 2020-09-06 19:11:28 -07:00
Simon Michael
a9fbaaf284 ;partial comment cleanups 2020-09-03 09:52:00 -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
Simon Michael
e95a222ad2 ;update some cabal files 2020-09-01 20:39:02 -07:00
Simon Michael
09ac90a70a ;doc: finalise changelogs 2020-09-01 20:28:04 -07:00
Simon Michael
3170cc7cbd bump version to 1.19 2020-09-01 20:27:17 -07:00
Simon Michael
7aefa6f0ce ;doc: changelogs 2020-09-01 20:23:30 -07:00
Simon Michael
e44c1cfae8 ;regen manuals 2020-09-01 16:31:18 -07:00
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