Source codeContentsIndex
Hledger.Read.Common
Description
Common utilities for hledger data readers, such as the context (state) that is kept while parsing a journal.
Synopsis
data Reader = Reader {
rFormat :: String
rDetector :: FilePath -> String -> Bool
rParser :: FilePath -> String -> ErrorT String IO Journal
}
type JournalUpdate = ErrorT String IO (Journal -> Journal)
parseJournalWith :: GenParser Char JournalContext JournalUpdate -> FilePath -> String -> ErrorT String IO Journal
data JournalContext = Ctx {
ctxYear :: !(Maybe Integer)
ctxCommod :: !(Maybe String)
ctxAccount :: ![String]
}
emptyCtx :: JournalContext
setYear :: Integer -> GenParser tok JournalContext ()
getYear :: GenParser tok JournalContext (Maybe Integer)
pushParentAccount :: String -> GenParser tok JournalContext ()
popParentAccount :: GenParser tok JournalContext ()
getParentAccount :: GenParser tok JournalContext String
expandPath :: MonadIO m => SourcePos -> FilePath -> m FilePath
fileSuffix :: FilePath -> String
Documentation
data Reader Source
A hledger data reader is a triple of format name, format-detecting predicate, and a parser to Journal.
Constructors
Reader
rFormat :: String
rDetector :: FilePath -> String -> Bool
rParser :: FilePath -> String -> ErrorT String IO Journal
type JournalUpdate = ErrorT String IO (Journal -> Journal)Source
A JournalUpdate is some transformation of a Journal. It can do I/O or raise an error.
parseJournalWith :: GenParser Char JournalContext JournalUpdate -> 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.
data JournalContext Source
Some state kept while parsing a journal file.
Constructors
Ctx
ctxYear :: !(Maybe Integer)the default year most recently specified with Y
ctxCommod :: !(Maybe String)I don't know
ctxAccount :: ![String]the current stack of parent accounts specified by !account
show/hide Instances
emptyCtx :: JournalContextSource
setYear :: Integer -> GenParser tok JournalContext ()Source
getYear :: GenParser tok JournalContext (Maybe Integer)Source
pushParentAccount :: String -> GenParser tok JournalContext ()Source
popParentAccount :: GenParser tok JournalContext ()Source
getParentAccount :: GenParser tok JournalContext StringSource
expandPath :: MonadIO m => SourcePos -> FilePath -> m FilePathSource
fileSuffix :: FilePath -> StringSource
Produced by Haddock version 2.6.1