HORIZON HASKELLDocslts/ghc-10.0.x8c2f8e82026-10-19Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8c2f8e8 · 2026-10-19

Modulehledger-lib-1.52.4GHC2021

Hledger.Reports.ReportOptions

Options common to most hledger reports.

  • 9 types
  • 3 classes
  • 38 values
  • Packagehledger-lib-1.52.4
  • Exports50
  • LanguageGHC2021
  • LicenceGPL-3.0-or-later
  • SourceReportOptions.hs
datadata ReportOpts
#

Standard 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.

Constructors

Instances4Show, Default, HasReportOpts, HasReportOptsNoUpdate
classclass HasReportOptsNoUpdate c where
#
Instances2HasReportOptsNoUpdate
classclass HasReportOptsNoUpdate a => HasReportOpts a where
#

Special 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:
Example5 expressions
import Lens.Micro (set)_rsQuery <$> setEither querystring ["assets"] defreportspecRight (Acct (RegexpCI "assets"))_rsQuery <$> setEither querystring ["(assets"] defreportspecLeft "This regular expression is invalid or unsupported, please correct it:\n(assets"_rsQuery $ set querystring ["assets"] defreportspecAcct (RegexpCI "assets")_rsQuery $ set period (MonthPeriod 2021 08) defreportspecDate DateSpan 2021-08

XXX testing error output isn't working since adding color to it: > import System.Environment > setEnv NO_COLOR "1" >> return (_rsQuery $ set querystring ["(assets"] defreportspec) *** Exception: Error: Updating ReportSpec failed: try using overEither instead of over or setEither instead of set

Methods

Instances2HasReportOpts
datadata ReportSpec
#

A fully-determined set of report parameters (report options with all partial values made total, eg the begin and end dates are known, avoiding date/regex errors; plus the reporting date), and the query successfully calculated from them.

If you change the report options or date in one of these, you should use reportOptsToSpec to regenerate the whole thing, avoiding inconsistency.

Constructors

Instances5Show, Default, HasReportOpts, HasReportOptsNoUpdate, HasReportSpec
datadata BalanceCalculation
#

What to calculate for each cell in a balance report. "Balance report types -> Calculation type" in the hledger manual.

Constructors

  • CalcChange

    Sum of posting amounts in the period.

  • CalcBudget

    Sum of posting amounts and the goal for the period.

  • CalcValueChange

    Change from previous period's historical end value to this period's historical end value.

  • CalcGain

    Change from previous period's gain, i.e. valuation minus cost basis.

  • CalcPostingsCount

    Number of postings in the period.

Instances3Eq, Show, Default
datadata BalanceAccumulation
#

How to accumulate calculated values across periods (columns) in a balance report. "Balance report types -> Accumulation type" in the hledger manual.

Constructors

  • PerPeriod

    No accumulation. Eg, shows the change of balance in each period.

  • Cumulative

    Accumulate changes across periods, starting from zero at report start.

  • Historical

    Accumulate changes across periods, including any from before report start. Eg, shows the historical end balance of each period.

Instances3Eq, Show, Default
datadata ValuationType
#

What kind of value conversion should be done on amounts ? CLI: --value=then|end|now|DATE[,COMM]

Constructors

Instances2Eq, Show

Generate a ReportOpts from raw command-line input, given a day and whether to use ANSI colour/styles in standard output. 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,

Update 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.

valuesimplifyStatuses :: Ord a => [a] -> [a]
#

Reduce a list of statuses to just one of each status, and if all statuses are present return the empty list.

Convert 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.

If 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.

If the ReportOpts specify that we will need to consider historical postings, either because this is a historical report, or because the valuation strategy requires historical amounts.

Get 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.

The effective report span is the start and end dates requested by options or queries. If the start date is unspecified, the earliest transaction or posting date is used. If the end date is unspecified, the latest transaction or posting date (or non-future market price date, when doing an end value report) is used. If none of these things are present, the null date span is returned. The report sub-periods caused by a report interval, if any, are also returned.

Make 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 date

  • balance change reports where the periods are months and all in the same year: the short month name in the current locale

  • all other balance change reports: a description of the datespan, abbreviated to compact form if possible (see showDateSpan).