h$yeӦ       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                                                                                                                                                                                                                                                    ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! " " " " " # # # # $ $ $ $ $ $ % % % % % % % % % % % & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & ' ' ( ( ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) * * * * * * * * * + + + + + + + + + + , , , , , , , , , , , , , , - - - - - - - - - - - - - . . . . . / 03 Safe-Inferred( hledger-libAn efficient-to-build tree suggested by Cale Gibbard, probably better than accountNameTreeFrom.()*()* Safe-Inferred. hledger-lib&A SystemString-aware version of error./ hledger-lib*A SystemString-aware version of userError.0 hledger-lib=A SystemString-aware version of error that adds a usage hint. ./0  ./0None >$P1 hledger-libAn error message arising during a regular expression operation. Eg: trying to compile a malformed regular expression, or trying to apply a malformed replacement pattern.2 hledger-lib>A replacement pattern. May include numeric backreferences (N).3 hledger-libRegular expression. Extended regular expression-ish syntax ? But does not support eg (?i) syntax.9 hledger-lib=Test whether a Regexp matches a String. This is an alias for   for consistent naming.: hledger-lib&Tests whether a Regexp matches a Text.This currently unpacks the Text to a String an works on that. This is due to a performance bug in regex-tdfa (#9), which may or may not be relevant here.; hledger-libA memoising version of regexReplace. Caches the result for each search pattern, replacement pattern, target string tuple. This won't generate a regular expression parsing error since that is pre-compiled nowadays, but there can still be a runtime error from the replacement pattern, eg with a backreference referring to a nonexistent match group. 123456789:;<= 345678219:;<=None #$28>UE hledger-libA Ledger has the journal it derives from, and the accounts derived from that. Accounts are accessible both list-wise and tree-wise, since each one knows its parent and subs; the first account is the root of the tree and always exists.I hledger-libWhether an account's balance is normally a positive number (in accounting terms, a debit balance) or a negative number (credit balance). Assets and expenses are normally positive (debit), while liabilities, equity and income are normally negative (credit). ,https://en.wikipedia.org/wiki/Normal_balanceL hledger-libAn account, with its balances, parent/subaccount relationships, etc. Only the name is required; the other fields are added when needed.N hledger-libthis account's full nameO hledger-liboptional extra info from account directives relationships in the treeP hledger-libthis account's sub-accountsQ hledger-libparent accountR hledger-libused in the accounts report to label elidable parents balance informationS hledger-lib&the number of postings to this accountT hledger-lib-this account's balance, excluding subaccountsU hledger-lib-this account's balance, including subaccountsV hledger-libExtra information about an account that can be derived from its account directive (and the other account directives).X hledger-libany comment lines following an account directive for this accountY hledger-lib/tags extracted from the account comment, if anyZ hledger-libthe order in which this account was declared, relative to other account declarations, during parsing (1..)[ hledger-lib-Extra information found in a payee directive.] hledger-lib/any comment lines following the payee directive^ hledger-lib'tags extracted from the comment, if any_ hledger-lib2The id of a data format understood by hledger, eg journal or csv>. The --output-format option selects one of these for output.` hledger-libA journal in the process of being parsed, not yet finalised. The data is partial, and list fields are in reverse order.a hledger-libA Journal, containing transactions and various other things. The basic data model for hledger.This is used during parsing (as the type alias ParsedJournal), and then finalised/validated for use as a Journal. Some extra parsing-related fields are included for convenience, at least for now. In a ParsedJournal these are updated as parsing proceeds, in a Journal they represent the final state at end of parsing (used eg by the add command).c hledger-libthe current default year, specified by the most recent Y directive (or current date)d hledger-libthe current default commodity and its format, specified by the most recent D directivee hledger-libthe character to always parse as decimal point, if set by CsvReader's decimal-mark (or a future journal directive)f hledger-libthe current stack of parent account names, specified by apply account directivesg hledger-libthe current account name aliases in effect, specified by alias directives (& options ?) ,jparsetransactioncount :: Integer -- ^ the current count of transactions parsed so far (only journal format txns, currently)h hledger-lib2timeclock sessions which have not been clocked outj hledger-libPayees declared by payee directives, in parse order (after journal finalisation)k hledger-libAccounts declared by account directives, in parse order (after journal finalisation)l hledger-libAccounts whose type has been declared in account directives (usually 5 top-level accounts)m hledger-libper-commodity display styles declared globally, eg by command line option or import commandn hledger-lib8commodities and formats declared by commodity directiveso hledger-lib5commodities and formats inferred from journal amountsp hledger-libDeclarations of market prices by P directives, in parse order (after journal finalisation)q hledger-libMarket prices implied by transactions, in parse order (after journal finalisation)u hledger-lib6any final trailing comments in the (main) journal filev hledger-libthe file path and raw text of the main and any included journal files. The main file is first, followed by any included files in the order encountered. TODO: FilePath is a sloppy type here, don't assume it's a real file; values like "", "-", "(string)" can be seenw hledger-lib0when this journal was last read from its file(s)x hledger-libA historical market price (exchange rate) from one commodity to another. A more concise form of a PriceDirective, without the amount display info.z hledger-lib+Date on which this price becomes effective.{ hledger-lib#The commodity being converted from.| hledger-lib!The commodity being converted to.} hledger-libOne unit of the "from" commodity is worth this quantity of the "to" commodity.~ hledger-libA market price declaration made by the journal format's P directive. It declares two things: a historical exchange rate between two commodities, and an amount display style for the second commodity. hledger-libA periodic transaction rule, describing a transaction that recurs. hledger-lib the period expression as written hledger-lib-the interval at which this transaction recurs hledger-libthe (possibly unbounded) period during which this transaction recurs. Contains a whole number of intervals. hledger-libsome of Transaction's fields hledger-libA transaction modifier transformation, which adds an extra posting to the matched posting's transaction. Can be like a regular posting, or the amount can have the aismultiplier flag set, indicating that it's a multiplier for the matched posting's amount. hledger-libA transaction modifier rule. This has a query which matches postings in the journal, and a list of transformations to apply to those postings or their transactions. Currently there is one kind of transformation: the TMPostingRule, which adds a posting ("auto posting") to the transaction, optionally setting its amount to the matched posting's amount multiplied by a constant. hledger-libthis transaction's 1-based position in the transaction stream, or 0 when not available hledger-lib8any comment lines immediately preceding this transaction hledger-lib'the file position where the date starts hledger-libthis transaction's comment lines, as a single non-indented multi-line string hledger-lib0tag names and values, extracted from the comment hledger-libthis transaction's postings hledger-libThe position of parse errors (eg), like parsec's SourcePos but generic. hledger-lib9file path, 1-based line number and 1-based column number. hledger-libfile path, inclusive range of 1-based line numbers (first, last). hledger-lib8this posting's date, if different from the transaction's hledger-libthis posting's secondary date, if different from the transaction's hledger-libthis posting's comment lines, as a single non-indented multi-line string hledger-lib0tag names and values, extracted from the comment hledger-liban expected balance in the account after this posting, in a single commodity, excluding subaccounts. hledger-libthis posting's parent transaction (co-recursive types). Tying this knot gets tedious, Maybe makes it easier/optional. hledger-libWhen this posting has been transformed in some way (eg its amount or price was inferred, or the account name was changed by a pivot or budget report), this references the original untransformed posting (which will have Nothing in this field). hledger-libA balance assertion is a declaration about an account's expected balance at a certain point (posting date and parse order). They provide additional error checking and readability to a journal file.The  type is also used to represent balance assignments, which instruct hledger what an account's balance should become at a certain point.Different kinds of balance assertions are discussed eg on #290. Variables include:%which postings are to be summed (realvirtual; unmarkedpendingcleared; this accountthis account including subs)6which commodities within the balance are to be checkedwhether to do a partial or a total check (disallowing other commodities)I suspect we want: partial, subaccount-exclusive, Ledger-compatible assertions. Because they're what we've always had, and removing them would break some journals unnecessarily. Implemented with = syntax.total assertions. Because otherwise assertions are a bit leaky. Implemented with == syntax.subaccount-inclusive assertions. Because that's something folks need. Not implemented.flexible assertions allowing custom criteria (perhaps arbitrary queries). Because power users have diverse needs and want to try out different schemes (assert cleared balances, assert balance from real or virtual postings, etc.). Not implemented.multicommodity assertions, asserting the balance of multiple commodities at once. Not implemented, requires #934. hledger-lib.the expected balance in a particular commodity hledger-lib.disallow additional non-asserted commodities ? hledger-lib9include subaccounts when calculating the actual balance ? hledger-lib2the assertion's file position, for error reporting hledger-libThe status of a transaction or posting, recorded with a status mark (nothing, !, or *). What these mean is ultimately user defined. hledger-libkludge: a flag marking this amount and posting as a multiplier in a TMPostingRule. In a regular Posting, should always be false. hledger-lib?the (fixed, transaction-specific) price for this amount, if any hledger-libA style for displaying digit groups in the integer part of a floating point number. It consists of the character used to separate groups (comma or period, whichever is not used as decimal point), and the size of each group, starting with the one nearest the decimal point. The last group size is assumed to repeat. Eg, comma between thousands is DigitGroups ',' [3]. hledger-libThe "display precision" for a hledger amount, by which we mean the number of decimal digits to display to the right of the decimal mark. This can be from 0 to 255 digits (the maximum supported by the Decimal library), or NaturalPrecision meaning "show all significant decimal digits". hledger-libDisplay style for an amount. hledger-lib1does the symbol appear on the left or the right ? hledger-lib#space between symbol and quantity ? hledger-lib2number of digits displayed after the decimal point hledger-libcharacter used as decimal point: period or comma. Nothing means "unspecified, use default" hledger-lib)style for displaying digit groups, if any hledger-libAn amount's per-unit or total cost/selling price in another commodity, as recorded in the journal entry eg with  or @. Docs call this "transaction price". The amount is always positive. hledger-lib'The basic numeric type used in amounts. hledger-lib current year -> current quarter if it's in selected year, otherwise first quarter of selected year -> current month if it's in selected quarter, otherwise first month of selected quarter -> current week if it's in selected month, otherwise first week of selected month -> today if it's in selected week, otherwise first day of selected week, unless that's in previous month, in which case first day of month containing selected week. Shrinking a day has no effect.None #$28>h hledger-libShow a JSON-convertible haskell value as pretty-printed JSON text. hledger-libWrite a JSON-convertible haskell value to a pretty-printed JSON file. Eg: writeJsonFile "a.json" nulltransaction hledger-libRead a JSON file and decode it to the target type, or raise an error if we can't. Eg: readJsonFile "a.json" :: IO Transaction1 Safe-Inferredh 2 Safe-Inferred 2>?}@  hledger-libA type bundling a   with its full source text, filepath, and stack of include files. Suitable for pretty-printing. Megaparsec's   type already bundles a parse error with its full source text and filepath, so we just add a stack of include files.  hledger-libA type representing "final" parse errors that cannot be backtracked from and are guaranteed to halt parsing. The anti-backtracking behaviour is implemented by an  < layer in the parser's monad stack, using this type as the   error type.We have three goals for this type: (1) it should be possible to convert any parse error into a "final" parse error, (2) it should be possible to take a parse error thrown from an include file and re-throw it in the parent file, and (3) the pretty-printing of "final" parse errors should be consistent with that of ordinary parse errors, but should also report a stack of files for errors thrown from include files.In order to pretty-print a "final" parse error (goal 3), it must be bundled with include filepaths and its full source text. When a "final" parse error is thrown from within a parser, we do not have access to the full source, so we must hold the parse error until it can be joined with its source (and include filepaths, if it was thrown from an include file) by the parser's caller.A parse error with include filepaths and its full source text is represented by the   type, while a parse error in need of either include filepaths, full source text, or both is represented by the   type.  hledger-libA fragment of source suitable for "re-parsing". The purpose of this data type is to preserve the content and source position of the excerpt so that parse errors raised during "re-parsing" may properly reference the original source. hledger-libA custom error type for the parser. The type is specialized to parsers of   streams.  hledger-libFail at a specific source position, given by the raw offset from the start of the input stream (the number of tokens processed at that point).  hledger-libFail at a specific source interval, given by the raw offsets of its endpoints from the start of the input stream (the numbers of tokens processed at those points).Note that care must be taken to ensure that the specified interval does not span multiple lines of the input source. This will not be checked.  hledger-lib%Get the raw text of a source excerpt.  hledger-lib&'excerpt_ p' applies the given parser p5 and extracts the portion of the source consumed by p, along with the source position of this portion. This is the only way to create a source excerpt suitable for "re-parsing" by  .  hledger-lib4'reparseExcerpt s p' "re-parses" the source excerpt s using the parser p. Parse errors raised by p will be re-thrown at the source position of the source excerpt.In order for the correct source file to be displayed when re-throwing parse errors, we must ensure that the source file during the use of 'reparseExcerpt s p' is the same as that during the use of  $ that generated the source excerpt s. However, we can usually expect this condition to be satisfied because, at the time of writing, the only changes of source file in the codebase take place through include files, and the parser for include files neither accepts nor returns  s.  hledger-libPretty-print our custom parse errors. It is necessary to use this instead of  % when custom parse errors are thrown.This function intercepts our custom parse errors and applies final adjustments (finalizeCustomError) before passing them to  . These adjustments are part of the implementation of the behaviour of our custom parse errors.,Note: We must ensure that the offset of the   of the provided  . is no larger than the offset specified by a   constructor. This is guaranteed if this offset is set to 0 (that is, the beginning of the source file), which is the case for  s returned from  .  hledger-lib;Convert a "regular" parse error into a "final" parse error.  hledger-libLike megaparsec's  , but as a "final" parse error.  hledger-libLike  , but as a "final" parse error.  hledger-libLike megaparsec's  , but as a "final" parse error.  hledger-libPretty-print a "final" parse error: print the stack of include files, then apply the pretty-printer for parse error bundles. Note that   must be used on a "final" parse error before it can be pretty-printed.  hledger-libSupply a filepath and source text to a "final" parse error so that it can be pretty-printed. You must ensure that you provide the appropriate source text and filepath.  hledger-libParse a file with the given parser and initial state, discarding the final state and re-throwing any parse errors as "final" parse errors.  hledger-lib Start offset hledger-libEnd end offset hledger-lib Error message   None? hledger-libA parser of text that runs in some monad, keeping a Journal as state, that can throw an exception to end parsing, preventing further parser backtracking. hledger-libA parser of text that runs in some monad, keeping a Journal as state. hledger-lib)A parser of text that runs in some monad. hledger-lib%A parser of strict text to some type. hledger-lib A parser of string to some type. hledger-libBacktracking choice, use this when alternatives share a prefix. Consumes no input if all choices fail. hledger-libBacktracking choice, use this when alternatives share a prefix. Consumes no input if all choices fail. hledger-libRun a stateful parser with some initial state on a text. See also: runTextParser, runJournalParser. None? hledger-lib7Pretty print. Generic alias for pretty-simple's pPrint. hledger-lib5Pretty show. Generic alias for pretty-simple's pShow. hledger-lib3Pretty trace. Easier alias for traceShowId + pShow. hledger-libLike traceShowId, but uses a custom show function to render the value. traceShowIdWith was too much of a mouthful. hledger-libGlobal debug level, which controls the verbosity of debug output on the console. The default is 0 meaning no debug output. The --debug$ command line flag sets it to 1, or  --debug=N' sets it to a higher value (note: not  --debug N for some reason). This uses unsafePerformIO and can be accessed from anywhere and before normal command-line processing. When running with :main in GHCI, you must touch and reload this module to see the effect of a new --debug option. {- OPTIONS_GHC -fno-cse -} {- NOINLINE debugLevel -} hledger-libTrace (print to stderr) a string if the global debug level is at or above the specified level. At level 0, always prints. Otherwise, uses unsafePerformIO. hledger-libTrace (print to stderr) a showable value using a custom show function, if the global debug level is at or above the specified level. At level 0, always prints. Otherwise, uses unsafePerformIO. hledger-libPretty-print a label and a showable value to the console if the global debug level is at or above the specified level. At level 0, always prints. Otherwise, uses unsafePerformIO. hledger-libLike ptraceAt, but takes a custom show function instead of a label. hledger-libPretty-print a label and the showable value to the console, then return it. hledger-libPretty-print a label and the showable value to the console when the global debug level is >= 1, then return it. Uses unsafePerformIO. hledger-lib;Like dbg0, but also exit the program. Uses unsafePerformIO. hledger-lib?Like dbg0, but takes a custom show function instead of a label. hledger-libLike ptraceAt, but convenient to insert in an IO monad and enforces monadic sequencing (plus convenience aliases). XXX These have a bug; they should use traceIO, not trace, otherwise GHC can occasionally over-optimise (cf lpaste a few days ago where it killed/blocked a child thread). hledger-libLog a label and a pretty-printed showable value to ./debug.log, then return it. Can fail, see plogAt. hledger-libLog a label and a pretty-printed showable value to ./debug.log, if the global debug level is at or above the specified level. At level 0, always logs. Otherwise, uses unsafePerformIO. Tends to fail if called more than once too quickly, at least when built with -threaded ("Exception: debug.log: openFile: resource busy (file is locked)"). hledger-libPrint the provided label (if non-null) and current parser state (position and next input) to the console. See also megaparsec's dbg. hledger-lib"Convenience alias for traceParseAt: -None ?f  hledger-libName and group a list of tests. Shorter alias for Test.Tasty.HUnit.testGroup. hledger-libName an assertion or sequence of assertions. Shorter alias for Test.Tasty.HUnit.testCase. hledger-libAssert any Left value. hledger-libAssert any Right value. hledger-libAssert that this stateful parser runnable in IO successfully parses all of the given input text, showing the parse error if it fails. Suitable for hledger's JournalParser parsers. hledger-lib+Assert a parser produces an expected value. hledger-libLike assertParseEq, but transform the parse result with the given function before comparing it. hledger-libAssert that this stateful parser runnable in IO fails to parse the given input text, with a parse error containing the given string. hledger-libRun a stateful parser in IO like assertParse, then assert that the final state (the wrapped state, not megaparsec's internal state), transformed by the given function, matches the given expected value. hledger-libThese E variants of the above are suitable for hledger's ErroringJournalParser parsers.2 "! #$'&% "! #$'&%3 Safe-Inferred hledger-libHelper for constructing Builders while keeping track of text width. hledger-lib'Convert a WideBuilder to a strict Text. hledger-lib"Convert a WideBuilder to a String. hledger-libCalculate the render width of a string, considering wide characters (counted as double width) hledger-libCalculate the render width of a string, considering wide characters (counted as double width) hledger-libGet the designated render width of a character: 0 for a combining character, 1 for a regular character, 2 for a wide character. (Wide characters are rendered as exactly double width in apps and fonts that support it.) (From Pandoc.)   Safe-Inferred  hledger-libHow to align text in a cell hledger-lib Cell contents along an alignment hledger-lib)The options to use for rendering a table. hledger-lib Pretty tables hledger-lib$Whether to display the outer borders hledger-lib%Whether to display spaces around bars hledger-libCreate a single-line cell from the given contents with its natural width. hledger-libReturn the width of a Cell. hledger-libRender a table according to common options, for backwards compatibility hledger-lib8Render a table according to various cell specifications> hledger-lib>A version of renderTable which returns the underlying Builder. hledger-lib5Render a single row according to cell specifications. hledger-lib hledger-lib&Wrap a Text with the surrounding Text. hledger-lib*Remove trailing newlines/carriage returns. hledger-lib7Clip and pad a string to a minimum & maximum width, andor leftright justify it. Works on multi-line strings too (but will rewrite non-unix line endings). hledger-libWrap a string in double quotes, and -prefix any embedded single quotes, if it contains whitespace and is not already single- or double-quoted. hledger-libStrip one matching pair of single or double quotes on the ends of a string. hledger-libJoin several multi-line strings as side-by-side rectangular strings of the same height, top-padded. Treats wide characters as double width. hledger-libJoin several multi-line strings as side-by-side rectangular strings of the same height, bottom-padded. Treats wide characters as double width. hledger-libGeneral-purpose wide-char-aware single-line text layout function. It can left- or right-pad a short string to a minimum width. It can left- or right-clip a long string to a maximum width, optionally inserting an ellipsis (the third argument). It clips and pads on the right when the fourth argument is true, otherwise on the left. It treats wide characters as double width. hledger-libLeft-pad a text to the specified width. Treats wide characters as double width. Works on multi-line texts too (but will rewrite non-unix line endings). hledger-libRight-pad a string to the specified width. Treats wide characters as double width. Works on multi-line strings too (but will rewrite non-unix line endings). hledger-libDouble-width-character-aware string truncation. Take as many characters as possible from a string without exceeding the specified width. Eg textTakeWidth 3 "aa`" = "a". hledger-lib&Add a prefix to each line of a string. hledger-libAdd a prefix to the first line of a string, and a different prefix to the remaining lines. hledger-lib 0 (otherwise does nothing). Possibly uses O(n) stack ? hledger-libConvert a possibly relative, possibly tilde-containing file path to an absolute one, given the current directory. ~username is not supported. Leave "-" unchanged. Can raise an error. hledger-lib/Expand user home path indicated by tilde prefix hledger-libRead text from a file, converting any rn line endings to n,, using the system locale's text encoding, ignoring any utf8 BOM prefix (as seen in paypal's 2018 CSV, eg) if that encoding is utf8. hledger-libLike readFilePortably, but read from standard input if the path is "-". hledger-libTotal version of maximum, for integral types, giving 0 for an empty list. hledger-lib-Strict version of sum that doesn@t leak space hledger-lib1Strict version of maximum that doesn@t leak space hledger-lib1Strict version of minimum that doesn@t leak space hledger-libThis is a version of sequence based on difference lists. It is slightly faster but we mostly use it because it uses the heap instead of the stack. This has the advantage that Neil Mitchell@s trick of limiting the stack size to discover space leaks doesn@t show this as a false positive. hledger-libLike mapM but uses sequence'. hledger-libLike embedFile, but takes a path relative to the package directory. Similar to embedFileRelative ?  "! #$'&% ()*./0123456789:;<=,./0NoneB hledger-libThe result of running cmdargs: an association list of option names to string values. hledger-libIs the named option present ? hledger-libFrom a list of RawOpts, get the last one (ie the right-most on the command line) for which the given predicate returns a Just value. Useful for exclusive choice flags like --daily|--weekly|--quarterly...import Safe (readMay)7choiceopt Just (RawOpts [("a",""), ("b",""), ("c","")])Just "c".choiceopt (const Nothing) (RawOpts [("a","")])Nothingchoiceopt readMay (RawOpts [("LT",""),("EQ",""),("Neither","")]) :: Maybe OrderingJust EQ hledger-libCollects processed and filtered list of options preserving their order0collectopts (const Nothing) (RawOpts [("x","")])[].collectopts Just (RawOpts [("a",""),("b","")])[("a",""),("b","")] hledger-libReads the named option's Int argument, if it is present. An argument that is too small or too large will raise an error. hledger-libReads the named option's natural-number argument, if it is present. An argument that is negative or too large will raise an error. hledger-libReads the named option's Int argument. If not present it will return 0. An argument that is too small or too large will raise an error. hledger-libReads the named option's natural-number argument. If not present it will return 0. An argument that is negative or too large will raise an error. hledger-lib"parser" that returns   value for valid choice hledger-lib%actual options where to look for flag hledger-lib)exclusive choice among those returned as   from "parser"None  ?% hledger-libRender a datespan as a display string, abbreviating into a compact form if possible. hledger-libLike showDateSpan, but show month spans as just the abbreviated month name in the current locale. hledger-libGet the current local date. hledger-lib#Get the current local month number. hledger-libGet the current local year. hledger-lib5Get the 0-2 years mentioned explicitly in a DateSpan. hledger-lib?Get overall span enclosing multiple sequentially ordered spans. hledger-libSplit a DateSpan into consecutive whole spans of the specified interval which fully encompass the original span (and a little more when necessary). If no interval is specified, the original span is returned. If the original span is the null date span, ie unbounded, the null date span is returned. If the original span is empty, eg if the end date is <= the start date, no spans are returned. Examples:let t i y1 m1 d1 y2 m2 d2 = splitSpan i $ DateSpan (Just $ fromGregorian y1 m1 d1) (Just $ fromGregorian y2 m2 d2)"t NoInterval 2008 01 01 2009 01 01[DateSpan 2008]$t (Quarters 1) 2008 01 01 2009 01 01[DateSpan 2008Q1,DateSpan 2008Q2,DateSpan 2008Q3,DateSpan 2008Q4]#splitSpan (Quarters 1) nulldatespan [DateSpan ..]6t (Days 1) 2008 01 01 2008 01 01 -- an empty datespan[]$t (Quarters 1) 2008 01 01 2008 01 01[]"t (Months 1) 2008 01 01 2008 04 014[DateSpan 2008-01,DateSpan 2008-02,DateSpan 2008-03]"t (Months 2) 2008 01 01 2008 04 01[DateSpan 2008-01-01..2008-02-29,DateSpan 2008-03-01..2008-04-30]!t (Weeks 1) 2008 01 01 2008 01 15[DateSpan 2007-12-31W01,DateSpan 2008-01-07W02,DateSpan 2008-01-14W03]!t (Weeks 2) 2008 01 01 2008 01 15[DateSpan 2007-12-31..2008-01-13,DateSpan 2008-01-14..2008-01-27]&t (DayOfMonth 2) 2008 01 01 2008 04 01[DateSpan 2007-12-02..2008-01-01,DateSpan 2008-01-02..2008-02-01,DateSpan 2008-02-02..2008-03-01,DateSpan 2008-03-02..2008-04-01],t (WeekdayOfMonth 2 4) 2011 01 01 2011 02 15[DateSpan 2010-12-09..2011-01-12,DateSpan 2011-01-13..2011-02-09,DateSpan 2011-02-10..2011-03-09]%t (DayOfWeek 2) 2011 01 01 2011 01 15[DateSpan 2010-12-28..2011-01-03,DateSpan 2011-01-04..2011-01-10,DateSpan 2011-01-11..2011-01-17])t (DayOfYear 11 29) 2011 10 01 2011 10 15![DateSpan 2010-11-29..2011-11-28])t (DayOfYear 11 29) 2011 12 01 2012 12 15[DateSpan 2011-11-29..2012-11-28,DateSpan 2012-11-29..2013-11-28] hledger-libCount the days in a DateSpan, or if it is open-ended return Nothing. hledger-lib&Does the span include the given date ? hledger-libDoes the period include the given date ? (Here to avoid import cycle). hledger-lib4Calculate the intersection of a number of datespans. hledger-lib,Calculate the intersection of two datespans.For non-intersecting spans, gives an empty span beginning on the second's start date: >>> DateSpan (Just $ fromGregorian 2018 01 01) (Just $ fromGregorian 2018 01 03)  DateSpan (Just $ fromGregorian 2018 01 03) (Just $ fromGregorian 2018 01 05) DateSpan 2018-01-03..2018-01-02 hledger-libFill any unspecified dates in the first span with the dates from the second one. Sort of a one-way spanIntersect. hledger-lib-Calculate the union of a number of datespans. hledger-lib%Calculate the union of two datespans. hledger-libCalculate the minimal DateSpan containing all of the given Days (in the usual exclusive-end-date sense: beginning on the earliest, and ending on the day after the latest). hledger-libSelect the DateSpan containing a given Day, if any, from a given list of DateSpans.If the DateSpans are non-overlapping, this returns the unique containing DateSpan, if it exists. If the DateSpans are overlapping, it will return the containing DateSpan with the latest start date, and then latest end date. hledger-libParse a period expression to an Interval and overall DateSpan using the provided reference date, or return a parse error. hledger-lib1Like parsePeriodExpr, but call error' on failure. hledger-libConvert a smart date string to an explicit yyyy/mm/dd string using the provided reference date, or raise an error. hledger-lib"A safe version of fixSmartDateStr. hledger-libConvert a SmartDate to an absolute date using the provided reference date. Examples: :set -XOverloadedStrings2let t = fixSmartDateStr (fromGregorian 2008 11 26)t "0000-01-01" "0000-01-01"t "1999-12-02" "1999-12-02"t "1999.12.02" "1999-12-02" t "1999/3/2" "1999-03-02" t "19990302" "1999-03-02" t "2008/2" "2008-02-01" t "0020/2" "0020-02-01"t "1000" "1000-01-01"t "4/2" "2008-04-02"t "2" "2008-11-02" t "January" "2008-01-01"t "feb" "2008-02-01" t "today" "2008-11-26" t "yesterday" "2008-11-25" t "tomorrow" "2008-11-27" t "this day" "2008-11-26" t "last day" "2008-11-25" t "next day" "2008-11-27"t "this week" -- last monday "2008-11-24"!t "last week" -- previous monday "2008-11-17"t "next week" -- next monday "2008-12-01"t "this month" "2008-11-01"t "last month" "2008-10-01"t "next month" "2008-12-01"t "this quarter" "2008-10-01"t "last quarter" "2008-07-01"t "next quarter" "2009-01-01" t "this year" "2008-01-01" t "last year" "2007-01-01" t "next year" "2009-01-01"t "last wed" "2008-11-19" t "next friday" "2008-11-28" t "next january" "2009-01-01" hledger-libTry to parse a couple of date string formats: `YYYY-MM-DD`, `YYYYMMDD` or 45, with leading zeros required. For internal use, not quite the same as the journal's "simple dates". >>> parsedateM "200802*03" Just 2008-02-03 >>> parsedateM "200802#03/" Nothing >>> parsedateM "200802 30" Nothing hledger-libParse a date in any of the formats allowed in Ledger's period expressions, and some others. Assumes any text in the parse stream has been lowercased. Returns a SmartDate, to be converted to a full date later (see fixSmartDate). Examples: 2004 (start of year, which must have 4+ digits) 2004/10 (start of month, which must be 1-12) 2004/10/1 (exact date, day must be 1-31) 10/1 (month and day in current year) 21 (day in current month) october, oct (start of month in current year) yesterday, today, tomorrow (-1, 0, 1 days from today) last/this/next day/week/month/quarter/year (-1, 0, 1 periods from the current period) 20181201 (8 digit YYYYMMDD with valid year month and day) 201812 (6 digit YYYYMM with valid year and month)=Note malformed digit sequences might give surprising results: 201813 (6 digits with an invalid month is parsed as start of 6-digit year) 20181301 (8 digits with an invalid month is parsed as start of 8-digit year) 20181232 (8 digits with an invalid day gives an error) 201801012 (9+ digits beginning with a valid YYYYMMDD gives an error)Eg:YYYYMMDD is parsed as year-month-date if those parts are valid (>=4 digits, 1-12, and 1-31 respectively): >>> parsewith (smartdate <* eof) "20181201" Right (SmartAssumeStart 2018 (Just (12,Just 1)))YYYYMM is parsed as year-month-01 if year and month are valid: >>> parsewith (smartdate <* eof) "201804" Right (SmartAssumeStart 2018 (Just (4,Nothing)))With an invalid month, it's parsed as a year: >>> parsewith (smartdate <* eof) "201813" Right (SmartAssumeStart 201813 Nothing)A 9+ digit number beginning with valid YYYYMMDD gives an error: >>> parsewith (smartdate <* eof) "201801012" Left (...)Big numbers not beginning with a valid YYYYMMDD are parsed as a year: >>> parsewith (smartdate <* eof) "201813012" Right (SmartAssumeStart 201813012 Nothing) hledger-libParse a year number from a Text, making sure that at least four digits are used. hledger-libParse a period expression, specifying a date span and optionally a reporting interval. Requires a reference "today" date for resolving any relative start/end dates (only; it is not needed for parsing the reporting interval).2let p = parsePeriodExpr (fromGregorian 2008 11 26)p "from Aug to Oct"2Right (NoInterval,DateSpan 2008-08-01..2008-09-30)p "aug to oct"2Right (NoInterval,DateSpan 2008-08-01..2008-09-30) p "2009q2""Right (NoInterval,DateSpan 2009Q2)p "Q3""Right (NoInterval,DateSpan 2008Q3)p "every 3 days in Aug"Right (Days 3,DateSpan 2008-08)p "daily from aug"$Right (Days 1,DateSpan 2008-08-01..)p "every week to 2009"%Right (Weeks 1,DateSpan ..2008-12-31)p "every 2nd day of month" Right (DayOfMonth 2,DateSpan ..)p "every 2nd day" Right (DayOfMonth 2,DateSpan ..)p "every 2nd day 2009.."*Right (DayOfMonth 2,DateSpan 2009-01-01..)p "every 2nd day 2009-"*Right (DayOfMonth 2,DateSpan 2009-01-01..)p "every 29th Nov"#Right (DayOfYear 11 29,DateSpan ..)p "every 29th nov ..2009"-Right (DayOfYear 11 29,DateSpan ..2008-12-31)p "every nov 29th"#Right (DayOfYear 11 29,DateSpan ..)p "every Nov 29th 2009.."-Right (DayOfYear 11 29,DateSpan 2009-01-01..)p "every 11/29 from 2009"-Right (DayOfYear 11 29,DateSpan 2009-01-01..)'p "every 2nd Thursday of month to 2009"0Right (WeekdayOfMonth 2 4,DateSpan ..2008-12-31)%p "every 1st monday of month to 2009"0Right (WeekdayOfMonth 1 1,DateSpan ..2008-12-31) p "every tue"Right (DayOfWeek 2,DateSpan ..)p "every 2nd day of week"Right (DayOfWeek 2,DateSpan ..)p "every 2nd day of month" Right (DayOfMonth 2,DateSpan ..)p "every 2nd day" Right (DayOfMonth 2,DateSpan ..)p "every 2nd day 2009.."*Right (DayOfMonth 2,DateSpan 2009-01-01..)!p "every 2nd day of month 2009.."*Right (DayOfMonth 2,DateSpan 2009-01-01..) hledger-lib0A datespan of zero length, that matches no date.**None  hledger-lib6Look up one of the sample commodities' symbol by name. hledger-libFind the conversion rate between two commodities. Currently returns 1.None #$2$o hledger-lib2Options for the display of Amount and MixedAmount. hledger-lib*Whether to display the Price of an Amount. hledger-libIf the Amount rounds to 0, whether to display its commodity string. hledger-lib&Whether to colourise negative Amounts. hledger-lib4Whether to normalise MixedAmounts before displaying. hledger-libWhether to display on one line. hledger-libMinimum width to pad to hledger-libMaximum width to clip to hledger-lib.Display Amount and MixedAmount with no colour. hledger-lib.Display Amount and MixedAmount with no prices. hledger-lib:Display Amount and MixedAmount on one line with no prices. hledger-libDefault amount style hledger-libThe empty simple amount. hledger-libThe empty simple amount. hledger-libA temporary value for parsed transactions which had no amount specified. hledger-libConvert an amount to the specified commodity, ignoring and discarding any assigned prices and assuming an exchange rate of 1. hledger-libConvert a amount to its "cost" or "selling price" in another commodity, using its attached transaction price if it has one. Notes:price amounts must be MixedAmounts with exactly one component Amount (or there will be a runtime error XXX)price amounts should be positive in the Journal (though this is currently not enforced) hledger-libReplace an amount's TotalPrice, if it has one, with an equivalent UnitPrice. Has no effect on amounts without one. Also increases the unit price's display precision to show one extra decimal place, to help keep transaction amounts balancing. Does Decimal division, might be some rounding/irrational number issues. hledger-libDivide an amount's quantity (and its total price, if it has one) by a constant. hledger-libMultiply an amount's quantity (and its total price, if it has one) by a constant. hledger-lib/Is this amount negative ? The price is ignored. hledger-libDo this Amount and (and its total price, if it has one) appear to be zero when rendered with its display precision ? hledger-libIs this Amount (and its total price, if it has one) exactly zero, ignoring its display precision ? hledger-lib+Set an amount's display precision, flipped. hledger-lib"Set an amount's display precision. hledger-libIncrease an amount's display precision, if needed, to enough decimal places to show it exactly (showing all significant decimal digits, excluding trailing zeros). hledger-libSet an amount's internal precision, ie rounds the Decimal representing the amount's quantity to some number of decimal places. Rounding is done with Data.Decimal's default roundTo function: "If the value ends in 5 then it is rounded to the nearest even value (Banker's Rounding)". Does not change the amount's display precision. Intended only for internal use, eg when comparing amounts in tests. hledger-libSet an amount's internal precision, flipped. Intended only for internal use, eg when comparing amounts in tests. hledger-lib1Set (or clear) an amount's display decimal point. hledger-lib:Set (or clear) an amount's display decimal point, flipped. hledger-libGiven a map of standard commodity display styles, apply the appropriate one to this amount. If there's no standard style for this amount's commodity, return the amount unchanged. hledger-libLike styleAmount, but keep the number of decimal places unchanged. hledger-lib1Reset this amount's display style to the default. hledger-libGet the string representation of an amount, based on its commodity's display settings. String representations equivalent to zero are converted to just "0". The special "missing" amount is displayed as the empty string. ,showAmount = wbUnpack . showAmountB noColour hledger-libGeneral function to generate a WideBuilder for an Amount, according the supplied AmountDisplayOpts. The special "missing" amount is displayed as the empty string. This is the main function to use for showing Amounts, constructing a builder; it can then be converted to a Text with wbToText, or to a String with wbUnpack. hledger-libColour version. For a negative amount, adds ANSI codes to change the colour, currently to hard-coded red.  ["a","a:b","a:b:c","d","d:e"] hledger-lib"a:b:c" -> ["a","a:b","a:b:c"] hledger-lib  "a:b:c","d:e" -> ["a","d"] hledger-libIs the first account a parent or other ancestor of (and not the same as) the second ? hledger-libFrom a list of account names, select those which are direct subaccounts of the given account name. hledger-lib*Convert a list of account names to a tree. hledger-libElide an account name to fit in the specified width. From the ledger 2.6 news:  What Ledger now does is that if an account name is too long, it will start abbreviating the first parts of the account name down to two letters in length. If this results in a string that is still too long, the front will be elided -- not the end. For example: Expenses:Cash ; OK, not too long Ex:Wednesday:Cash ; Expenses6 was abbreviated to fit Ex:We:Afternoon:Cash ; Expenses and  Wednesday abbreviated ; Expenses:Wednesday:Afternoon:Lunch:Snack:Candy:Chocolate:Cash ..:Af:Lu:Sn:Ca:Ch:Cash ; Abbreviated and elided!  hledger-libKeep only the first n components of an account name, where n is a positive integer. If n is Just 0, returns the empty string, if n is Nothing, return the full name. hledger-libKeep only the first n components of an account name, where n is a positive integer. If n is Just 0, returns "...", if n is Nothing, return the full name. hledger-libEscape an AccountName for use within a regular expression. >>> putStr . T.unpack $ escapeName "First?! $*?$(*) !@^*? %)*!#" First?!#$*?$(*) !^ \*\? %\)\*!@ hledger-libConvert an account name to a regular expression matching it and its subaccounts. hledger-libConvert an account name to a regular expression matching it and its subaccounts, case insensitively. hledger-libConvert an account name to a regular expression matching it but not its subaccounts. hledger-libConvert an account name to a regular expression matching it but not its subaccounts, case insensitively.None %G6 hledger-libMake a posting to an account. hledger-lib2Make a virtual (unbalanced) posting to an account. hledger-lib=Make a posting to an account, maybe with a balance assertion. hledger-libMake a virtual (unbalanced) posting to an account, maybe with a balance assertion. hledger-lib,Make a partial, exclusive balance assertion. hledger-lib*Make a total, exclusive balance assertion. hledger-lib,Make a partial, inclusive balance assertion. hledger-lib*Make a total, inclusive balance assertion. hledger-lib9Sorted unique account names referenced by these postings. hledger-libRemove all prices of a posting hledger-libGet a posting's (primary) date - it's own primary date if specified, otherwise the parent transaction's primary date, or the null date if there is no parent transaction. hledger-libGet a posting's secondary (secondary) date, which is the first of: posting's secondary date, transaction's secondary date, posting's primary date, transaction's primary date, or the null date if there is no parent transaction. hledger-libGet a posting's status. This is cleared or pending if those are explicitly set on the posting, otherwise the status of its parent transaction, or unmarked if there is no parent transaction. (Note the ambiguity, unmarked can mean "posting and transaction are both unmarked" or "posting is unmarked and don't know about the transaction". hledger-libTags for this posting including any inherited from its parent transaction. hledger-lib:Tags for this transaction including any from its postings. hledger-lib3Does this posting fall within the given date span ? hledger-libPrefix one account name to another, preserving posting type indicators like concatAccountNames. hledger-libJoin account names into one. If any of them has () or [] posting type indicators, these (the first type encountered) will also be applied to the resulting account name. hledger-libApply some account aliases to the posting's account name, as described by accountNameApplyAliases. This can fail due to a bad replacement pattern in a regular expression alias. hledger-libRewrite an account name using all matching aliases from the given list, in sequence. Each alias sees the result of applying the previous aliases. Or, return any error arising from a bad regular expression in the aliases. hledger-lib=Memoising version of accountNameApplyAliases, maybe overkill. hledger-libApply a specified costing and valuation to this posting's amount, using the provided price oracle, commodity styles, and reference dates. Costing is done first if requested, and after that any valuation. See amountApplyValuation and amountCost. hledger-libApply a specified valuation to this posting's amount, using the provided price oracle, commodity styles, and reference dates. See amountApplyValuation. hledger-libConvert this posting's amount to cost, and apply the appropriate amount styles. hledger-lib4Apply a transform function to this posting's amount. hledger-libJoin two parts of a comment, eg a tag and another tag, or a tag and a non-tag, on a single line. Interpolates a comma and space unless one of the parts is empty. hledger-libAdd a tag to a comment, comma-separated from any prior content. A space is inserted following the colon, before the value. hledger-libAdd a tag on its own line to a comment, preserving any prior content. A space is inserted following the colon, before the value.00None #$%?X hledger-libRender source position in human-readable form. Keep in sync with Hledger.UI.ErrorScreen.hledgerparseerrorpositionp (temporary). XXX hledger-lib;Make a simple transaction with the given date and postings. hledger-libRender a journal transaction as text similar to the style of Ledger's print command.0Adapted from Ledger 2.x and 3.x standard format: yyyy-mm-dd[ *][ CODE] description......... [ ; comment...............] account name 1..................... ...$amount1[ ; comment...............] account name 2..................... ..$-amount1[ ; comment...............] pcodewidth = no limit -- 10 -- mimicking ledger layout. pdescwidth = no limit -- 20 -- I don't remember what these mean, pacctwidth = 35 minimum, no maximum -- they were important at the time. pamtwidth = 11 pcommentwidth = no limit -- 22 The output will be parseable journal syntax. To facilitate this, postings with explicit multi-commodity amounts are displayed as multiple similar postings, one per commodity. (Normally does not happen with this function). hledger-libLike showTransaction, but explicit multi-commodity amounts are shown on one line, comma-separated. In this case the output will not be parseable journal syntax. hledger-libRender a posting, simply. Used in balance assertion errors. showPostingLine p = lineIndent $ if pstatus p == Cleared then "* " else "" ++ -- XXX show ! showAccountName Nothing (ptype p) (paccount p) ++ " " ++ showMixedAmountOneLine (pamount p) ++ assertion where -- XXX extract, handle == assertion = maybe "" ((" = " ++) . showAmountWithZeroCommodity . baamount) $ pbalanceassertion pRender a posting, at the appropriate width for aligning with its siblings if any. Used by the rewrite command. hledger-libShow an account name, clipped to the given width if any, and appropriately bracketed/parenthesised for the given posting type. hledger-lib(Legacy form of transactionCheckBalanced. hledger-libBalance this transaction, ensuring that its postings (and its balanced virtual postings) sum to 0, by inferring a missing amount or conversion price(s) if needed. Or if balancing is not possible, because the amounts don't sum to 0 or because there's more than one missing amount, return an error message.Transactions with balance assignments can have more than one missing amount; to balance those you should use the more powerful journalBalanceTransactions.The "sum to 0" test is done using commodity display precisions, if provided, so that the result agrees with the numbers users can see. hledger-libHelper used by balanceTransaction and balanceTransactionWithBalanceAssignmentAndCheckAssertionsB; use one of those instead. It also returns a list of accounts and amounts that were inferred. hledger-libEnsure a transaction's postings refer back to it, so that eg relatedPostings works right. hledger-libEnsure a transaction's postings do not refer back to it, so that eg recursiveSize and GHCI's :sprint work right. hledger-lib9Apply a transform function to this transaction's amounts. hledger-libApply a specified costing and valuation to this transaction's amounts, using the provided price oracle, commodity styles, and reference dates. See amountApplyValuation and amountCost. hledger-libApply a specified valuation to this transaction's amounts, using the provided price oracle, commodity styles, and reference dates. See amountApplyValuation. hledger-libConvert this transaction's amounts to cost, and apply the appropriate amount styles. hledger-libApply some account aliases to all posting account names in the transaction, as described by accountNameApplyAliases. This can fail due to a bad replacement pattern in a regular expression alias. hledger-lib3Apply a transformation to a transaction's postings. hledger-lib:Apply a transformation to a transaction's posting amounts. hledger-lib5The file path from which this transaction was parsed. hledger-libcommodity display styles hledger-libcommodity display styles!!None &?r- hledger-libA query option changes a query's/report's behaviour and output in some way. hledger-lib1show an account register focussed on this account hledger-libas above but include sub-accounts in the account register | QueryOptCostBasis -- ^ show amounts converted to cost where possible | QueryOptDate2 -- ^ show secondary dates instead of primary dates hledger-libA more expressive Ord, used for amt: queries. The Abs* variants compare with the absolute value of a number, ignoring sign. hledger-libA query is a composition of search criteria, which can be used to match postings, transactions, accounts and more. hledger-lib always match hledger-lib never match hledger-libnegate this match hledger-libmatch if any of these match hledger-libmatch if all of these match hledger-lib!match if code matches this regexp hledger-lib(match if description matches this regexp hledger-lib0match postings whose account matches this regexp hledger-lib'match if primary date in this date span hledger-lib)match if secondary date in this date span hledger-lib$match txns/postings with this status hledger-libmatch if "realness" (involves a real non-virtual account ?) has this value hledger-lib3match if the amount's numeric quantity is less than greater than'equal to/unsignedly equal to some value hledger-lib>match if the entire commodity symbol is matched by this regexp hledger-libmatch if account depth is less than or equal to this value. Depth is sometimes used like a query (for filtering report data) and sometimes like a query option (for controlling display) hledger-libmatch if a tag's name, and optionally its value, is matched by these respective regexps matching the regexp if provided, exists hledger-libConstruct a payee tag hledger-libConstruct a note tag hledger-lib%Construct a generated-transaction tag hledger-libA version of parseQueryList which acts on a single Text of space-separated terms.The usual shell quoting rules are assumed. When a pattern contains whitespace, it (or the whole term including prefix) should be enclosed in single or double quotes.)parseQuery nulldate "expenses:dining out"Right (Or [Acct (RegexpCI "expenses:dining"),Acct (RegexpCI "out")],[])-parseQuery nulldate "\"expenses:dining out\""0Right (Acct (RegexpCI "expenses:dining out"),[]) hledger-libConvert a list of query expression containing to a query and zero or more query options; or return an error message if query parsing fails.A query term is either: :a search pattern, which matches on one or more fields, eg:acct:REGEXP - match the account name with a regular expression desc:REGEXP - match the transaction description date:PERIODEXP - match the date with a period expressionThe prefix indicates the field to match, or if there is no prefix account name is assumed. a query option, which modifies the reporting behaviour in some way. There is currently one of these, which may appear only once:inacct:FULLACCTNAMEPeriod expressions may contain relative dates, so a reference date is required to fully parse these.Multiple terms are combined as follows: 1. multiple account patterns are OR'd together 2. multiple description patterns are OR'd together 3. multiple status patterns are OR'd together 4. then all terms are AND'd together hledger-libQuote-and-prefix-aware version of words - don't split on spaces which are inside quotes, including quotes which may have one of the specified prefixes in front, and maybe an additional not: prefix in front of that. hledger-libRemove query terms (or whole sub-expressions) not matching the given predicate from this query. XXX Semantics not completely clear. hledger-lib"Does this query match everything ? hledger-libDoes this query specify a start date and nothing else (that would filter postings prior to the date) ? When the flag is true, look for a starting secondary date instead. hledger-libWhat start date (or secondary date) does this query specify, if any ? For OR expressions, use the earliest of the dates. NOT is ignored. hledger-libWhat end date (or secondary date) does this query specify, if any ? For OR expressions, use the latest of the dates. NOT is ignored. hledger-libWhat date span (or with a true argument, what secondary date span) does this query specify ? OR clauses specifying multiple spans return their union (the span enclosing all of them). AND clauses specifying multiple spans return their intersection. NOT clauses are ignored. hledger-libWhat date span does this query specify, treating primary and secondary dates as equivalent ? OR clauses specifying multiple spans return their union (the span enclosing all of them). AND clauses specifying multiple spans return their intersection. NOT clauses are ignored. hledger-lib3The depth limit this query specifies, if it has one hledger-libThe account we are currently focussed on, if any, and whether subaccounts are included. Just looks at the first query option. hledger-libA query for the account(s) we are currently focussed on, if any. Just looks at the first query option. hledger-libDoes the match expression match this account ? A matching in: clause is also considered a match. When matching by account name pattern, if there's a regular expression error, this function calls error. hledger-lib6Does the match expression match this (simple) amount ? hledger-lib.Does the match expression match this posting ?Note that for account match we try both original and effective account hledger-lib2Does the match expression match this transaction ? hledger-libDoes the query match this transaction description ? Tests desc: terms, any other terms are ignored. hledger-libDoes the query match this transaction payee ? Tests desc: (and payee: ?) terms, any other terms are ignored. XXX Currently an alias for matchDescription. I'm not sure if more is needed, There's some shenanigan with payee: and "payeeTag" to figure out. hledger-libDoes the query match the name and optionally the value of any of these tags ? hledger-lib(Does the query match this market price ?None %&t hledger-libApply all the given transaction modifiers, in turn, to each transaction. Or if any of them fails to be parsed, return the first error. A reference date is provided to help interpret relative dates in transaction modifier queries.None u hledger-libConvert time log entries to journal transactions. When there is no clockout, add one with the provided current time. Sessions crossing midnight are split into days to give accurate per-day totals.None #$e hledger-libGenerate transactions from  within a #Note that new transactions require  post-processing. The new transactions will have three tags added: - a recur:PERIODICEXPR tag whose value is the generating periodic expression - a generated-transaction: tag - a hidden _generated-transaction: tag which does not appear in the comment.  import Data.Time (fromGregorian)&_ptgen "monthly from 2017/1 to 2017/4" 2017-01-01< ; generated-transaction: ~ monthly from 2017/1 to 2017/4 a $1.00 2017-02-01< ; generated-transaction: ~ monthly from 2017/1 to 2017/4 a $1.00 2017-03-01< ; generated-transaction: ~ monthly from 2017/1 to 2017/4 a $1.00&_ptgen "monthly from 2017/1 to 2017/5" 2017-01-01< ; generated-transaction: ~ monthly from 2017/1 to 2017/5 a $1.00 2017-02-01< ; generated-transaction: ~ monthly from 2017/1 to 2017/5 a $1.00 2017-03-01< ; generated-transaction: ~ monthly from 2017/1 to 2017/5 a $1.00 2017-04-01< ; generated-transaction: ~ monthly from 2017/1 to 2017/5 a $1.007_ptgen "every 2nd day of month from 2017/02 to 2017/04" 2017-01-02 ; generated-transaction: ~ every 2nd day of month from 2017/02 to 2017/04 a $1.00 2017-02-02 ; generated-transaction: ~ every 2nd day of month from 2017/02 to 2017/04 a $1.00 2017-03-02 ; generated-transaction: ~ every 2nd day of month from 2017/02 to 2017/04 a $1.006_ptgen "every 30th day of month from 2017/1 to 2017/5" 2016-12-30 ; generated-transaction: ~ every 30th day of month from 2017/1 to 2017/5 a $1.00 2017-01-30 ; generated-transaction: ~ every 30th day of month from 2017/1 to 2017/5 a $1.00 2017-02-28 ; generated-transaction: ~ every 30th day of month from 2017/1 to 2017/5 a $1.00 2017-03-30 ; generated-transaction: ~ every 30th day of month from 2017/1 to 2017/5 a $1.00 2017-04-30 ; generated-transaction: ~ every 30th day of month from 2017/1 to 2017/5 a $1.00:_ptgen "every 2nd Thursday of month from 2017/1 to 2017/4" 2016-12-08 ; generated-transaction: ~ every 2nd Thursday of month from 2017/1 to 2017/4 a $1.00 2017-01-12 ; generated-transaction: ~ every 2nd Thursday of month from 2017/1 to 2017/4 a $1.00 2017-02-09 ; generated-transaction: ~ every 2nd Thursday of month from 2017/1 to 2017/4 a $1.00 2017-03-09 ; generated-transaction: ~ every 2nd Thursday of month from 2017/1 to 2017/4 a $1.00)_ptgen "every nov 29th from 2017 to 2019" 2016-11-29? ; generated-transaction: ~ every nov 29th from 2017 to 2019 a $1.00 2017-11-29? ; generated-transaction: ~ every nov 29th from 2017 to 2019 a $1.00 2018-11-29? ; generated-transaction: ~ every nov 29th from 2017 to 2019 a $1.00_ptgen "2017/1" 2017-01-01% ; generated-transaction: ~ 2017/1 a $1.00 _ptgen ""!*** Exception: failed to parse......_ptgen "weekly from 2017"*** Exception: Unable to generate transactions according to "weekly from 2017" because 2017-01-01 is not a first day of the Week_ptgen "monthly from 2017/5/4"*** Exception: Unable to generate transactions according to "monthly from 2017/5/4" because 2017-05-04 is not a first day of the Month$_ptgen "every quarter from 2017/1/2"*** Exception: Unable to generate transactions according to "every quarter from 2017/1/2" because 2017-01-02 is not a first day of the Quarter_ptgen "yearly from 2017/1/14"*** Exception: Unable to generate transactions according to "yearly from 2017/1/14" because 2017-01-14 is not a first day of the Yearlet reportperiod="daily from 2018/01/03" in let (i,s) = parsePeriodExpr' nulldate reportperiod in runPeriodicTransaction (nullperiodictransaction{ptperiodexpr=reportperiod, ptspan=s, ptinterval=i, ptpostings=["a" `post` usd 1]}) (DateSpan (Just $ fromGregorian 2018 01 01) (Just $ fromGregorian 2018 01 03))[]_ptgenspan "every 3 months from 2019-05" (DateSpan (Just $ fromGregorian 2020 01 01) (Just $ fromGregorian 2020 02 01))_ptgenspan "every 3 months from 2019-05" (DateSpan (Just $ fromGregorian 2020 02 01) (Just $ fromGregorian 2020 03 01)) 2020-02-01: ; generated-transaction: ~ every 3 months from 2019-05 a $1.00_ptgenspan "every 3 days from 2018" (DateSpan (Just $ fromGregorian 2018 01 01) (Just $ fromGregorian 2018 01 05)) 2018-01-015 ; generated-transaction: ~ every 3 days from 2018 a $1.00 2018-01-045 ; generated-transaction: ~ every 3 days from 2018 a $1.00_ptgenspan "every 3 days from 2018" (DateSpan (Just $ fromGregorian 2018 01 02) (Just $ fromGregorian 2018 01 05)) 2018-01-045 ; generated-transaction: ~ every 3 days from 2018 a $1.00 hledger-libCheck that this date span begins at a boundary of this interval, or return an explanatory error message including the provided period expression (from which the span and interval are derived).None  %22 hledger-libGet the transaction with this index (its 1-based position in the input stream), if any. hledger-libGet the transaction that appeared immediately after this one in the input stream, if any. hledger-libGet the transaction that appeared immediately before this one in the input stream, if any. hledger-lib8All postings from this journal's transactions, in order. hledger-libSorted unique commodity symbols declared by commodity directives in this journal. hledger-lib5Unique transaction descriptions used in this journal. hledger-libSorted unique payees declared by payee directives in this journal. hledger-lib:Sorted unique payees used by transactions in this journal. hledger-libSorted unique payees used in transactions or declared by payee directives in this journal. hledger-libSorted unique account names posted to by this journal's transactions. hledger-libSorted unique account names implied by this journal's transactions - accounts posted to and all their implied parent accounts. hledger-libSorted unique account names declared by account directives in this journal. hledger-libSorted unique account names declared by account directives or posted to by transactions in this journal. hledger-libSorted unique account names declared by account directives, or posted to or implied as parents by transactions in this journal.  hledger-libConvenience/compatibility alias for journalAccountNamesDeclaredOrImplied.  hledger-libFind up to N most similar and most recent transactions matching the given transaction description and query. Transactions are listed with their description's similarity score (see compareDescriptions), sorted by highest score and then by date. Only transactions with a similarity score greater than a minimum threshold (currently 0) are returned.  hledger-libA query for accounts in this journal which have been declared as Asset (or Cash, a subtype of Asset) by account directives, or otherwise for accounts with names matched by the case-insensitive regular expression  ^assets?(:|$).  hledger-libA query for Cash (liquid asset) accounts in this journal, ie accounts declared as Cash by account directives, or otherwise Asset accounts whose names do not include the case-insensitive regular expression #(investment|receivable|:A/R|:fixed).  hledger-libA query for accounts in this journal which have been declared as Liability by account directives, or otherwise for accounts with names matched by the case-insensitive regular expression ^(debts?|liabilit(y|ies))(:|$).  hledger-libA query for accounts in this journal which have been declared as Equity by account directives, or otherwise for accounts with names matched by the case-insensitive regular expression  ^equity(:|$).  hledger-libA query for accounts in this journal which have been declared as Revenue by account directives, or otherwise for accounts with names matched by the case-insensitive regular expression ^(income|revenue)s?(:|$).  hledger-libA query for accounts in this journal which have been declared as Expense by account directives, or otherwise for accounts with names matched by the case-insensitive regular expression ^expenses?(:|$).  hledger-libA query for Asset, Liability & Equity accounts in this journal. Cf  http://en.wikipedia.org/wiki/Chart_of_accounts#Balance_Sheet_Accounts.  hledger-lib8A query for Profit & Loss accounts in this journal. Cf  http://en.wikipedia.org/wiki/Chart_of_accounts#Profit_.26_Loss_accounts.  hledger-lib5Keep only transactions matching the query expression.  hledger-libKeep only postings matching the query expression. This can leave unbalanced transactions.  hledger-libWithin each posting's amount, keep only the parts matching the query. This can leave unbalanced transactions.  hledger-libFilter out all parts of this transaction's amounts which do not match the query. This can leave the transaction unbalanced.  hledger-libFilter out all parts of this posting's amount which do not match the query.  hledger-lib3Apply a transformation to a journal's transactions.  hledger-lib/Apply a transformation to a journal's postings.  hledger-lib6Apply a transformation to a journal's posting amounts.  hledger-libReverse all lists of parsed items, which during parsing were prepended to, so that the items are in parse order. Part of post-parse finalisation.  hledger-libSet this journal's last read time, ie when its files were last read.  hledger-libUntie all transaction-posting knots in this journal, so that eg recursiveSize and GHCI's :sprint can work on it.  hledger-libApply any transaction modifier rules in the journal (adding automated postings to transactions, eg). Or if a modifier rule fails to parse, return the error message. A reference date is provided to help interpret relative dates in transaction modifier queries.  hledger-libCheck any balance assertions in the journal and return an error message if any of them fail (or if the transaction balancing they require fails).  hledger-libInfer any missing amounts (to satisfy balance assignments and to balance transactions) and check that all transactions balance and (optional) all balance assertions pass. Or return an error message (just the first error encountered).Assumes journalInferCommodityStyles has been called, since those affect transaction balancing.This does multiple things at once because amount inferring, balance assignments, balance assertions and posting dates are interdependent.  hledger-libChoose and apply a consistent display style to the posting amounts in each commodity (see journalCommodityStyles). Can return an error message eg if inconsistent number formats are found.  hledger-libGet the canonical amount styles for this journal, whether (in order of precedence): set globally in InputOpts, declared by commodity directives, declared by a default commodity (D) directive, or inferred from posting amounts, as a map from symbol to style. Styles from directives are assumed to specify the decimal mark.  hledger-libGiven a list of amounts, in parse order (roughly speaking; see journalStyleInfluencingAmounts), build a map from their commodity names to standard commodity display formats. Can return an error message eg if inconsistent number formats are found.Though, these amounts may have come from multiple files, so we shouldn't assume they use consistent number formats. Currently we don't enforce that even within a single file, and this function never reports an error.  hledger-libGiven a list of amount styles (assumed to be from parsed amounts in a single commodity), in parse order, choose a canonical style.  hledger-libInfer transaction-implied market prices from commodity-exchanging transactions, if any. It's best to call this after transactions have been balanced and posting amounts have appropriate prices attached.  hledger-libConvert all this journal's amounts to cost using the transaction prices, if any. The journal's commodity styles are applied to the resulting amounts.  hledger-libGet an ordered list of s from the amounts in this journal which influence canonical amount display styles. See traverseJournalAmounts. journalAmounts :: Journal -> [Amount] journalAmounts = getConst . traverseJournalAmounts (Const . (:[]))| Apply a transformation to the journal amounts traversed by traverseJournalAmounts. overJournalAmounts :: (Amount -> Amount) -> Journal -> Journal overJournalAmounts f = runIdentity . traverseJournalAmounts (Identity . f)| A helper that traverses over most amounts in the journal, in particular the ones which influence canonical amount display styles, processing them with the given applicative function.&These include, in the following order:7the amount in the final default commodity (D) directive7amounts in market price (P) directives (in parse order)0posting amounts in transactions (in parse order)Transaction price amounts, which may be embedded in posting amounts (the aprice field), are left intact but not traversed/processed.traverseJournalAmounts :: Applicative f => (Amount -> f Amount) -> Journal -> f Journal traverseJournalAmounts f j = recombine  $> (traverse . dcamt) f (jparsedefaultcommodity j)  *8 (traverse . pdamt) f (jpricedirectives j)  * (traverse . tps . traverse . pamt . amts . traverse) f (jtxns j) where recombine pds txns = j { jpricedirectives = pds, jtxns = txns } -- a bunch of traversals dcamt g pd = (mdc -> case mdc of Nothing -> Nothing Just ((c,stpd{pdamount =amt} )  $ g (pdamount pd) pdamt g pd = (amt -> pd{pdamount =amt})  $ g (pdamount pd) tps g t = (ps -> t {tpostings=ps })  $ g (tpostings t) pamt g p = (amt -> p {pamount =amt})  $/ g (pamount p) amts g (Mixed as) = Mixed  $ g asThe fully specified date span enclosing the dates (primary or secondary) of all this journal's transactions and postings, or DateSpan Nothing Nothing if there are none.  hledger-libThe fully specified date span enclosing the dates (primary and secondary) of all this journal's transactions and postings, or DateSpan Nothing Nothing if there are none.  hledger-libThe earliest of this journal's transaction and posting dates, or Nothing if there are none.  hledger-libThe latest of this journal's transaction and posting dates, or Nothing if there are none.  hledger-libApply the pivot transformation to all postings in a journal, replacing their account name by their value for the given field or tag.  hledger-libApply some account aliases to all posting account names in the journal, as described by accountNameApplyAliases. This can fail due to a bad replacement pattern in a regular expression alias.= =     None #$  hledger-libDerive 1. an account tree and 2. each account's total exclusive and inclusive changes from a list of postings. This is the core of the balance command (and of *ledger). The accounts are returned as a list in flattened tree order, and also reference each other as a tree. (The first account is the root of the tree.)  hledger-libConvert a list of account names to a tree of Account objects, with just the account names filled in. A single root account with the given name is added.  hledger-lib;Tie the knot so all subaccounts' parents are set correctly.  hledger-libGet this account's parent accounts, from the nearest up to the root.  hledger-lib4List the accounts at each level of the account tree.  hledger-libMap a (non-tree-structure-modifying) function over this and sub accounts.  hledger-libIs the predicate true on any of this account or its subaccounts ?  hledger-lib5Add subaccount-inclusive balances to an account tree.  hledger-lib-Remove all subaccounts below a certain depth.  hledger-libRemove subaccounts below the specified depth, aggregating their balance at the depth limit (accounts at the depth limit will have any sub-balances merged into their exclusive balance). If the depth is Nothing, return the original accounts  hledger-lib;Remove all leaf accounts and subtrees matching a predicate.  hledger-libFlatten an account tree into a list, which is sometimes convenient. Note since accounts link to their parents/subs, the tree's structure remains intact and can still be used. It's a tree/list!  hledger-lib#Filter an account tree (to a list).  hledger-libSort each group of siblings in an account tree by inclusive amount, so that the accounts with largest normal balances are listed first. The provided normal balance sign determines whether normal balances are negative or positive, affecting the sort order. Ie, if balances are normally negative, then the most negative balances sort first, and vice versa.  hledger-libAdd extra info for this account derived from the Journal's account directives, if any (comment, tags, declaration order..).  hledger-libSort account names by the order in which they were declared in the journal, at each level of the account tree (ie within each group of siblings). Undeclared accounts are sorted last and alphabetically. This is hledger's default sort for reports organised by account. The account list is converted to a tree temporarily, adding any missing parents; these can be kept (suitable for a tree-mode report) or removed (suitable for a flat-mode report).  hledger-libSort each group of siblings in an account tree by declaration order, then account name. So each group will contain first the declared accounts, in the same order as their account directives were parsed, and then the undeclared accounts, sorted by account name.  hledger-libSearch an account list by name.  None Ć  hledger-libFilter a journal's transactions with the given query, then build a Ledger, containing the journal plus the tree of all its accounts with their subaccount-inclusive and subaccount-exclusive balances. If the query includes a depth limit, the ledger's journal will be depth limited, but the ledger's account tree will not.  hledger-libList a ledger's account names.  hledger-lib$Get the named account from a ledger.  hledger-libGet this ledger's root account, which is a dummy "root" account above all others. This should always be first in the account list, if somehow not this returns a null account.  hledger-libList a ledger's top-level accounts (the ones below the root), in tree order.  hledger-libList a ledger's bottom-level (subaccount-less) accounts, in tree order.  hledger-lib.List a ledger's postings, in the order parsed.  hledger-libThe (fully specified) date span containing all the ledger's (filtered) transactions, or DateSpan Nothing Nothing if there are none.  hledger-lib$All commodities used in this ledger. None EFGHIJKLMUTSRQPNOVWZXY[\]^_`abwvutsrqponmlkjihgfecdxy}|z{~  None #$܅&  hledger-libThe result of successfully parsing a ReportOpts on a particular Day. Any ambiguous dates are completed and Queries are parsed, ensuring that there are no regular expression errors. Values here should be used in preference to re-deriving them from ReportOpts. If you change the query_ in ReportOpts, you should call  2 to regenerate the ReportSpec with the new Query.  hledger-lib:The underlying ReportOpts used to generate this ReportSpec  hledger-lib(The Day this ReportSpec is generated for  hledger-lib%The generated Query for the given day  hledger-lib%A list of QueryOpts for the given day  hledger-libStandard options for customising report filtering and output. Most of these correspond to standard hledger command-line options or query arguments, but not all. Some are used only by certain commands, as noted below.  hledger-lib(Zero, one, or two statuses to be matched  hledger-lib0Should we convert amounts to cost, when present?  hledger-lib+What value should amounts be converted to ?  hledger-lib'Infer market prices from transactions ?  hledger-lib)if true, flip all amount signs in reports  hledger-libThis can be set when running balance reports on a set of accounts with the same normal balance type (eg all assets, or all incomes). - It helps --sort-amount know how to sort negative numbers (eg in the income section of an income statement) - It helps compound balance report commands (is, bs etc.) do sign normalisation, converting normally negative subreports to normally positive for a more conventional display.  hledger-libWhether to use ANSI color codes in text output. Influenced by the --color/colour flag (cf CliOptions), whether stdout is an interactive terminal, and the value of TERM and existence of NO_COLOR environment variables.  hledger-libShould accounts be displayed: in the command's default style, hierarchically, or as a flat list ?  hledger-lib?Which "accumulation method" is being shown in a balance report.  hledger-lib+The accumulate change over a single period.  hledger-lib/The accumulated change across multiple periods.  hledger-libThe historical ending balance, including the effect of all postings before the report period. Unless altered by, a query, this is what you would see on a bank statement.  hledger-lib>What is calculated and shown in each cell in a balance report.  hledger-libThe sum of posting amounts.  hledger-lib(The sum of posting amounts and the goal.  hledger-lib4The change of value of period-end historical values.  hledger-lib>Generate a ReportSpec from a set of ReportOpts on a given day.  hledger-libUpdate the ReportOpts and the fields derived from it in a ReportSpec, or return an error message if there is a problem such as missing or unparseable options data. This is the safe way to change a ReportSpec, ensuring that all fields (rsQuery, rsOpts, querystring_, etc.) are in sync.  hledger-libLike updateReportSpec, but takes a ReportOpts-modifying function.  hledger-lib8Generate a ReportSpec from RawOpts and the current date.  hledger-libGet the report interval, if any, specified by the last of -p/--period, -D --daily, -W--weekly, -M/--monthly etc. options. An interval from --period counts only if it is explicitly defined.  hledger-lib,get period expression from --forecast option  hledger-libReduce a list of statuses to just one of each status, and if all statuses are present return the empty list.  hledger-libAdd/remove this status from the status list. Used by hledger-ui.  hledger-lib6Select the Transaction date accessor based on --date2.  hledger-lib2Select the Posting date accessor based on --date2.  hledger-lib5Report which date we will report on based on --date2.  hledger-lib;Legacy-compatible convenience aliases for accountlistmode_.  hledger-libConvert this journal's postings' amounts to cost using their transaction prices, if specified by options (-B/--cost). Maybe soon superseded by newer valuation code.  hledger-libConvert report options to a query, ignoring any non-flag command line arguments.  hledger-libThe effective report span is the start and end dates specified by options or queries, or otherwise the earliest and latest transaction or posting dates in the journal. If no dates are specified by options/queries and the journal is empty, returns the null date span. The boolean argument flags whether primary and secondary dates are considered equivalently.  hledger-libLike reportSpan, but uses both primary and secondary dates when calculating the span.  !None58:p  hledger-lib4A full name, display name, and depth for an account.  hledger-libDescription of one subreport within a compound balance report. Part of a CompoundBalanceCommandSpec, but also used in hledger-lib.  hledger-lib"The title to use for the subreport  hledger-lib"The Query to use for the subreport  hledger-libA function to transform the ReportOpts used to produce the subreport  hledger-lib3A function to transform the result of the subreport  hledger-libWhether the subreport and overall report total are of the same sign (e.g. Assets are normally positive in a balance sheet report, as is the overall total. Liabilities are normally of the opposite sign.)  hledger-libA compound balance report has:an overall title%the period (date span) of each columnone or more named, normal-positive multi balance reports, with columns corresponding to the above, and a flag indicating whether they increased or decreased the overall totalsa list of overall totals for each column, and their grand total and averageIt is used in compound balance report commands like balancesheet, cashflow and incomestatement.  hledger-libA periodic report is a generic tabular report, where each row corresponds to some label (usually an account name) and each column to a date period. The column periods are usually consecutive subperiods formed by splitting the overall report period by some report interval (daily, weekly, etc.). It has: *a list of each column's period (date span) a list of rows, each containing:an account labelthe account's depthA list of amounts, one for each column. Depending on the value type, these can represent balance changes, ending balances, budget performance, etc. (for example, see  BalanceType and Hledger.Cli.Commands.Balance).the total of the row's amounts for a periodic report, or zero for cumulative/historical reports (since summing end balances generally doesn't make sense). the average of the row's amounts the column totals, and the overall grand total (or zero for cumulative/historical reports) and grand average.  hledger-lib4Figure out the overall date span of a PeriodicReport  hledger-lib"Map a function over the row names.  hledger-libT  hledger-libA postings report is a list of postings with a running total, and a little extra transaction info to help with rendering. This is used eg for the register command.  hledger-libSelect postings from the journal and add running balance and other information to make a postings report. Used by eg hledger's register command.  hledger-libGenerate one postings report line item, containing the posting, the current running balance, and optionally the posting date and/or the transaction description.  #None #$>  hledger-libA journal entries report is a list of whole transactions as originally entered in the journal (mostly). This is used by eg hledger's print command and hledger-web's journal entries view.  hledger-lib*Select transactions for an entries report.  $None #$>7  hledger-libAn account transactions report represents transactions affecting a particular account (or possibly several accounts, but we don't use that). It is used eg by hledger-ui's and hledger-web's register view, and hledger's aregister report, where we want to show one row per transaction, in the context of the current account. Report items consist of:the transaction, unmodifiedthe transaction as seen in the context of the current account and query, which means:the transaction date is set to the "transaction context date", which can be different from the transaction's general date: if postings to the current account (and matched by the report query) have their own dates, it's the earliest of these dates.the transaction's postings are filtered, excluding any which are not matched by the report query9a text description of the other account(s) posted to/froma flag indicating whether there's more than one other account involved2the total increase/decrease to the current accountthe report transactions' running total after this transaction; or if historical balance is requested (-H), the historical running total. The historical running total includes transactions from before the report start date if one is specified, filtered by the report query. The historical running total may or may not be the account's historical running balance, depending on the report query.Items are sorted by transaction register date (the earliest date the transaction posts to the current account), most recent first. Reporting intervals are currently ignored.  hledger-libGenerate transactions report items from a list of transactions, using the provided user-specified report query, a query specifying which account to use as the focus, a starting balance, a sign-setting function and a balance-summing function. Or with a None current account query, this can also be used for the transactionsReport.  hledger-libWhat is the transaction's date in the context of a particular account (specified with a query) and report query, as in an account register ? It's normally the transaction's general date, but if any posting(s) matched by the report query and affecting the matched account(s) have their own earlier dates, it's the earliest of these dates. Secondary transaction/posting dates are ignored.  %None #$>  hledger-libA transactions report includes a list of transactions touching multiple accounts (posting-filtered and unfiltered variants), a running balance, and some other information helpful for rendering a register view with or without a notion of current account(s). Two kinds of report use this data structure, see transactionsReport and accountTransactionsReport below for details.  hledger-libSelect transactions from the whole journal. This is similar to a "postingsReport" except with transaction-based report items which are ordered most recent first. XXX Or an EntriesReport - use that instead ? This is used by hledger-web's journal view.  hledger-libSplit a transactions report whose items may involve several commodities, into one or more single-commodity transactions reports. &None #$%?0_1  hledger-libVarious options to use when reading journal files. Similar to CliOptions.inputflags, simplifies the journal-reading functions.  hledger-liba file/storage format to try, unless overridden by a filename prefix. Nothing means try all.  hledger-lib1a conversion rules file to use (when reading CSV)  hledger-libaccount name aliases to apply  hledger-lib.do light anonymisation/obfuscation of the data  hledger-libdon't check balance assertions  hledger-lib8read only new transactions since this file was last read  hledger-lib0save latest new transactions state for next time  hledger-lib/use the given field's value as the account name  hledger-lib2generate automatic postings when journal is parsed  hledger-lib5optional commodity display styles affecting all files  hledger-lib>do extra error checking (eg, all posted accounts are declared)  hledger-libA hledger journal reader is a triple of storage format name, a detector of that format, and a parser from that format to Journal. The type variable m appears here so that rParserr can hold a journal parser, which depends on it.  hledger-libRun a text parser in the identity monad. See also: parseWithState.  hledger-libRun a text parser in the identity monad. See also: parseWithState.  hledger-lib=Run a journal parser in some monad. See also: parseWithState.  hledger-lib=Run a journal parser in some monad. See also: parseWithState.  hledger-libRun an erroring journal parser in some monad. See also: parseWithState.  hledger-libRun an erroring journal parser in some monad. See also: parseWithState.  hledger-libConstruct a generic start & end line parse position from start and end megaparsec SourcePos's.  hledger-libGiven a parser to ParsedJournal, input options, file path and content: run the parser on the content, and finalise the result to get a Journal; or throw an error.  hledger-libLike parseAndFinaliseJournal but takes a (non-Erroring) JournalParser. Also, applies command-line account aliases before finalising. Used for timeclock/timedot. TODO: get rid of this, use parseAndFinaliseJournal instead  hledger-libPost-process a Journal that has just been parsed or generated, in this order:apply canonical amount styles,save misc info and reverse transactions into their original parse order,:evaluate balance assignments and balance each transaction,7apply transaction modifiers (auto postings) if enabled,$check balance assertions if enabled.?infer transaction-implied market prices from transaction prices  hledger-libCheck that all the journal's transactions have payees declared with payee directives, returning an error message otherwise.  hledger-libCheck that all the journal's postings are to accounts declared with account directives, returning an error message otherwise.  hledger-libCheck that all the commodities used in this journal's postings have been declared by commodity directives, returning an error message otherwise.  hledger-lib2Get amount style associated with default currency.Returns  used to defined by a latest default commodity directive prior to current position within this file or its parents.  hledger-libGet the  declared by the most recently parsed (in the current or parent files, prior to the current position) commodity directive for the given commodity, if any.  hledger-libParse a date in YYYY-MM-DD format. Slash (/) and period (.) are also allowed as separators. The year may be omitted if a default year has been set. Leading zeroes may be omitted.  hledger-libParse a date and time in YYYY-MM-DD HH:MM[:SS][+-ZZZZ] format. Slash (/) and period (.) are also allowed as date separators. The year may be omitted if a default year has been set. Seconds are optional. The timezone is optional and ignored (the time is always interpreted as a local time). Leading zeroes may be omitted (except in a timezone).  hledger-libParse an account name (plus one following space if present), then apply any parent account prefix and/or account aliases currently in effect, in that order. (Ie first add the parent account prefix, then rewrite with aliases). This calls error if any account alias with an invalid regular expression exists.  hledger-libParse an account name, plus one following space if present. Account names have one or more parts separated by the account separator character, and are terminated by two or more spaces (or end of input). Each part is at least one character long, may have single spaces inside it, and starts with a non-whitespace. Note, this means "{account}", "%^!" and ";comment" are all accepted (parent parsers usually prevent/consume the last). It should have required parts to start with an alphanumeric; for now it remains as-is for backwards compatibility.  hledger-libParse any text beginning with a non-whitespace character, until a double space or the end of input. TODO including characters which normally start a comment (;#) - exclude those ?  hledger-lib Similar to  , except that the text must only contain characters satisfying the given predicate.  hledger-libParse one non-newline whitespace character that is not followed by another one.  hledger-libParse whitespace then an amount, with an optional left or right currency symbol and optional price, or return the special "missing" marker amount.  hledger-libParse a single-commodity amount, with optional symbol on the left or right, followed by, in any order: an optional transaction price, an optional ledger-style lot price, and/or an optional ledger-style lot date. A lot price and lot date will be ignored.To parse the amount's quantity (number) we need to know which character represents a decimal mark. We find it in one of three ways: If a decimal mark has been set explicitly in the journal parse state, we use thatOr if the journal has a commodity declaration for the amount's commodity, we get the decimal mark from thatOtherwise we will parse any valid decimal mark appearing in the number, as long as the number appears well formed.Note 3 is the default zero-config case; it means we automatically handle files with any supported decimal mark, but it also allows different decimal marks in different amounts, which is a bit too loose. There's an open issue.  hledger-lib/Parse an amount from a string, or get an error.  hledger-lib4Parse a mixed amount from a string, or get an error.  hledger-libParse a string representation of a number for its value and display attributes.Some international number formats are accepted, eg either period or comma may be used for the decimal mark, and the other of these may be used for separating digit groups in the integer part. See  .http://en.wikipedia.org/wiki/Decimal_separator for more examples.This returns: the parsed numeric value, the precision (number of digits seen following the decimal mark), the decimal mark character used if any, and the digit group style if any.  hledger-lib+Interpret a raw number as a decimal number.Returns: - the decimal number - the precision (number of digits after the decimal point) - the decimal point character, if any - the digit group style, if any (digit group character and sizes of digit groups)  hledger-libParse and interpret the structure of a number without external hints. Numbers are digit strings, possibly separated into digit groups by one of two types of separators. (1) Numbers may optionally have a decimal mark, which may be either a period or comma. (2) Numbers may optionally contain digit group marks, which must all be either a period, a comma, or a space.It is our task to deduce the characters used as decimal mark and digit group mark, based on the allowed syntax. For instance, we make use of the fact that a decimal mark can occur at most once and must be to the right of all digit group marks.#parseTest rawnumberp "1,234,567.89">Right (WithSeparators ',' ["1","234","567"] (Just ('.',"89")))parseTest rawnumberp "1,000"$Left (AmbiguousNumber "1" ',' "000")parseTest rawnumberp "1 000".Right (WithSeparators ' ' ["1","000"] Nothing)  hledger-libA blank or comment line in journal format: a line that's empty or containing only whitespace or whose first non-whitespace character is semicolon, hash, or star.  hledger-libParse the text of a (possibly multiline) comment following a journal item.(rtp followingcommentp "" -- no commentRight ""rtp followingcommentp ";" -- just a (empty) same-line comment. newline is added Right "\n"rtp followingcommentp "; \n" Right "\n"rtp followingcommentp ";\n ;\n" -- a same-line and a next-line comment Right "\n\n"rtp followingcommentp "\n ;\n" -- just a next-line comment. Insert an empty same-line comment so the next-line comment doesn't become a same-line comment. Right "\n\n"  hledger-lib1Parse a transaction comment and extract its tags.The first line of a transaction may be followed by comments, which begin with semicolons and extend to the end of the line. Transaction comments may span multiple lines, but comment lines below the transaction must be preceded by leading whitespace.200011 ; a transaction comment starting on the same line ... ; extending to the next line account1 $1 account2Tags are name-value pairs.let getTags (_,tags) = tags6let parseTags = fmap getTags . rtp transactioncommentp3parseTags "; name1: val1, name2:all this is value2"7Right [("name1","val1"),("name2","all this is value2")]A tag's name must be immediately followed by a colon, without separating whitespace. The corresponding value consists of all the text following the colon up until the next colon or newline, stripped of leading and trailing whitespace.  hledger-lib7Parse a posting comment and extract its tags and dates.Postings may be followed by comments, which begin with semicolons and extend to the end of the line. Posting comments may span multiple lines, but comment lines below the posting must be preceded by leading whitespace.200011 account1 $1 ; a posting comment starting on the same line ... ; extending to the next line:account2 ; a posting comment beginning on the next lineTags are name-value pairs.let getTags (_,tags,_,_) = tags>> rtp (postingcommentp (Just 2000)) "; a:b, date:34, [=56]" Right ("a:b, date:34, [=56]n",[("a","b"),("date","3/4")],Just 2000-03-04,Just 2000-05-06)Example: extraction of dates from date tags ignores trailing text >>> rtp (postingcommentp (Just 2000)) "; date:34=56" Right ("date:34=56n",[("date","34=56")],Just 2000-03-04,Nothing)  hledger-libParse Ledger-style bracketed posting dates ([DATE=DATE2]), as "date" and/or "date2" tags. Anything that looks like an attempt at this (a square-bracketed sequence of 0123456789/-.= containing at least one digit and one date separator) is also parsed, and will throw an appropriate error.The dates are parsed in full here so that errors are reported in the right position. A missing year in DATE can be inferred if a default date is provided. A missing year in DATE2 will be inferred from DATE.either (Left . customErrorBundlePretty) Right $ rtp (bracketeddatetagsp Nothing) "[2016/1/2=3/4]"0Right [("date",2016-01-02),("date2",2016-03-04)]either (Left . customErrorBundlePretty) Right $ rtp (bracketeddatetagsp Nothing) "[1]"Left ...not a bracketed date...either (Left . customErrorBundlePretty) Right $ rtp (bracketeddatetagsp Nothing) "[2016/1/32]"9Left ...1:2:...well-formed but invalid date: 2016/1/32...either (Left . customErrorBundlePretty) Right $ rtp (bracketeddatetagsp Nothing) "[1/31]"Left ...1:2:...partial date 1/31 found, but the current year is unknown...either (Left . customErrorBundlePretty) Right $ rtp (bracketeddatetagsp Nothing) "[0123456789/-.=/-.=]")Left ...1:13:...expecting month or day...  hledger-lib2Get the account name aliases from options, if any.  hledger-libA custom show instance, showing digit groups as the parser saw them.  'None 1  (None 1  )None #$%&>?3  hledger-libAn pure-exception-throwing IO action that parses this file's content as CSV conversion rules, interpolating any included files first, and runs some extra validation checks.  hledger-libGiven a CSV file path, what would normally be the corresponding rules file ?  hledger-libGiven a CSV rules file path, what would normally be the corresponding CSV file ? *None  #$%?7   hledger-lib findReader mformat mpathFind the reader named by mformat, if provided. Or, if a file path is provided, find the first reader that handles its file extension, if any.  hledger-libIf a filepath is prefixed by one of the reader names and a colon, split that off. Eg "csv:-" -> (Just "csv", "-").  hledger-lib,A journal parser. Accumulates and returns a  ParsedJournal2, which should be finalised/validated before use.*rejp (journalp <* eof) "2015/1/1\n a 0\n"6Right (Right Journal with 1 transactions, 1 accounts)  hledger-libParse any journal directive and update the parse state accordingly. Cf  )http://hledger.org/manual.html#directives, =http://ledger-cli.org/3.0/doc/ledger3.html#Command-Directives  +None A  hledger-libA file path optionally prefixed by a reader name and colon (journal:, csv:, timedot:, etc.).  hledger-libRead a Journal from the given text, assuming journal format; or throw an error.  hledger-lib readJournal iopts mfile txt:Read a Journal from some text, or return an error message.;The reader (data format) is chosen based on, in this order:a reader name provided in ioptsa reader prefix in the mfile patha file extension in mfileIf none of these is available, or if the reader name is unrecognised, we use the journal reader. (We used to try all readers in this case; since hledger 1.17, we prefer predictability.)  hledger-libRead the default journal file specified by the environment, or raise an error.  hledger-libGet the default journal file path specified by the environment. Like ledger, we look first for the LEDGER_FILE environment variable, and if that does not exist, for the legacy LEDGER environment variable. If neither is set, or the value is blank, return the hard-coded default, which is .hledger.journal in the users's home directory (or in the current directory, if we cannot determine a home directory).  hledger-libRead a Journal from each specified file path and combine them into one. Or, return the first error message.Combining Journals means concatenating them, basically. The parse state resets at the start of each file, which means that directives & aliases do not affect subsequent sibling or parent files. They do affect included child files though. Also the final parse state saved in the Journal does span all files.  hledger-libRead a Journal from this file, or from stdin if the file path is -, or return an error message. The file path can have a READER: prefix.The reader (data format) to use is determined from (in priority order): the mformat_ specified in the input options, if any; the file path's READER: prefix, if any; a recognised file name extension. if none of these identify a known reader, the journal reader is used.The input options can also configure balance assertion checking, automated posting generation, a rules file for converting CSV data, etc.  hledger-libIf the specified journal file does not exist (and is not "-"), give a helpful error and quit.  hledger-libEnsure there is a journal file at the given path, creating an empty one if needed. On Windows, also ensure that the path contains no trailing dots which could cause data loss (see  ). ,None #$>M|  hledger-libA multi balance report is a kind of periodic report, where the amounts correspond to balance changes or ending balances in a given period. It has: *a list of each column's period (date span) a list of rows, each containing:6the full account name, display name, and display depth'A list of amounts, one for each column.4the total of the row's amounts for a periodic report the average of the row's amounts the column totals, and the overall grand total (or zero for cumulative/historical reports) and grand average.  hledger-libGenerate a multicolumn balance report for the matched accounts, showing the change of balance, accumulated balance, or historical balance in each of the specified periods. If the normalbalance_ option is set, it adjusts the sorting and sign of amounts (see ReportOpts and CompoundBalanceCommand). hledger's most powerful and useful report, used by the balance command (in multiperiod mode) and (via compoundBalanceReport) by the bscf is commands.  hledger-libA helper for multiBalanceReport. This one takes an extra argument, a PriceOracle to be used for looking up market prices. Commands which run multiple reports (bs etc.) can generate the price oracle just once for efficiency, passing it to each report by calling this function directly.  hledger-libGenerate a compound balance report from a list of CBCSubreportSpec. This shares postings between the subreports.  hledger-libA helper for compoundBalanceReport, similar to multiBalanceReportWith.  hledger-lib-Calculate starting balances, if needed for -HBalances at report start date, from all earlier postings which otherwise match the query. These balances are unvalued. TODO: Do we want to check whether to bother calculating these? isHistorical and startDate is not nothing, otherwise mempty? This currently gives a failure with some totals which are supposed to be 0 being blank.  hledger-libRemove any date queries and insert queries from the report span. The user's query expanded to the report span if there is one (otherwise any date queries are left as-is, which handles the hledger-ui+future txns case above).  hledger-lib'Group postings, grouped by their column  hledger-lib