Safe Haskell | Safe-Infered |
---|
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.
- data Error
- type MatcherFactory = CaseSensitive -> Text -> Exceptional Text (Text -> Bool)
- evaluate :: Foldable l => l (Token a) -> Maybe a
- data Token a
- newtype FilteredNum = FilteredNum {}
- newtype SortedNum = SortedNum {}
- data LibertyMeta
- xactionsToFiltered :: (PostFam -> Bool) -> [PostFilterFn] -> (PostFam -> PostFam -> Ordering) -> [Transaction] -> [Box LibertyMeta]
- newtype ListLength = ListLength {
- unListLength :: Int
- newtype ItemIndex = ItemIndex {
- unItemIndex :: Int
- type PostFilterFn = ListLength -> ItemIndex -> Bool
- parseComparer :: (Eq a, Ord a) => String -> Maybe (a -> a -> Bool)
- processPostFilters :: [PostFilterFn] -> [a] -> [a]
- parseTokenList :: [Token a] -> Maybe a
- parsePredicate :: [Token (a -> Bool)] -> Maybe (a -> Bool)
- type Operand = Operand (PostFam -> Bool)
- parseOperand :: Parser (DateTime -> DefaultTimeZone -> RadGroup -> CaseSensitive -> MatcherFactory -> Exceptional Error Operand)
- parsePostFilter :: Parser (Exceptional Error PostFilterFn)
- parseMatcherSelect :: Parser MatcherFactory
- parseCaseSelect :: Parser CaseSensitive
- parseOperator :: Parser (Token (a -> Bool))
- type Orderer = PostFam -> PostFam -> Ordering
- parseSort :: Parser (Exceptional Error Orderer)
Documentation
type MatcherFactory = CaseSensitive -> Text -> Exceptional Text (Text -> Bool)Source
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.
newtype FilteredNum Source
A serial indicating how a post relates to all other postings that made it through the filtering phase.
A serial indicating how a posting relates to all other postings that have been sorted.
:: (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 ListLength Source
type PostFilterFn = ListLength -> ItemIndex -> BoolSource
Specifies options for the post-filter stage.
parseComparer :: (Eq a, Ord a) => String -> Maybe (a -> a -> Bool)Source
Parses comparers given on command line to a function.
processPostFilters :: [PostFilterFn] -> [a] -> [a]Source
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.
Parsers
parseOperand :: Parser (DateTime -> DefaultTimeZone -> RadGroup -> CaseSensitive -> MatcherFactory -> Exceptional Error Operand)Source
Parses operands.
parseOperator :: Parser (Token (a -> Bool))Source