A Transaction consists of a TopLine (information common to all postings, such as the DateTime) and of at least two Postings. This data relationship is so important and useful that it is expressed in these modules. This module has its own functions and re-exports functions and types from other modules in this hierarchy. There are handy accessor functions for the records within each of the family types, but these are not exported due to name conflicts; if you want these simply import the necessary module (maybe qualified).
- data Family p c = Family p c c [c]
- data Child p c = Child c c [c] p
- data Siblings a = Siblings a a [a]
- mapChildrenA :: Applicative m => (a -> m b) -> Family p a -> m (Family p b)
- mapChildren :: (a -> b) -> Family p a -> Family p b
- mapParentA :: Applicative m => (a -> m b) -> Family a c -> m (Family b c)
- mapParent :: (a -> b) -> Family a c -> Family b c
- children :: Family p c -> Siblings (Child p c)
- orphans :: Family p c -> Siblings c
- adopt :: p -> Siblings c -> Family p c
- marryWith :: (p1 -> p2 -> p3) -> (c1 -> c2 -> c3) -> Family p1 c1 -> Family p2 c2 -> Family p3 c3
- marry :: Family p1 c1 -> Family p2 c2 -> Family (p1, p2) (c1, c2)
- divorceWith :: (p1 -> (p2, p3)) -> (c1 -> (c2, c3)) -> Family p1 c1 -> (Family p2 c2, Family p3 c3)
- divorce :: Family (p1, p2) (c1, c2) -> (Family p1 c1, Family p2 c2)
- filterChildren :: (a -> Bool) -> Family p a -> Maybe (Family p a)
- find :: (p -> c -> Bool) -> Family p c -> Maybe c
- collapse :: Siblings (NonEmpty a) -> Siblings a
A Family has one parent (ah, the anomie, sorry) and at least two children.
|Family p c c [c]|
A Child has at least one sibling and a parent.
|Child c c [c] p|
Describes the siblings of a family, but tells you nothing about the parent. There are always at least two Siblings.
|Siblings a a [a]|
Maps over all children, in order starting with child 1, then child 2, then the children in the list from left to right.
Maps over the parent in an Applicative.
Functions to manipulate families
Gets a family's children. The Child type contains information on the parent, and each Child contains information on the other Siblings.
Unites a parent and some siblings into one family; the dual of orphans.
Marries two families into one. This function is rather cruel: if one family has more children than the other family, then the extra children are discarded. That is, all children must pair one-by-one.
marryWith a tupling function.
Splits up a family.
divorceWith an untupling function.
Filters the children. Fails if there are not at least two children after filtering. Retains the original order of the children (after removing the children you don't want.)