traced-2009.4.3: Simple evaluation trace



The Traced module provides a simple way of tracing expression evaluation. A value of type Traced a has both a value of type a and an expression tree that describes how the value was computed.

There are instances for the Traced type for all numeric classes to make it simple to trace numeric expressions.

The expression tree associated with a traced value is exactly that: a tree. But evaluation of expressions in Haskell typically has sharing to avoid recomputation. This sharing can be recovered by the (impure) reShare function.




data Traced a Source

Traced values of some type.

traced :: Traceable a => a -> Traced aSource

Create a traced value.

named :: Traceable a => String -> a -> Traced aSource

Create a named traced value.

nameTraced :: Traceable a => String -> Traced a -> Traced aSource

Add a named to a traced value.

unknown :: Traceable a => String -> Traced aSource

Create a named thing with no value. Cannot be used where a real value is needed.

unTraced :: Traced a -> aSource

Extract the real value from a traced value.

tracedD :: Traceable a => Traced a -> TracedDSource

Extract the expression tree from a traced value.

data TracedD Source

Expression tree for a traced value.

unTracedD :: Traceable a => TracedD -> Maybe (Traced a)Source

Convert an expression tree to a traced value, if the types are correct.

class (Typeable a, Show a) => Traceable a Source


(Typeable a, Show a) => Traceable a 

liftT :: Liftable a b => Name -> Fixity -> a -> bSource

liftFun :: Liftable a b => Name -> a -> bSource

showAsExp :: Traceable a => Traced a -> StringSource

Show the expression tree of a traced value.

showAsExpFull :: Traceable a => Traced a -> StringSource

Show the expression tree of a traced value, also show the value of each variable.

simplify :: Traced a -> Traced aSource

Simplify an expression tree.

ifT :: Traceable a => Traced Bool -> Traced a -> Traced a -> Traced aSource

Traced version of if.

(%/=) :: (Traceable a, Eq a) => Traced a -> Traced a -> Traced BoolSource

Comparisons generating traced booleans.

data TracedExp a Source

A wrapper for Traced to show it with full details.