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

Safe HaskellNone

Penny.Steel.Pdct

Description

Trees of predicates.

Exports names which conflict with Prelude names, so you probably want to import this module qualified.

Synopsis

Documentation

data Pdct a Source

A tree of predicates.

Constructors

Pdct Label (Node a) 

Instances

Show (Pdct a) 

always :: Pdct aSource

Returns a tree that is always True.

never :: Pdct aSource

Returns a tree that is always False.

and :: [Pdct a] -> Pdct aSource

or :: [Pdct a] -> Pdct aSource

not :: Pdct a -> Pdct aSource

operand :: Text -> (a -> Bool) -> Pdct aSource

Creates a new operand. The Pdct is Just True or Just False, never Nothing.

neverFalse :: Pdct a -> Pdct aSource

Turns an existing Pdct to one that never says False. If the underlying predicate returns Just True, the new Pdct also returns Just True. Otherwise, the Pdct returns Nothing. Has no effect on non-Operand Pdct.

neverTrue :: Pdct a -> Pdct aSource

Turns an existing Pdct to one that never says True. If the underlying predicate returns Just False, the new Pdct also returns Just False. Otherwise, the Pdct returns Nothing. Has no effect on non-Operand Pdct.

(&&&) :: Pdct a -> Pdct a -> Pdct aSource

(|||) :: Pdct a -> Pdct a -> Pdct aSource

rename :: (Text -> Text) -> Pdct a -> Pdct aSource

Renames the top level of the Pdct. The function you pass will be applied to the old name.

eval :: Pdct a -> a -> Maybe BoolSource

Evaluates a Pdct.

evaluateSource

Arguments

:: IndentAmt

Indent each level by this many spaces.

-> ShowDiscards

If True, show discarded test results; otherwise, hide them.

-> a

The subject to evaluate

-> Level

How many levels deep in the tree we are. Start at level 0. This determines the level of indentation.

-> Pdct a 
-> (Maybe Bool, [Chunk]) 

Verbosely evaluates a Pdct.

boxPdct :: (b -> a) -> Pdct a -> Pdct bSource

Given a function that un-boxes values of type b, changes a Pdct from type a to type b.

boxNode :: (b -> a) -> Node a -> Node bSource

Given a function that un-boxes values of type b, changes a Node from type a to type b.