penny-lib-0.16.0.0: Extensible double-entry accounting system - library

Safe HaskellNone

Penny.Liberty

Contents

Description

Liberty - Penny command line parsing utilities

Both Cabin and Zinc share various functions that aid in parsing command lines. For instance both the Postings report and the Zinc postings filter use common command-line options. However, Zinc already depends on Cabin. To avoid a cyclic dependency whereby Cabin would also depend on Zinc, functions formerly in Zinc that Cabin will also find useful are relocated here, to Liberty.

Synopsis

Documentation

newtype FilteredNum Source

A serial indicating how a post relates to all other postings that made it through the filtering phase.

Constructors

FilteredNum 

Instances

newtype SortedNum Source

A serial indicating how a posting relates to all other postings that have been sorted.

Constructors

SortedNum 

Fields

unSortedNum :: Serial
 

Instances

data LibertyMeta Source

All metadata from Liberty.

Instances

xactionsToFilteredSource

Arguments

:: LPdct

The predicate to filter the transactions

-> [PostFilterFn]

Post filter specs

-> (Posting -> Posting -> Ordering)

The sorter

-> [Transaction]

The transactions to work on (probably parsed in from Copper)

-> ([Chunk], [(LibertyMeta, Posting)])

Sorted, filtered postings

Takes a list of transactions, splits them into PostingChild instances, filters them, post-filters them, sorts them, and places them in Box instances with Filtered serials. Also returns Chunks containing a description of the evalutation process.

newtype ItemIndex Source

Constructors

ItemIndex 

Fields

unItemIndex :: Int
 

type PostFilterFn = ListLength -> ItemIndex -> BoolSource

Specifies options for the post-filter stage.

parseComparer :: String -> (Ordering -> Pdct a) -> Exceptional Error (Pdct a)Source

Parses comparers given on command line to a function. Fails if the string given is invalid.

parsePredicate :: ExprDesc -> [Token a] -> Exceptional Error (Pdct a)Source

Parses a list of tokens to obtain a predicate. Deals with an empty list of tokens by returning a predicate that is always True. Fails if the list of tokens is not empty and the parse fails.

parseInt :: String -> Exceptional Error IntSource

Parses exactly one integer; fails if it cannot read exactly one.

exprDesc :: [OptSpec ExprDesc]Source

Both Infix and RPN options.

Parsers

Version

versionSource

Arguments

:: Version

Version of binary

-> OptSpec (IO a) 

Parses the --version option and returns an IO action that prints it and exits successfully. You supply the version of the executable, as there is no easy way to get that automatically.

Output

output :: OptSpec (Text -> IO ())Source

An option for where the user would like to send output.

processOutput :: [Text -> IO ()] -> Text -> IO ()Source

Given a list of output options, returns a single IO action to write to all given files. If the list was empty, returns an IO action that writes to standard output.

Errors

type Error = TextSource

A multiline Text that holds an error message.