Safe Haskell | None |
---|
Copper - the Penny parser.
The parse functions in this module only accept lists of files rather than individual files because in order to correctly assign the global serials a single function must be able to see all the transactions, not just the transactions in a single file.
- parse :: [(Filename, FileContents)] -> Exceptional ErrorMsg Ledger
- open :: [String] -> IO Ledger
- data Item
- mapItem :: (Comment -> Comment) -> (PricePoint -> PricePoint) -> (Transaction -> Transaction) -> Item -> Item
- mapItemA :: Applicative a => (Comment -> a Comment) -> (PricePoint -> a PricePoint) -> (Transaction -> a Transaction) -> Item -> a Item
- newtype Ledger = Ledger {}
- mapLedger :: (Item -> Item) -> Ledger -> Ledger
- mapLedgerA :: Applicative a => (Item -> a Item) -> Ledger -> a Ledger
- newtype Comment = Comment {}
- newtype FileContents = FileContents {}
- data ErrorMsg
- data GroupSpec
- = NoGrouping
- | GroupLarge
- | GroupAll
- data GroupSpecs = GroupSpecs {}
- ledger :: GroupSpecs -> Ledger -> Maybe Text
Convenience functions to read and parse files
parse :: [(Filename, FileContents)] -> Exceptional ErrorMsg LedgerSource
open :: [String] -> IO LedgerSource
Reads and parses the given files. If any of the files is -
,
reads standard input. If the list of files is empty, reads standard
input. IO errors are not caught. Parse errors are printed to
standard error and the program will exit with a failure.
Types for things found in ledger files
mapItem :: (Comment -> Comment) -> (PricePoint -> PricePoint) -> (Transaction -> Transaction) -> Item -> ItemSource
mapItemA :: Applicative a => (Comment -> a Comment) -> (PricePoint -> a PricePoint) -> (Transaction -> a Transaction) -> Item -> a ItemSource
mapLedgerA :: Applicative a => (Item -> a Item) -> Ledger -> a LedgerSource
Rendering
Specifies how to perform digit grouping when rendering a quantity. All grouping groups into groups of 3 digits.
NoGrouping | Do not perform any digit grouping |
GroupLarge | Group digits, but only if the number to be grouped is greater than 9,999 (if grouping the whole part) or if there are more than 4 decimal places (if grouping the fractional part). |
GroupAll | Group digits whenever there are at least four decimal places. |