h$Q?       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                                                                                                                                                                                                                                                                                     ! ! ! ! ! ! ! ! ! ! ! ! " # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ % % % % % & & & & & & & & & & & & & & & ' ' ' ' ( ( ( ( ( ( ( ( ( ( ( ( ) ) ) ) ) * * * * * * * * * * * * * + , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , - - . . / / / / / / / / / / / / / / / / / / 0 0 0 0 0 0 0 0 0 0 0 0 0              14None >% 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>Z2 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.6 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_balance9 hledger-libAn account, with its balances, parent/subaccount relationships, etc. Only the name is required; the other fields are added when needed.; hledger-libthis account's full name< 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 accountA hledger-lib-this account's balance, excluding subaccountsB hledger-lib-this account's balance, including subaccountsC hledger-libExtra information about an account that can be derived from its account directive (and the other account directives).E hledger-libany comment lines following an account directive for this accountF hledger-lib/tags extracted from the account comment, if anyG hledger-libthe order in which this account was declared, relative to other account declarations, during parsing (1..)H hledger-lib-Extra information found in a payee directive.J hledger-lib/any comment lines following the payee directiveK hledger-lib'tags extracted from the comment, if anyL hledger-lib2The id of a data format understood by hledger, eg journal or csv>. The --output-format option selects one of these for output.M hledger-libA journal in the process of being parsed, not yet finalised. The data is partial, and list fields are in reverse order.N 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).P hledger-libthe current default year, specified by the most recent Y directive (or current date)Q hledger-libthe current default commodity and its format, specified by the most recent D directiveR hledger-libthe character to always parse as decimal point, if set by CsvReader's decimal-mark (or a future journal directive)S hledger-libthe current stack of parent account names, specified by apply account directivesT 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)U hledger-lib2timeclock sessions which have not been clocked outW hledger-libPayees declared by payee directives, in parse order (after journal finalisation)X hledger-libAccounts declared by account directives, in parse order (after journal finalisation)Y hledger-libAccounts which have tags declared in their directives, and those tags. (Does not include parents' tags.)Z hledger-libAccounts whose type has been explicitly declared in their account directives, grouped by type.[ hledger-libAll accounts for which a type has been declared or can be inferred from its parent or its name.\ hledger-libper-commodity display styles declared globally, eg by command line option or import command] hledger-lib8commodities and formats declared by commodity directives^ hledger-lib5commodities and formats inferred from journal amounts_ 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)d hledger-lib6any final trailing comments in the (main) journal filee 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 seenf hledger-libwhen this journal was last read from its file(s) NOTE: after adding new fields, eg involving account names, consider updating the Anon instance in Hleger.Cli.Anong hledger-libA historical market price (exchange rate) from one commodity to another. A more concise form of a PriceDirective, without the amount display info.i hledger-lib+Date on which this price becomes effective.j hledger-lib#The commodity being converted from.k hledger-lib!The commodity being converted to.l hledger-libOne unit of the "from" commodity is worth this quantity of the "to" commodity.m hledger-libA market price declaration made by the journal format's P directive. It declares two things: a historical exchange rate between two commodities, and an amount display style for the second commodity. hledger-libA periodic transaction rule, describing a transaction that recurs. hledger-lib the period expression as written hledger-lib-the interval at which this transaction recurs hledger-libthe (possibly unbounded) period during which this transaction recurs. Contains a whole number of intervals. hledger-libsome of Transaction's fields hledger-libA transaction modifier transformation, which adds an extra posting to the matched posting's transaction. Can be like a regular posting, or 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-libtag names and values, extracted from the posting comment and (after finalisation) the posting account's directive if any 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=;=; 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.2 Safe-Inferredl 3 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 specialised version of ParseErrorBundle: a non-empty collection of hledger parse errors, equipped with PosState to help pretty-print them. Specialised for a   parse stream. hledger-lib9Custom error data for hledger parsers. Specialised for a   parse stream.  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-libRender a pair of source positions in human-readable form, only displaying the range of lines. 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-lib%Take elements from the end of a list. hledger-lib'Remove leading and trailing whitespace. hledger-libRemove leading whitespace. hledger-libRemove trailing whitespace. hledger-lib.Remove all trailing newlines/carriage returns. hledger-libRemove all trailing newline/carriage returns, leaving just one trailing newline. hledger-libRemove consecutive line breaks, replacing them with single space hledger-lib7Clip and pad a string to a minimum & maximum width, andor leftright justify it. Works on multi-line strings too (but will rewrite non-unix line endings). hledger-libDouble-quote this string if it contains whitespace, single quotes or double-quotes, escaping the quotes as needed. hledger-libSingle-quote this string if it contains whitespace or double-quotes. No good for strings containing single quotes. hledger-libQuote-aware version of words - don't split on spaces which are inside quotes. NB correctly handles "a'b" but not "'a''". Can raise an error if parsing fails. hledger-libQuote-aware version of unwords - single-quote strings which contain whitespace hledger-libDouble-width-character-aware string truncation. Take as many characters as possible from a string without exceeding the specified width. Eg takeWidth 3 "aa`" = "a". hledger-libLike strWidth, but also strips ANSI escape sequences before calculating the width.This is no longer used in code, as widths are calculated before adding ANSI escape sequences, but is being kept around for now. hledger-lib Alias for  . hledger-lib*Strip ANSI escape sequences from a string.stripAnsi "\ESC[31m-1\ESC[m""-1"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-libLog a pretty-printed showable value to "./debug.log". Uses unsafePerformIO. 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 ?1 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.0   4 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.  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 Find the number of digits of an . 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     !"#$%&'()*2 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-libConstruct a list of >> 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" t "in 5 days" "2008-12-01"t "in 7 months" "2009-06-01"t "in -2 weeks" "2008-11-10"t "1 quarter ago" "2008-07-01"t "1 week ahead" "2008-12-01" hledger-libTry to parse a couple of date string formats: `YYYY-MM-DD`, `YYYYMMDD` or 56, 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) in n days/weeks/months/quarters/years (n periods from the current period) n days/weeks/months/quarters/years ago (-n 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 (SmartCompleteDate 2018-12-01)YYYYMM is parsed as year-month-01 if year and month are valid: >>> parsewith (smartdate <* eof) "201804" Right (SmartAssumeStart 2018 (Just 4))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-libRegular expressions matching common English top-level account names, used as a fallback when account types are not declared. hledger-libTry to guess an account's type from its name, matching common English top-level account names. hledger-libA top-level account prefixed to some accounts in budget reports. Defined here so it can be ignored by accountNameDrop. hledger-libPrefix one account name to another, preserving posting type indicators like concatAccountNames. hledger-libJoin account names into one. If any of them has () or [] posting type indicators, these (the first type encountered) will also be applied to the resulting account name. hledger-libRewrite an account name using all matching aliases from the given list, in sequence. Each alias sees the result of applying the previous aliases. Or, return any error arising from a bad regular expression in the aliases. hledger-lib=Memoising version of accountNameApplyAliases, maybe overkill. hledger-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 ?  hledger-libAn id identifying which report item field to interpolate. These are drawn from several hledger report types, so are not all applicable for a given report. hledger-lib/A posting or balance report item's account name hledger-lib1A posting or register or entry report item's date hledger-lib8A posting or register or entry report item's description hledger-libA balance or posting report item's balance or running total. Always rendered right-justified. hledger-libA balance report item's indent level (which may be different from the account name depth). Rendered as this number of spaces, multiplied by the minimum width spec if any. hledger-lib0A report item's nth field. May be unimplemented. hledger-lib!Literal text to be rendered as-is hledger-lib:A data field to be formatted and interpolated. Parameters:'Left justify ? Right justified if false:Minimum width ? Will be space-padded if narrower than this2Maximum width ? Will be clipped if wider than this?Which of the standard hledger report item fields to interpolate hledger-libA format specification/template to use when rendering a report line item as text.A format is a sequence of components; each is either a literal string, or a hledger report item field with specified width and justification whose value will be interpolated at render time.A component's value may be a multi-line string (or a multi-commodity amount), in which case the final string will be either single-line or a top or bottom-aligned multi-line string depending on the StringFormat variant used.Currently this is only used in the balance command's single-column mode, which provides a limited StringFormat renderer. hledger-lib?multi-line values will be rendered on one line, comma-separated hledger-libvalues will be top-aligned (and bottom-padded to the same height) hledger-lib.values will be bottom-aligned (and top-padded) hledger-libDefault line format for balance report: "%20(total) %2(depth_spacer)%-(account)" hledger-lib=Parse a string format specification, or return a parse error.None #$: 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 display thousands separators. 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-libDisplay Amount and MixedAmount in a form suitable for CSV output. 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-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-lib