Commit Graph

50 Commits

Author SHA1 Message Date
Shubham Lagwankar
37b7ebfe22 use isSpace in lstrip (#441) 2016-12-20 09:29:12 -08:00
Johannes Gerer
74502f7e50 more general parser types enabling reuse outside of IO (#439) 2016-12-09 15:57:17 -08:00
Simon Michael
00e2a8a327 lib: note a problem with dbg*IO 2016-12-07 07:59:48 -08:00
Simon Michael
36c75841ee lib: dbgIO -> dbg0IO, consistent with dbg0 2016-11-24 10:59:03 -08:00
Simon Michael
3a5091e9eb don't show stack trace details in errors with GHC 8+ 2016-11-22 14:28:39 -08:00
Simon Michael
8bc0538778 allow megaparsec 5.0 or 5.1 for stackage compatibility 2016-10-27 07:19:26 -07:00
Simon Michael
2f4dde3699 lib: debug utils cleanup 2016-09-06 08:31:53 -07:00
Moritz Kiefer
4141067428 Replace Parsec with Megaparsec (see #289) (#366)
* Replace Parsec with Megaparsec (see #289)

This builds upon PR #289 by @rasendubi

* Revert renaming of parseWithState to parseWithCtx

* Fix doctests

* Update for Megaparsec 5

* Specialize parser to improve performance

* Pretty print errors

* Swap StateT and ParsecT

This is necessary to get the correct backtracking behavior, i.e. discard
state changes if the parsing fails.
2016-07-29 08:57:10 -07:00
Simon Michael
2d7a1904b4 dbgtrace takes a level parameter 2016-07-05 14:09:21 -07:00
Simon Michael
770dcee742 lib: textification: comments and tags
No change.

hledger -f data/100x100x10.journal stats
<<ghc: 42859576 bytes, 84 GCs, 193781/269984 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.001 elapsed), 0.016 MUT (0.020 elapsed), 0.009 GC (0.011 elapsed) :ghc>>
<<ghc: 42859576 bytes, 84 GCs, 193781/269984 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.001 elapsed), 0.015 MUT (0.018 elapsed), 0.009 GC (0.013 elapsed) :ghc>>

hledger -f data/1000x1000x10.journal stats
<<ghc: 349576344 bytes, 681 GCs, 1407388/4091680 avg/max bytes residency (7 samples), 11M in use, 0.000 INIT (0.000 elapsed), 0.124 MUT (0.130 elapsed), 0.047 GC (0.055 elapsed) :ghc>>
<<ghc: 349576280 bytes, 681 GCs, 1407388/4091680 avg/max bytes residency (7 samples), 11M in use, 0.000 INIT (0.000 elapsed), 0.126 MUT (0.132 elapsed), 0.049 GC (0.058 elapsed) :ghc>>

hledger -f data/10000x1000x10.journal stats
<<ghc: 3424030664 bytes, 6658 GCs, 11403359/41071624 avg/max bytes residency (11 samples), 111M in use, 0.000 INIT (0.000 elapsed), 1.207 MUT (1.228 elapsed), 0.473 GC (0.528 elapsed) :ghc>>
<<ghc: 3424030760 bytes, 6658 GCs, 11403874/41077288 avg/max bytes residency (11 samples), 111M in use, 0.000 INIT (0.002 elapsed), 1.234 MUT (1.256 elapsed), 0.470 GC (0.520 elapsed) :ghc>>

hledger -f data/100000x1000x10.journal stats
<<ghc: 34306547448 bytes, 66727 GCs, 76805504/414629288 avg/max bytes residency (14 samples), 1009M in use, 0.000 INIT (0.003 elapsed), 12.615 MUT (12.813 elapsed), 4.656 GC (5.291 elapsed) :ghc>>
<<ghc: 34306547320 bytes, 66727 GCs, 76805504/414629288 avg/max bytes residency (14 samples), 1009M in use, 0.000 INIT (0.009 elapsed), 12.802 MUT (13.065 elapsed), 4.774 GC (5.441 elapsed) :ghc>>
2016-05-24 19:00:57 -07:00
Simon Michael
c89c33b36e lib: textification: parse stream
10% more allocation, but 35% lower maximum residency, and slightly quicker.

hledger -f data/100x100x10.journal stats
<<ghc: 39327768 bytes, 77 GCs, 196834/269496 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.010 elapsed), 0.020 MUT (0.092 elapsed), 0.014 GC (0.119 elapsed) :ghc>>
<<ghc: 42842136 bytes, 84 GCs, 194010/270912 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.009 elapsed), 0.016 MUT (0.029 elapsed), 0.012 GC (0.120 elapsed) :ghc>>

hledger -f data/1000x1000x10.journal stats
<<ghc: 314291440 bytes, 612 GCs, 2070776/6628048 avg/max bytes residency (7 samples), 16M in use, 0.000 INIT (0.000 elapsed), 0.128 MUT (0.144 elapsed), 0.059 GC (0.070 elapsed) :ghc>>
<<ghc: 349558872 bytes, 681 GCs, 1397597/4106384 avg/max bytes residency (7 samples), 11M in use, 0.000 INIT (0.004 elapsed), 0.124 MUT (0.133 elapsed), 0.047 GC (0.053 elapsed) :ghc>>

hledger -f data/10000x1000x10.journal stats
<<ghc: 3070026824 bytes, 5973 GCs, 12698030/62951784 avg/max bytes residency (10 samples), 124M in use, 0.000 INIT (0.002 elapsed), 1.268 MUT (1.354 elapsed), 0.514 GC (0.587 elapsed) :ghc>>
<<ghc: 3424013128 bytes, 6658 GCs, 11405501/41071624 avg/max bytes residency (11 samples), 111M in use, 0.000 INIT (0.001 elapsed), 1.343 MUT (1.406 elapsed), 0.511 GC (0.573 elapsed) :ghc>>

hledger -f data/100000x1000x10.journal stats
<<ghc: 30753387392 bytes, 59811 GCs, 117615462/666703600 avg/max bytes residency (14 samples), 1588M in use, 0.000 INIT (0.000 elapsed), 12.068 MUT (12.238 elapsed), 6.015 GC (7.190 elapsed) :ghc>>
<<ghc: 34306530696 bytes, 66727 GCs, 76806196/414629312 avg/max bytes residency (14 samples), 1009M in use, 0.000 INIT (0.010 elapsed), 14.357 MUT (16.370 elapsed), 5.298 GC (6.534 elapsed) :ghc>>
2016-05-24 19:00:57 -07:00
Simon Michael
2538d14ea7 lib: textification begins! account names
The first of several conversions from String to (strict) Text, hopefully
reducing space and time usage.

This one shows a small improvement, with GHC 7.10.3 and text-1.2.2.1:

hledger -f data/100x100x10.journal stats
string: <<ghc: 39471064 bytes, 77 GCs, 198421/275048 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.001 elapsed), 0.015 MUT (0.020 elapsed), 0.010 GC (0.014 elapsed) :ghc>>
text:   <<ghc: 39268024 bytes, 77 GCs, 197018/270840 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.002 elapsed), 0.016 MUT (0.022 elapsed), 0.009 GC (0.011 elapsed) :ghc>>

hledger -f data/1000x100x10.journal stats
string: <<ghc: 318555920 bytes, 617 GCs, 2178997/7134472 avg/max bytes residency (7 samples), 16M in use, 0.000 INIT (0.001 elapsed), 0.129 MUT (0.136 elapsed), 0.067 GC (0.077 elapsed) :ghc>>
text:   <<ghc: 314248496 bytes, 612 GCs, 2074045/6617960 avg/max bytes residency (7 samples), 16M in use, 0.000 INIT (0.003 elapsed), 0.137 MUT (0.145 elapsed), 0.067 GC (0.079 elapsed) :ghc>>

hledger -f data/10000x100x10.journal stats
string: <<ghc: 3114763608 bytes, 6026 GCs, 18858950/75552024 avg/max bytes residency (11 samples), 201M in use, 0.000 INIT (0.000 elapsed), 1.331 MUT (1.372 elapsed), 0.699 GC (0.812 elapsed) :ghc>>
text:   <<ghc: 3071468920 bytes, 5968 GCs, 14120344/62951360 avg/max bytes residency (9 samples), 124M in use, 0.000 INIT (0.003 elapsed), 1.272 MUT (1.349 elapsed), 0.513 GC (0.578 elapsed) :ghc>>

hledger -f data/100000x100x10.journal stats
string: <<ghc: 31186579432 bytes, 60278 GCs, 135332581/740228992 avg/max bytes residency (13 samples), 1697M in use, 0.000 INIT (0.008 elapsed), 14.677 MUT (15.508 elapsed), 7.081 GC (8.074 elapsed) :ghc>>
text:   <<ghc: 30753427672 bytes, 59763 GCs, 117595958/666457240 avg/max bytes residency (14 samples), 1588M in use, 0.000 INIT (0.008 elapsed), 13.713 MUT (13.966 elapsed), 6.220 GC (7.108 elapsed) :ghc>>
2016-05-24 19:00:49 -07:00
Simon Michael
4179a83c1d lib: pprint 2016-05-20 08:31:39 -07:00
Simon Michael
550e99acd3 lib: let dbg*IO work in any MonadIO 2016-05-20 07:51:51 -07:00
Simon Michael
7f5e09096f lib: rename JournalContext to JournalParseState 2016-05-18 20:57:34 -07:00
Simon Michael
dd77ac4c0a lib: note debugLevel gotcha in GHCI 2016-02-19 22:54:38 -08:00
Simon Michael
76ab5df833 lib: credit pandoc for the charWidth function 2015-10-29 09:19:20 -07:00
Simon Michael
155722d7ee make strWidth aware of multi-line strings (#242) 2015-10-10 15:08:28 -07:00
Simon Michael
3b40edba9c print: fix wide char support, add tests (#242)
The print command wasn't lining up amounts with wide chars in account
names, fixed it properly this time. Transaction and Posting's Show instances
should also be wide-char-aware now.
2015-10-10 11:53:28 -07:00
Simon Michael
ef27e5c427 string utils cleanup 2015-09-28 18:47:05 -10:00
Simon Michael
42e2da4bb6 balance, print; more wide char support (#242)
Simple (non-multicolumn) balance reports containing wide characters
should now align correctly (in apps and fonts that show wide chars as
double width). Likewise, the print command.
2015-09-28 18:33:18 -10:00
Simon Michael
5b5e5eeaf4 register: wide-character-aware layout (#242)
Wide characters, eg chinese/japanese/korean characters, are typically
rendered wider than latin characters. In some applications (eg gnome
terminal or osx terminal) and fonts (eg monaco) they are exactly double
width. This is a start at making hledger aware of this. A register
report containing wide characters (in descriptions, account names, or
commodity symbols) should now align its columns correctly, when viewed
with a suitable font and application.
2015-09-28 16:12:20 -10:00
Simon Michael
041541e466 lib: memoised versions of regexReplace[CI] (#244) 2015-09-26 15:45:17 -10:00
Simon Michael
f8f2d457b9 lib: memoize toRegex[CI] (#244)
The regex helpers were converting strings to regex-tdfa regular
expressions on the fly every time, but this appears to be quite
expensive. The simplest memoisation lib seems to solve it nicely.
2015-09-26 15:39:21 -10:00
Simon Michael
74512814ec cli/ui/web: rename X.Options modules to X.XOptions
Make these modules' names more like the heavily-used types they
define (CliOpts, UIOpts, WebOpts). This is consistent with
RawOptions and ReportOptions, and helps with code navigation.
2015-08-28 12:43:51 -07:00
Simon Michael
cc98ee39f7 balance, lib: --format/StringFormat improvements
The balance command's --format option (in single-column mode) can now
adjust the rendering of multi-line strings, such as amounts with multiple
commodities. To control this, begin the format string with one of:

 %_  - renders on multiple lines, bottom-aligned (the default)
 %^  - renders on multiple lines, top-aligned
 %,  - render on one line, comma-separated

Also the final total (and the line above it) now adapt themselves to a
custom format.
2015-08-19 20:53:51 -07:00
Simon Michael
7aecbac851 lib: split up Utils more 2015-08-19 20:53:50 -07:00
Simon Michael
9e2111106b drop regexpr dependency 2015-05-17 08:32:45 -07:00
Simon Michael
70d87613f2 some cleanup of debug trace helpers 2015-05-14 13:01:49 -07:00
Simon Michael
e7376e4ea5 unnecessary CPP pragma 2015-03-29 16:10:39 -07:00
Simon Michael
4538745005 adapt to GHC-7.10's foldable/traversable changes (#239) 2015-03-27 15:43:28 -07:00
Julien Moutinho
cf28985cf2 lib: move from Text.ParserCombinators.Parsec to Text.Parsec
NOTE: required to use liftIO in includedirective
SEE: http://www.vex.net/~trebla/haskell/parsec-generally.xhtml#IO
2014-11-20 10:08:30 +01:00
Simon Michael
a2612f17c6 tweak wording 2014-10-29 08:27:52 -07:00
Simon Michael
d25fe21834 apply all matching account aliases, not just one directive and one option 2014-10-29 08:20:27 -07:00
Simon Michael
9fa22e0398 account aliases (and regexReplace) now support backreferences 2014-10-29 07:46:49 -07:00
Simon Michael
69636f70fb extract debug helpers into a module 2014-10-28 18:40:22 -07:00
Simon Michael
be9b637e0c fix a regexReplaceCI bug 2014-10-24 15:04:21 -07:00
Simon Michael
bfedf367c4 export Regexp types, disambiguate CsvReader's 2014-10-24 14:30:49 -07:00
gwern
d1618aaca8 strip trailing whitespace from all Haskell files 2014-10-14 18:48:24 -07:00
Simon Michael
9f991fa94b tweak Regex haddock 2014-07-08 11:50:19 -07:00
Simon Michael
5bebc2beb0 regex haddock fix 2014-07-06 14:08:45 -07:00
Simon Michael
3a16e6cfc7 mostly replace slow regexpr with regex-tdfa (fixes #189) 2014-07-06 14:03:28 -07:00
Simon Michael
04f6162e19 extract regular expression utils module 2014-07-06 10:11:02 -07:00
Simon Michael
e89bd131e9 also fix warnings in UTF8IOCompat 2013-04-12 16:28:29 -07:00
Simon Michael
42385fc8bf parsing: read dos line endings, deprecate encoding compatibility layer
We should now read all text in universal newline mode, so eg journal
files with DOS/windows line endings are fine.

This also deprecates and disables our IO encoding compatibility layer,
which prevented many encoding-related problems with certain platforms
and GHC versions. With modern GHC (7.x) this is now hopefully totally
unnecessary, but the module remains in place just in case.
2013-04-12 16:18:20 -07:00
Simon Michael
977fb2c3e8 make the utf8 IO compatibiity layer build on GHC 6.12.3, 7.0.4, 7.2.2, 7.4.1 2012-03-29 20:40:31 +00:00
Simon Michael
18f8a5386a docs: fix UTF8IOCompat haddock 2012-03-29 22:10:43 +00:00
Simon Michael
9ed8d8a8f6 docs: fix haddock hyperlink 2012-03-30 19:24:20 +00:00
Simon Michael
8492f6cae4 fix unicode handling on GHC >= 7.2, unify utf8 IO compatibility layer
tests pass again from GHC 6.12.3 to 7.4.1
2012-03-29 19:06:31 +00:00
Simon Michael
5084280879 imports, api cleanup 2011-05-28 04:11:44 +00:00