h$r.       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! " " " " # # # # # # # # # # # # $ $ $ $ $ % % % % % % % % % % % % % & ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ( ( ) ) * * * * * * * * * * * * * * * * * * + + + + + + + + + + + + + , , , , , , , , , , -0None >$* 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. hledger-lib>A replacement pattern. May include numeric backreferences (N). hledger-libRegular expression. Extended regular expression-ish syntax ? But does not support eg (?i) syntax.# 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.  !"#$%&'  !"#$%&'None #$28>V/ 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.3 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_balance6 hledger-libAn account, with its balances, parent/subaccount relationships, etc. Only the name is required; the other fields are added when needed.8 hledger-libthis account's full name9 hledger-liboptional extra info from account directives relationships in the tree: hledger-libthis account's sub-accounts; hledger-libparent account< hledger-libused in the accounts report to label elidable parents balance information= hledger-lib&the number of postings to this account> hledger-lib-this account's balance, excluding subaccounts? hledger-lib-this account's balance, including subaccounts@ hledger-libExtra information about an account that can be derived from its account directive (and the other account directives).B hledger-libany comment lines following an account directive for this accountC hledger-lib/tags extracted from the account comment, if anyD hledger-libthe order in which this account was declared, relative to other account declarations, during parsing (1..)E hledger-lib-Extra information found in a payee directive.G hledger-lib/any comment lines following the payee directiveH hledger-lib'tags extracted from the comment, if anyI hledger-lib2The id of a data format understood by hledger, eg journal or csv>. The --output-format option selects one of these for output.J hledger-libA journal in the process of being parsed, not yet finalised. The data is partial, and list fields are in reverse order.K 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).M hledger-libthe current default year, specified by the most recent Y directive (or current date)N hledger-libthe current default commodity and its format, specified by the most recent D directiveO hledger-libthe character to always parse as decimal point, if set by CsvReader's decimal-mark (or a future journal directive)P hledger-libthe current stack of parent account names, specified by apply account directivesQ 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)R hledger-lib2timeclock sessions which have not been clocked outT hledger-libPayees declared by payee directives, in parse order (after journal finalisation)U hledger-libAccounts declared by account directives, in parse order (after journal finalisation)V hledger-libAccounts whose type has been declared in account directives (usually 5 top-level accounts)W hledger-libper-commodity display styles declared globally, eg by command line option or import commandX hledger-lib8commodities and formats declared by commodity directivesY hledger-lib5commodities and formats inferred from journal amountsZ hledger-libDeclarations of market prices by P directives, in parse order (after journal finalisation)[ hledger-libMarket prices implied by transactions, in parse order (after journal finalisation)_ hledger-lib6any final trailing comments in the (main) journal file` 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 seena hledger-lib0when this journal was last read from its file(s)b hledger-libA historical market price (exchange rate) from one commodity to another. A more concise form of a PriceDirective, without the amount display info.d hledger-lib+Date on which this price becomes effective.e hledger-lib#The commodity being converted from.f hledger-lib!The commodity being converted to.g hledger-libOne unit of the "from" commodity is worth this quantity of the "to" commodity.h 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.z 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 can have the tmprIsMultiplier 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-libthe file position where the date starts, and where the last posting ends 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-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-libStores the CommoditySymbol of the Amount, along with the CommoditySymbol of the price, and its unit price if being used. 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=<;:98@ADCBEFHGIJKLa`_^]\[ZYXWVUTSRQPONMbcgfedhilkjmnsrqpotyxvuwz{~}|z{~}|tyxvuwmnsrqpohilkjbcgfedKLa`_^]\[ZYXWVUTSRQPONMJIEFHG@ADCB67?>=<;:98354/021None h; hledger-libConvert Periods to DateSpans.periodAsDateSpan (MonthPeriod 2000 1) == DateSpan (Just $ fromGregorian 2000 1 1) (Just $ fromGregorian 2000 2 1)True hledger-libConvert DateSpans to Periods.dateSpanAsPeriod $ DateSpan (Just $ fromGregorian 2000 1 1) (Just $ fromGregorian 2000 2 1)MonthPeriod 2000 1 hledger-libConvert PeriodBetweens to a more abstract period where possible.simplifyPeriod $ PeriodBetween (fromGregorian 1 1 1) (fromGregorian 2 1 1) YearPeriod 1simplifyPeriod $ PeriodBetween (fromGregorian 2000 10 1) (fromGregorian 2001 1 1)QuarterPeriod 2000 4simplifyPeriod $ PeriodBetween (fromGregorian 2000 2 1) (fromGregorian 2000 3 1)MonthPeriod 2000 2simplifyPeriod $ PeriodBetween (fromGregorian 2016 7 25) (fromGregorian 2016 8 1)WeekPeriod 2016-07-25simplifyPeriod $ PeriodBetween (fromGregorian 2000 1 1) (fromGregorian 2000 1 2)DayPeriod 2000-01-01simplifyPeriod $ PeriodBetween (fromGregorian 2000 2 28) (fromGregorian 2000 3 1)#PeriodBetween 2000-02-28 2000-03-01simplifyPeriod $ PeriodBetween (fromGregorian 2000 2 29) (fromGregorian 2000 3 1)DayPeriod 2000-02-29simplifyPeriod $ PeriodBetween (fromGregorian 2000 12 31) (fromGregorian 2001 1 1)DayPeriod 2000-12-31 hledger-libIs this period a "standard" period, referencing a particular day, week, month, quarter, or year ? Periods of other durations, or infinite duration, or not starting on a standard period boundary, are not. hledger-lib2The width of a period of this type when displayed. hledger-libRender a period as a compact display string suitable for user output.1showPeriod (WeekPeriod (fromGregorian 2016 7 25))"2016-07-25W30" hledger-libLike showPeriod, but if it's a month period show just the 3 letter month name abbreviation for the current locale. hledger-libMove a standard period to the following period of same duration. Non-standard periods are unaffected. hledger-libMove a standard period to the preceding period of same duration. Non-standard periods are unaffected. hledger-libMove a standard period to the following period of same duration, staying within enclosing dates. Non-standard periods are unaffected. hledger-libMove a standard period to the preceding period of same duration, staying within enclosing dates. Non-standard periods are unaffected. hledger-libMove a standard period stepwise so that it encloses the given date. Non-standard periods are unaffected. hledger-libEnlarge a standard period to the next larger enclosing standard period, if there is one. Eg, a day becomes the enclosing week. A week becomes whichever month the week's thursday falls into. A year becomes all (unlimited). Non-standard periods (arbitrary dates, or open-ended) are unaffected. hledger-libShrink a period to the next smaller standard period inside it, choosing the subperiod which contains today's date if possible, otherwise the first subperiod. It goes like this: unbounded periods and nonstandard periods (between two arbitrary dates) -> 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.. Safe-Inferredh / 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   Safe-Inferred?  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-lib.Render source position in human-readable form. hledger-lib8Render a pair of source position in human-readable form. 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 text parser in the identity monad. See also: parseWithState. hledger-libRun a text parser in the identity monad. See also: parseWithState. 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 errput on the console. The default is 0 meaning no debug errput. 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 -} hledger-libCheck the IO environment to see if ANSI colour codes should be used on stdout. This is done using unsafePerformIO so it can be used anywhere, eg in low-level debug utilities, which should be ok since we are just reading. The logic is: use color if the program was started with --color=yes|always or ( the program was not started with --color=no|never and a NO_COLOR environment variable is not defined and stdout supports ANSI color and -o/--output-file was not used or is "-" ). Caveats: When running code in GHCI, this module must be reloaded to see a change. {- OPTIONS_GHC -fno-cse -} {- NOINLINE useColorOnStdout -} hledger-libLike useColorOnStdout, but checks for ANSI color support on stderr, and is not affected by -o/--output-file. {- OPTIONS_GHC -fno-cse -} {- NOINLINE useColorOnStdout -} 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-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 ?; 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.0    0 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 strict Text to a WideBuilder. 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-libCreate a multi-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-lib>A version of renderTable that operates on rows (including the  8 of column headers) and returns the underlying Builder. hledger-lib5Render a single row according to cell specifications. 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-lib(Simpler alias for errorWithoutStackTrace hledger-lib;A version of errorWithoutStackTrace that adds a usage hint. hledger-libLike embedFile, but takes a path relative to the package directory. Similar to embedFileRelative ? hledger-lib?Wrap a string in ANSI codes to set and reset foreground colour. hledger-lib?Wrap a string in ANSI codes to set and reset background colour. hledger-libWrap a WideBuilder in ANSI codes to set and reset foreground colour. hledger-libWrap a WideBuilder in ANSI codes to set and reset background colour. hledger-libMake classy lenses for Hledger options fields. This is intended to be used with BalancingOpts, InputOpt, ReportOpts, ReportSpec, and CliOpts. When run on X, it will create a typeclass named HasX (except for ReportOpts, which will be named HasReportOptsNoUpdate) containing all the lenses for that type. If the field name starts with an underscore, the lens name will be created by stripping the underscore from the front on the name. If the field name ends with an underscore, the field name ends with an underscore, the lens name will be mostly created by stripping the underscore, but a few names for which this would create too many conflicts instead have a second underscore appended. ReportOpts fields for which updating them requires updating the query in ReportSpec are instead names by dropping the trailing underscore and appending NoUpdate to the name, e.g. querystring_ -> querystringNoUpdate.There are a few reasons for the complicated rules. - We have some legacy field names ending in an underscore (e.g. value_) which we want to temporarily accommodate, before eventually switching to a more modern style (e.g. _rsReportOpts) - Certain fields in ReportOpts need to update the enclosing ReportSpec when they are updated, and it is a common programming error to forget to do this. We append NoUpdate to those lenses which will not update the enclosing field, and reserve the shorter name for manually define lenses (or at least something lens-like) which will update the ReportSpec. cf. the lengthy discussion here and in surrounding comments: https://github.com/simonmichael/hledger/pull/1545#issuecomment-881974554    !"#$%&'0 None% 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 (DaysOfWeek [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-lib5Group elements based on where they fall in a list of 1s without gaps. The precondition is not checked. 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 12, 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 (DaysOfWeek [2],DateSpan ..)p "every 2nd day of week""Right (DaysOfWeek [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-libTruncate all account name components but the last to two characters. hledger-libA top-level account prefixed to some accounts in budget reports. Defined here so it can be ignored by accountNameDrop. hledger-libRemove some number of account name components from the front of the account name. If the special " unbudgeted" top-level account is present, it is preserved and dropping affects the rest of the account name. hledger-libSorted unique account names implied by these account names, ie these plus all their parent accounts up to the root. Eg: ["a:b:c","d:e"] -> ["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 #$3e 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-libWhether to display on one line. hledger-libMinimum width to pad to hledger-libMaximum width to clip to | Display amounts in this order (without the commodity symbol) and display a 0 in case a corresponding commodity does not exist hledger-libShow space-containing commodity symbols quoted, as they are in a journal. 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 mainly for internal use, eg when comparing amounts in tests. hledger-libSet an amount's internal precision, flipped. Intended mainly 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-libStrip all prices from an Amount 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. Also apply the style to the price (except for precision) 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. Is this mixed amount non-zero, ignoring its display precision?/A convenient alias for not . mixedAmountIsZero. hledger-lib'Get a mixed amount's component amounts.amounts in the same commodity are combined unless they have different prices or total pricesmultiple zero amounts, all with the same non-null commodity, are replaced by just the last of them, preserving the commodity and amount style (all but the last zero amount are discarded)multiple zero amounts with multiple commodities, or no commodities, are replaced by one commodity-less zero amountan empty amount list is replaced by one commodity-less zero amount4the special "missing" mixed amount remains unchanged hledger-libGet a mixed amount's component amounts without normalising zero and missing amounts. This is used for JSON serialisation, so the order is important. In particular, we want the Amounts given in the order of the MixedAmountKeys, i.e. lexicographically first by commodity, then by price commodity, then by unit price from most negative to most positive. hledger-libGet this mixed amount's commodities as a set. Returns an empty set if there are no amounts. hledger-libUnify a MixedAmount to a single commodity value if possible. This consolidates amounts of the same commodity and discards zero amounts; but this one insists on simplifying to a single commodity, and will return Nothing if this is not possible. hledger-lib9Filter a mixed amount's component amounts by a predicate. hledger-libReturn an unnormalised MixedAmount containing exactly one Amount with the specified commodity and the quantity of that commodity found in the original. NB if Amount's quantity is zero it will be discarded next time the MixedAmount gets normalised. hledger-lib0Apply a transform to a mixed amount's component s. hledger-libConvert all component amounts to cost/selling price where possible (see amountCost). hledger-libGiven a map of standard commodity display styles, apply the appropriate one to each individual amount. hledger-libmatch 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-libParse a single query term as either a query or a query option, or return an error message if parsing fails. 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 %&v 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 w 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 #$0 hledger-libGenerate transactions from z 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 #$> 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 TransactionNone %6 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-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-libSorted unique commodity symbols declared or inferred from 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-libKeep only postings which do not match the query expression, but for which a related posting does. 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-libNumber (set the tindex field) this journal's transactions, counting upward from 1. 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-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 "exclusive end date" of this journal: the day following its latest transaction or posting date, 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-libIgnore balance assertions  hledger-lib1Infer prices in unbalanced multicommodity amounts  hledger-libcommodity display styles  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-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.  Noneq  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-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-lib/span in which to generate forecast transactions  hledger-liba dirty hack keeping the query dates in InputOpts. This rightfully lives in ReportSpec, but is duplicated here.  hledger-lib2generate automatic postings when journal is parsed  hledger-lib"options for balancing transactions  hledger-libdo extra error checking (eg, all posted accounts are declared, no prices are inferred)  hledger-libtoday's date, for use with forecast transactions XXX this duplicates _rsDay, and should eventually be removed when it's not needed anymore.  hledger-libGet the Maybe the DateSpan to generate forecast options from. This begins on: - the start date supplied to the `--forecast` argument, if present - otherwise, the later of - the report start date if specified with -b-pdate: - the day after the latest normal (non-periodic) transaction in the journal, if any - otherwise today. It ends on: - the end date supplied to the `--forecast` argument, if present - otherwise the report end date if specified with -e-p2date: - otherwise 180 days (6 months) from today. 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-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-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 m/01234567?>=<;:89@ADBCEFGHIJKLa`_^]\[ZYXWVUTSRQPOMNbcgfdehiljkmnsrqoptyxvwuz{~|} /01234567?>=<;:89@ADBCEFGHIJKLa`_^]\[ZYXWVUTSRQPOMNbcgfdehiljkmnsrqoptyxvwuz{~|} None #$>?3  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)What to calculate in balance report cells  hledger-lib1How to accumulate balance report values over time  hledger-libA case-insensitive description substring to select periodic transactions for budget reports. (Not a regexp, nor a full hledger query, for now.)  hledger-libWhether to show costs for reports which normally don't show them  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-libHow to accumulate calculated values across periods (columns) in a balance report. "Balance report types -> Accumulation type" in the hledger manual.  hledger-libNo accumulation. Eg, shows the change of balance in each period.  hledger-libAccumulate changes across periods, starting from zero at report start.  hledger-libAccumulate changes across periods, including any from before report start. Eg, shows the historical end balance of each period.  hledger-libWhat to calculate for each cell in a balance report. "Balance report types -> Calculation type" in the hledger manual.  hledger-lib%Sum of posting amounts in the period.  hledger-lib3Sum of posting amounts and the goal for the period.  hledger-libChange from previous period's historical end value to this period's historical end value.  hledger-libChange from previous period's gain, i.e. valuation minus cost basis.  hledger-libGenerate a ReportOpts from raw command-line input, given a day. This will fail with a usage error if it is passed - an invalid --format argument, - an invalid --value argument, - if --valuechange is called with a valuation type other than -V/--value=end. - an invalid --pretty argument,  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-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 and/or to value, if specified by options (-B--cost-V-X--value etc.). Strip prices if not needed. This should be the main stop for performing costing and valuation. The exception is whenever you need to perform valuation _after_ summing up amounts, as in a historical balance report with --value=end. valuationAfterSum will check for this condition.  hledger-libLike journalApplyValuationFromOpts, but takes PriceOracle as an argument.  hledger-libSelect the Account valuation functions required for performing valuation after summing amounts. Used in MultiBalanceReport to value historical and similar reports.  hledger-libIf the ReportOpts specify that we are performing valuation after summing amounts, return Just of the commodity symbol we're converting to, Just Nothing for the default, and otherwise return Nothing. Used for example with historical reports with --value=end.  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.  hledger-libLike reportSpan, but uses both primary and secondary dates when calculating the span.  hledger-libMake a name for the given period in a multiperiod report, given the type of balance being reported and the full set of report periods. This will be used as a column heading (or row heading, in a register summary report). We try to pick a useful name as follows:-ending-balance reports: the period's end datebalance change reports where the periods are months and all in the same year: the short month name in the current localeall other balance change reports: a description of the datespan, abbreviated to compact form if possible (see showDateSpan).  hledger-lib4Apply a function over a lens, but report on failure.  hledger-lib0Set a field using a lens, but report on failure.  hledger-libLenses for ReportOpts.  hledger-libSpecial lenses for ReportOpts which also update the Query and QueryOpts in ReportSpec. Note that these are not true lenses, as they have a further restriction on the functor. This will work as a normal lens for all common uses, but since they don't obey the lens laws for some fancy cases, they may fail in some exotic circumstances.Note that setEither/overEither should only be necessary with querystring and reportOpts: the other lenses should never fail. Examples:import Lens.Micro (set);_rsQuery <$> setEither querystring ["assets"] defreportspec Right (Acct (RegexpCI "assets"))<_rsQuery <$> setEither querystring ["(assets"] defreportspec=Left "this regular expression could not be compiled: (assets"3_rsQuery $ set querystring ["assets"] defreportspecAcct (RegexpCI "assets")4_rsQuery $ set querystring ["(assets"] defreportspec*** Exception: Updating ReportSpec failed: try using overEither instead of over or setEither instead of set9_rsQuery $ set period (MonthPeriod 2021 08) defreportspecDate DateSpan 2021-08  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, _rsReportOpts, querystring_, etc.) are in sync.  hledger-libLike updateReportSpec, but takes a ReportOpts-modifying function.  hledger-libGenerate a ReportSpec from RawOpts and a provided day, or return an error string if there are regular expression errors.   None58:   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 BalanceAccumulation 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-libv  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 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`  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 #$!  hledger-libA budget report tracks expected and actual changes per account and subperiod.  hledger-libCalculate per-account, per-period budget (balance change) goals from all periodic transactions, calculate actual balance changes from the regular transactions, and compare these to get a  . Unbudgeted accounts may be hidden or renamed (see journalWithBudgetAccountNames).  hledger-libCombine a per-account-and-subperiod report of budget goals, and one of actual change amounts, into a budget performance report. The two reports should have the same report interval, but need not have exactly the same account rows or date columns. (Cells in the combined budget report can be missing a budget goal, an actual amount, or both.) The combined report will include:consecutive subperiods at the same interval as the two reports, spanning the period of both reportsall accounts mentioned in either report, sorted by account code or account name or amount as appropriate.  hledger-libRender a budget report as plain text suitable for console output.  hledger-libBuild a  $ from a multi-column balance report.  hledger-libRender a budget report as CSV. Like multiBalanceReportAsCsv, but includes alternating actual and budget amount columns. $None >&  hledger-lib A simple balance report. It has: 2a list of items, one per account, each containing:the full account namethe Ledger-style elided short account name (the leaf account name, prefixed by any boring parents immediately above); or with --flat, the full account name againthe number of indentation steps for rendering a Ledger-style account tree, taking into account elided boring parents, --no-elide and --flat an amount the total of all amounts  hledger-libWhen true (the default), this makes balance --flat reports and their implementation clearer. Single/multi-col balance reports currently aren't all correct if this is false.  hledger-libEnabling this makes balance --flat --empty also show parent accounts without postings, in addition to those with postings and a zero balance. Disabling it shows only the latter. No longer supported, but leave this here for a bit. flatShowsPostinglessAccounts = TrueGenerate a simple balance report, containing the matched accounts and their balances (change of balance) during the specified period. If the normalbalance_ option is set, it adjusts the sorting and sign of amounts (see ReportOpts and CompoundBalanceCommand).  %None >1  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": the earliest of the transaction date and any other posting dates of postings to the current account (matched by the report query).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, and a sign-setting function. Each transaction is accompanied by the date that should be shown for it in the report, which is not necessarily the transaction date; it is the earliest of the posting dates which match both thisacctq and reportq, otherwise the transaction's date if there are no matching postings.  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.  hledger-libSplit an account transactions report whose items may involve several commodities, into one or more single-commodity account transactions reports. &None >1  'None #$%?g,&  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-libParse an InputOpts from a RawOpts and a provided date. This will fail with a usage error if the forecast period expression cannot be parsed.  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,add forecast transactions,: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-libGenerate periodic transactions from all periodic transaction rules in the journal. These transactions are added to the in-memory Journal (but not the on-disk file).The start & end date for generated periodic transactions are determined in a somewhat complicated way; see the hledger manual -> Periodic transactions.  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 possibly empty text until a semicolon or newline. Whitespace is preserved (for now - perhaps helps preserve alignment of same-line comments ?).  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 possibly empty text, including whitespace, until a comment start (semicolon) or newline.  hledger-libParse non-empty text, including whitespace, until a comment start (semicolon) or newline.  hledger-libParse non-empty, single-spaced text starting and ending with non-whitespace, until a double space or newline.  hledger-libParse non-empty, single-spaced text starting and ending with non-whitespace, until a comment start (semicolon), double space, or newline.  hledger-libParse non-empty, single-spaced text starting and ending with non-whitespace, where all characters satisfy 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-libIs this a character that, as the first non-whitespace on a line, starts a comment line ?  hledger-libIs this a character that, appearing anywhere within a line, starts a comment ?  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 h  )None i  *None #$&>?j  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 %?ok  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-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 y  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 {    !"#$%&'/01234567?>=<;:89@ADBCEFGHIJKLa`_^]\[ZYXWVUTSRQPOMNbcgfdehiljkmnsrqoptyxvwuz{~|}  34534634734834934:34;34;<=><=?<=@<=A<=B