Stephen Morgan
702c958487
lib: Replace some utility functions with library functions.
2020-03-02 12:45:30 -08:00
Simon Michael
7ec25da13a
web: edit/upload: normalise line endings, avoiding parse errors ( #1194 )
...
Renamed: writeValidJournal -> writeJournalTextIfValidAndChanged
Added comments clarifying line ending behaviour of:
add, import, appendToJournalFileOrStdout, readFilePortably,
writeFileWithBackupIfChanged, writeJournalTextIfValidAndChanged
Summary of current behaviour:
- hledger add and import commands will append with (at least some)
unix line endings, possibly causing the file to have mixed line
endings
- hledger-web edit and upload forms will write the file with
the current system's native line endings, ie changing all
line endings if the file previously used foreign line endings.
2020-02-24 14:04:44 -08:00
Mykola Orliuk
31ae3d3aaf
;lib: drop SystemString left from GHC pre 7.2
...
We are relying on base-4.9 or newer. Thus we don't compile anymore with
GHC version lower than 8.0.1.
2019-11-18 17:38:39 -08:00
Simon Michael
4beb416070
lib: currying helpers
2019-08-19 02:09:27 +01:00
Caleb Maclennan
11d9e5eb6a
code: Strip extraneous trailing whitespace from Haskell sources
2019-07-15 16:40:49 +01:00
Simon Michael
b34b262c76
lib: document mapM'
...
[ci skip]
2019-02-17 08:36:59 -08:00
Simon Michael
86d5652e53
stop depending on here due to slow haskell-src-meta/stackage issues
...
Using file-embed or ordinary literals instead, for now.
2019-02-02 16:34:10 -08:00
Simon Michael
550aa408eb
lib: refactor, add embedFileRelative
2019-01-26 15:52:58 -08:00
Mykola Orliuk
8c6a418325
lib: fix home path expansion in includes
...
fixes simonmichael/hledger#896
2018-10-09 13:35:40 -10:00
Simon Michael
91b111b60d
rename easytests_* to tests_*
2018-09-06 13:13:26 -07:00
Simon Michael
bbecb28cae
tests: Utils -> easytest
2018-09-03 15:54:53 -07:00
Simon Michael
d778a92561
tests: export HUnit/EasyTest from Hledger.Utils.Test; more helpers
2018-08-18 15:19:59 +01:00
Simon Michael
eb6baac6e7
lib: make applyN more robust ( #852 )
2018-07-30 11:04:33 +01:00
Pavlo Kerestey
63d4c51dc4
Use quoteIfNeeded in quoteIfSpaced. Fix escapeDoubleQuotes to escape
2018-04-12 12:04:20 -07:00
Simon Michael
fedf36e823
lib: when the text encoding is UTF-8, ignore any UTF-8 BOM prefix
...
Paypal's new CSV has this BOM prefix (at the time of writing),
which was causing a confusing parse error.
2018-01-04 16:29:23 -08:00
Simon Michael
81e964502b
lib: refactor low-level text file reading
2018-01-04 16:17:25 -08:00
Simon Michael
e3c4a76119
add & use simpler readJournalFilesWithOpts/InputOpts api
2017-09-14 17:43:32 -07:00
Simon Michael
9a86c9ee52
lib: begin supporting colour
...
Add some basic helpers for working with ANSI colour codes,
and make strWidth and the various string layout functions aware of them.
2017-04-25 18:27:25 -07:00
Simon Michael
b402fc7e7d
lib: optserror -> usageError, consolidate with other error functions ( #529 )
2017-03-29 08:00:51 -07:00
Moritz Kiefer
d236f7b237
Fix a few spaceleaks ( #413 )
2017-01-12 16:24:53 -08:00
Simon Michael
264e81c430
lib: applyN comment
2016-12-29 11:33:34 -08:00
Simon Michael
275f98b3be
lib: getCurrentZonedTime
2016-10-21 11:47:07 -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
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
0f5ee154c4
lib: simplify parsers; cleanups ( #275 )
...
The journal/timeclock/timedot parsers, instead of constructing (opaque)
journal update functions which are later applied to build the journal,
now construct the journal directly (by modifying the parser state). This
is easier to understand and debug. It also removes any possibility of
the journal updates being a space leak. (They weren't, in fact memory
usage is now slightly higher, but that will be addressed in other ways.)
Also:
Journal data and journal parse info have been merged into one type (for
now), and field names are more consistent.
The ParsedJournal type alias has been added to distinguish being-parsed
and finalised journals.
Journal is now a monoid.
stats: fixed an issue with ordering of include files
journal: fixed an issue with ordering of included same-date transactions
timeclock: sessions can no longer span file boundaries (unclocked-out
sessions will be auto-closed at the end of the file).
expandPath now throws a proper IO error (and requires the IO monad).
2016-05-23 00:44:19 -07:00
Simon Michael
3a7a5d6035
lib: 6-tuple accessors
2015-08-24 16:24:11 -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
e838ed0637
fix a Control.Monad.Error warning ( #239 )
2015-03-29 16:12:05 -07:00
Simon Michael
d2877a919a
add some type signatures in Utils, helps ghci-web
2015-02-09 17:42:51 +00: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
69636f70fb
extract debug helpers into a module
2014-10-28 18:40:22 -07:00
Simon Michael
f064ecf138
fix a splitAtElement bug with adjacent separators
2014-10-24 14:30:00 -07:00
Simon Michael
b6774f47a3
balance, print: add -o and CSV output here too
...
Not very elegant yet, but works.
2014-10-21 12:02:23 -07:00
gwern
d1618aaca8
strip trailing whitespace from all Haskell files
2014-10-14 18:48:24 -07:00
Simon Michael
3ce34b145c
add missing dbgN helpers
2014-07-28 18:57:54 -07:00
Simon Michael
8aec855d04
note dbg0 is like ltrace
2014-07-17 15:06:28 -07:00
Simon Michael
04f6162e19
extract regular expression utils module
2014-07-06 10:11:02 -07:00
Simon Michael
647d5833ff
clarify dbgAtM issue
2014-07-02 23:24:58 -07:00
Simon Michael
ec51d28839
web: a bunch of ui cleanup & improvement
...
- the web UI has been streamlined; edit form, raw & entries views dropped
- we now remember whether sidebar is open or closed
- better help dialog
- keyboard shortcuts are now available
- better add form
- more bootstrap styling
- static file cleanups
- report filtering fixes
- upgrade jquery to 2.1.1, bootstrap to 3.1.1, drop select2, add typeahead, cookie, hotkeys
- clarify debug helpers a little
- refactoring
2014-06-13 00:19:00 +01:00
Simon Michael
6871c4cce5
dbgtrace, does a trace if --debug was used
2014-05-09 17:52:23 -07:00
Simon Michael
9d10cfa180
fix single-quote-containing addon arguments harder
2014-04-15 13:07:43 -07:00
Simon Michael
0d1d3ed057
fix an error when running an addon with an argument containing a single quote
...
More crazy quote engineering.. seems more robust than before.
2014-04-15 11:45:30 -07:00
Simon Michael
c93b19cb10
more debug utils, dbg0/dbg1/dbg2
2014-04-13 12:49:05 -07:00
Simon Michael
577ff7902c
dbgAtM, monadic version of dbgAt
2014-04-03 18:49:56 -07:00
Simon Michael
a05810f8e0
dbgAt
2014-04-03 18:49:56 -07:00
Simon Michael
784e9eff8a
dbg(ppshow) output improvements
...
- align single-line output a little better
- start multi-line output on a new line and indent it
2014-04-03 18:49:56 -07:00
Simon Michael
c5a839b309
3/4/5-tuple accessors
2014-04-03 18:49:56 -07:00
Simon Michael
ef1cc06cab
avoid pretty-show with GHC < 7.4; update tested-with ( fixes #155 )
...
hledger builds with GHC 7.2 through 7.8. 7.0 is not supported
because we require shakespeare which requires the DeriveGeneric extension.
2014-03-27 12:29:34 -07:00