penny-lib-0.6.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

evaluate :: Foldable l => l (Token a) -> Maybe aSource

Tokens should be enqueued from left to right, so that tokens on the left side of the sequence are those at the beginning of the expression.

data Token a Source

Instances

Show a => Show (Token a) 

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

:: (PostFam -> Bool)

The predicate to filter the transactions

-> [PostFilterFn]

Post filter specs

-> (PostFam -> PostFam -> Ordering)

The sorter

-> [Transaction]

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

-> [Box LibertyMeta]

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.

newtype ItemIndex Source

Constructors

ItemIndex 

Fields

unItemIndex :: Int
 

type PostFilterFn = ListLength -> ItemIndex -> BoolSource

Specifies options for the post-filter stage.

parseComparer :: (Eq a, Ord a) => String -> Exceptional String (a -> a -> Bool)Source

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

parseTokenList :: [Token a] -> Maybe aSource

Parses a list of tokens. Returns Nothing if the token sequence is invalid (e.g. if two operators are next to each other) or if the resulting RPN expression is bad (there are tokens left on the stack after parsing). Otherwise, returns the expression.

An empty list will fail to parse. The function calling this one must deal with empty lists if those are a possibility.

parsePredicate :: [Token (a -> Bool)] -> Maybe (a -> Bool)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 String IntSource

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

Parsers