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
- parseJournalWith :: ParsecT [Char] JournalContext (ExceptT String IO) (JournalUpdate, JournalContext) -> Bool -> FilePath -> String -> ExceptT String IO Journal
- getParentAccount :: Stream [Char] m Char => ParsecT [Char] JournalContext m String
- journal :: ParsecT [Char] JournalContext (ExceptT String IO) (JournalUpdate, JournalContext)
- directive :: ParsecT [Char] JournalContext (ExceptT String IO) JournalUpdate
- defaultyeardirective :: ParsecT [Char] JournalContext (ExceptT String IO) JournalUpdate
- historicalpricedirective :: ParsecT [Char] JournalContext (ExceptT String IO) HistoricalPrice
- 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
- 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)
- emptyorcommentlinep :: Stream [Char] m Char => ParsecT [Char] JournalContext m ()
- followingcommentp :: Stream [Char] m Char => ParsecT [Char] JournalContext m String
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.
getParentAccount :: Stream [Char] m Char => ParsecT [Char] JournalContext m String Source
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.
historicalpricedirective :: ParsecT [Char] JournalContext (ExceptT String IO) HistoricalPrice Source
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.
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.
emptyorcommentlinep :: Stream [Char] m Char => ParsecT [Char] JournalContext m () Source
followingcommentp :: Stream [Char] m Char => ParsecT [Char] JournalContext m String Source