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

Safe HaskellNone
LanguageHaskell2010

Hledger.Read.JournalReader

Contents

Description

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
    assets:cash

Synopsis

Reader

Parsers used elsewhere

parseJournalWith :: ParsecT [Char] JournalContext (ExceptT String IO) (JournalUpdate, JournalContext) -> Bool -> FilePath -> String -> ExceptT String IO Journal Source

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 :: ParsecT [Char] JournalContext (ExceptT String IO) (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 :: Stream [Char] m Char => ParsecT [Char] JournalContext m LocalTime Source

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 :: Stream [Char] m Char => ParsecT [Char] st m AccountName Source

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.

modifiedaccountname :: Stream [Char] m Char => ParsecT [Char] JournalContext m AccountName Source

Parse an account name, then apply any parent account prefix and/or account aliases currently in effect.

amountp :: Stream [Char] m t => ParsecT [Char] JournalContext m Amount Source

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 -> Amount Source

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

mamountp' :: String -> MixedAmount Source

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

numberp :: Stream [Char] m t => ParsecT [Char] JournalContext m (Quantity, Int, Maybe Char, Maybe DigitGroupStyle) Source

Parse 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 point, 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 point), the decimal point character used if any, and the digit group style if any.