hledger-lib-1.32.3: A library providing the core functionality of hledger

Safe Haskell | Safe-Inferred
Language | Haskell2010

Hledger.Read.RulesReader

Contents

- Reader
- Misc.
- Tests
- Orphan instances

Description

A reader for a CSV rules file. This reads the actual data from a file specified by a `source` rule or from a similarly-named file in the same directory.

Most of the code for reading rules files and csv files is in this module.

Synopsis

- reader :: MonadIO m => Reader m
- readJournalFromCsv :: Maybe (Either CsvRules FilePath) -> FilePath -> Text -> ExceptT String IO Journal
- dataFileFor :: FilePath -> Maybe FilePath
- rulesFileFor :: FilePath -> FilePath
- tests_RulesReader :: TestTree

# Reader

reader :: MonadIO m => Reader m Source #

# Misc.

readJournalFromCsv :: Maybe (Either CsvRules FilePath) -> FilePath -> Text -> ExceptT String IO Journal Source #

Read a Journal from the given CSV data (and filename, used for error messages), or return an error. Proceed as follows:

1. Conversion rules are provided, or they are parsed from the specified rules file, or from the default rules file for the CSV data file. If rules parsing fails, or the required rules file does not exist, throw an error.
2. Parse the CSV data using the rules, or throw an error.
3. Convert the CSV records to hledger transactions using the rules.
4. Return the transactions as a Journal.

dataFileFor :: FilePath -> Maybe FilePath Source #

Given a rules file path, what would be the corresponding data file ? (Remove a .rules extension.)

rulesFileFor :: FilePath -> FilePath Source #

Given a csv file path, what would be the corresponding rules file ? (Add a .rules extension.)

# Tests

tests_RulesReader :: TestTree Source #

# Orphan instances

ShowErrorComponent String Source # |
Instance details Methods showErrorComponent :: String -> String Source # errorComponentLen :: String -> Int Source #