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

Safe HaskellSafe-Infered

Penny.Copper.Util

Synopsis

Documentation

lexeme :: Parser a -> Parser aSource

Creates a new parser that behaves like the old one, but also parses any whitespace remaining afterward.

eol :: Parser ()Source

Parses any trailing whitespace followed by a newline followed by additional whitespace.

spaces :: Parser ()Source

Parses a run of spaces.

checkText :: HasText a => NonEmpty (Char -> Bool, b) -> a -> Maybe bSource

Applied to a non-empty list of pairs, with the first element of the pair being a predicate that returns True if a character is OK and the second element being something of an arbitrary type, and to something that has a Text. The pairs must be ordered from most restrictive to least restrictive predicates. If at least one of the predicates indicates that the Text is valid, returns the leftmost b associated with that predicate. If none of the predicates indicates that the Text is valid, returns the rightmost error.

Here, most restrictive means the predicate that indicates True for the narrowest range of characters, while least restrictive means the predicate that indicates True for the widest range of characters.

listIsOKSource

Arguments

:: HasTextNonEmptyList a 
=> (Char -> Bool)

Returns True for characters that are allowed

-> a 
-> Bool 

firstCharOfListIsOKSource

Arguments

:: HasTextNonEmptyList a 
=> (Char -> Bool)

Returns True if the first character is allowed

-> a 
-> Bool 

renMaybe :: Maybe a -> (a -> Maybe Text) -> Maybe TextSource

Takes a field that may or may not be present and a function that renders it. If the field is not present at all, returns an empty Text. Otherwise will succeed or fail depending upon whether the rendering function succeeds or fails.

txtWords :: [Text] -> TextSource

Merges a list of words into one Text; however, if any given Text is empty, that Text is first dropped from the list.