Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- parseAndFinaliseJournal :: ParsecT [Char] JournalContext (ExceptT String IO) (JournalUpdate, JournalContext) -> Bool -> FilePath -> String -> ExceptT String IO Journal
- genericSourcePos :: SourcePos -> GenericSourcePos
- getParentAccount :: Stream [Char] m Char => ParsecT [Char] JournalContext m String
- journalp :: ParsecT [Char] JournalContext (ExceptT String IO) (JournalUpdate, JournalContext)
- directivep :: ParsecT [Char] JournalContext (ExceptT String IO) JournalUpdate
- defaultyeardirectivep :: ParsecT [Char] JournalContext (ExceptT String IO) JournalUpdate
- marketpricedirectivep :: ParsecT [Char] JournalContext (ExceptT String IO) MarketPrice
- datetimep :: Stream [Char] m Char => ParsecT [Char] JournalContext m LocalTime
- codep :: Stream [Char] m Char => ParsecT [Char] JournalContext m String
- accountnamep :: Stream [Char] m Char => ParsecT [Char] st m AccountName
- modifiedaccountnamep :: Stream [Char] m Char => ParsecT [Char] JournalContext m AccountName
- postingp :: Stream [Char] m Char => ParsecT [Char] JournalContext m Posting
- amountp :: Stream [Char] m t => ParsecT [Char] JournalContext m Amount
- amountp' :: String -> Amount
- mamountp' :: String -> MixedAmount
- numberp :: Stream [Char] m t => ParsecT [Char] JournalContext m (Quantity, Int, Maybe Char, Maybe DigitGroupStyle)
- statusp :: Stream [Char] m Char => ParsecT [Char] JournalContext m ClearedStatus
- emptyorcommentlinep :: Stream [Char] m Char => ParsecT [Char] JournalContext m ()
- followingcommentp :: Stream [Char] m Char => ParsecT [Char] JournalContext m String
- accountaliasp :: Stream [Char] m Char => ParsecT [Char] st m AccountAlias
- tests_Hledger_Read_JournalReader :: Test
Reader
Parsers used elsewhere
parseAndFinaliseJournal :: 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.
getParentAccount :: Stream [Char] m Char => ParsecT [Char] JournalContext m String Source
journalp :: 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. Hyphen (-) and period (.) are also allowed as date separators. The year may be omitted if a default year has been set. Seconds are optional. The timezone is optional and ignored (the time is always interpreted as a local time). Leading zeroes may be omitted (except in a timezone).
accountnamep :: Stream [Char] m Char => ParsecT [Char] st m AccountName Source
Parse an account name. Account names start with a non-space, may have single spaces inside them, and are terminated by two or more spaces (or end of input). Also they have one or more components of at least one character, separated by the account separator char. (This parser will also consume one following space, if present.)
modifiedaccountnamep :: 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.
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.
statusp :: Stream [Char] m Char => ParsecT [Char] JournalContext m ClearedStatus Source
emptyorcommentlinep :: Stream [Char] m Char => ParsecT [Char] JournalContext m () Source
followingcommentp :: Stream [Char] m Char => ParsecT [Char] JournalContext m String Source
accountaliasp :: Stream [Char] m Char => ParsecT [Char] st m AccountAlias Source