Safe Haskell | None |
---|
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
- reader :: Reader
- parseJournalWith :: GenParser Char JournalContext (JournalUpdate, JournalContext) -> FilePath -> String -> ErrorT String IO Journal
- getParentAccount :: GenParser tok JournalContext String
- journal :: GenParser Char JournalContext (JournalUpdate, JournalContext)
- directive :: GenParser Char JournalContext JournalUpdate
- defaultyeardirective :: GenParser Char JournalContext JournalUpdate
- historicalpricedirective :: GenParser Char JournalContext HistoricalPrice
- datetime :: GenParser Char JournalContext LocalTime
- code :: GenParser Char JournalContext String
- accountname :: GenParser Char st AccountName
- amountp :: GenParser Char JournalContext Amount
- amountp' :: String -> Amount
- mamountp' :: String -> MixedAmount
- emptyline :: GenParser Char JournalContext ()
Reader
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.
datetime :: 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.
accountname :: 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.
mamountp' :: String -> MixedAmountSource
Parse a mixed amount from a string, or get an error.