hledger-lib-0.23.2: Core data types, parsers and utilities for the hledger accounting tool.

Safe HaskellNone




A reader for hledger's journal file format (http://hledger.org/MANUAL.html#the-journal-file). hledger's journal format is a compatible subset of c++ ledger's (http://ledger-cli.org/3.0/doc/ledger3.html#Journal-Format), so this reader should handle many ledger files as well. Example:

2012/3/24 gift
    expenses:gifts  $10



Parsers used elsewhere

parseJournalWith :: GenParser Char JournalContext (JournalUpdate, JournalContext) -> FilePath -> String -> ErrorT String IO JournalSource

Given a JournalUpdate-generating parsec parser, file path and data string, parse and post-process a Journal so that it's ready to use, or give an error.

journal :: GenParser Char JournalContext (JournalUpdate, JournalContext)Source

Top-level journal parser. Returns a single composite, I/O performing, error-raising JournalUpdate (and final JournalContext) which can be applied to an empty journal to get the final result.

datetimep :: GenParser Char JournalContext LocalTimeSource

Parse a date and time in YYYYMMDD HH:MM[:SS][+-ZZZZ] format. Any timezone will be ignored; the time is treated as local time. Fewer digits are allowed, except in the timezone. The year may be omitted if a default year has already been set.

accountnamep :: GenParser Char st AccountNameSource

Parse an account name. Account names may have single spaces inside them, and are terminated by two or more spaces. They should have one or more components of at least one character, separated by the account separator char.

amountp :: GenParser Char JournalContext AmountSource

Parse a single-commodity amount, with optional symbol on the left or right, optional unit or total price, and optional (ignored) ledger-style balance assertion or fixed lot price declaration.

amountp' :: String -> AmountSource

Parse an amount from a string, or get an error.

mamountp' :: String -> MixedAmountSource

Parse a mixed amount from a string, or get an error.

numberp :: GenParser Char JournalContext (Quantity, Int, Char, Char, [Int])Source

Parse a numeric quantity for its value and display attributes. Some international number formats (cf http:en.wikipedia.orgwikiDecimal_separator) are accepted: either period or comma may be used for the decimal point, and the other of these may be used for separating digit groups in the integer part (eg a thousands separator). This returns the numeric value, the precision (number of digits to the right of the decimal point), the decimal point and separator characters (defaulting to . and ,), and the positions of separators (counting leftward from the decimal point, the last is assumed to repeat).