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.

$examples

- data Traced a
- traced :: Traceable a => a -> Traced a
- named :: Traceable a => String -> a -> Traced a
- nameTraced :: Traceable a => String -> Traced a -> Traced a
- unknown :: Traceable a => String -> Traced a
- unTraced :: Traced a -> a
- tracedD :: Traceable a => Traced a -> TracedD
- data TracedD
- unTracedD :: Traceable a => TracedD -> Maybe (Traced a)
- class (Typeable a, Show a) => Traceable a
- liftT :: Liftable a b => Name -> Fixity -> a -> b
- liftFun :: Liftable a b => Name -> a -> b
- class Liftable a b | a -> b, b -> a
- showAsExp :: Traceable a => Traced a -> String
- showAsExpFull :: Traceable a => Traced a -> String
- reShare :: Traceable a => Traced a -> Traced a
- simplify :: Traced a -> Traced a
- ifT :: Traceable a => Traced Bool -> Traced a -> Traced a -> Traced a
- (%==) :: (Traceable a, Eq a) => Traced a -> Traced a -> Traced Bool
- (%/=) :: (Traceable a, Eq a) => Traced a -> Traced a -> Traced Bool
- (%<) :: (Traceable a, Ord a) => Traced a -> Traced a -> Traced Bool
- (%<=) :: (Traceable a, Ord a) => Traced a -> Traced a -> Traced Bool
- (%>) :: (Traceable a, Ord a) => Traced a -> Traced a -> Traced Bool
- (%>=) :: (Traceable a, Ord a) => Traced a -> Traced a -> Traced Bool
- (%&&) :: Traced Bool -> Traced Bool -> Traced Bool
- (%||) :: Traced Bool -> Traced Bool -> Traced Bool
- tnot :: Traced Bool -> Traced Bool
- data TracedExp a
- tracedExp :: Traceable a => a -> TracedExp a
- namedExp :: Traceable a => String -> a -> TracedExp a

# Documentation

Traced values of some type.

Typeable1 Traced | |

Liftable Bool (Traced Bool) | |

Liftable Double (Traced Double) | |

Liftable Float (Traced Float) | |

Liftable Int (Traced Int) | |

Liftable Integer (Traced Integer) | |

Liftable Ordering (Traced Ordering) | |

Liftable () (Traced ()) | |

(Traceable a, Enum a) => Enum (Traced a) | |

Eq a => Eq (Traced a) | |

(Traceable a, Floating a) => Floating (Traced a) | |

(Traceable a, Fractional a) => Fractional (Traced a) | |

(Traceable a, Integral a) => Integral (Traced a) | |

Data a => Data (Traced a) | |

(Traceable a, Num a) => Num (Traced a) | |

Ord a => Ord (Traced a) | |

(Read a, Traceable a) => Read (Traced a) | |

(Traceable a, Real a) => Real (Traced a) | |

(Traceable a, RealFloat a) => RealFloat (Traced a) | |

(Traceable a, RealFrac a) => RealFrac (Traced a) | |

Show a => Show (Traced a) | |

(Traceable a, Liftable b tb) => Liftable (a -> b) (Traced a -> tb) |

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

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

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.

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

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

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

Comparisons generating traced booleans.

A wrapper for `Traced`

to show it with full details.

Typeable1 TracedExp | |

(Enum a, Show a, Typeable a) => Enum (TracedExp a) | |

Eq a => Eq (TracedExp a) | |

(Floating a, Typeable a) => Floating (TracedExp a) | |

(Fractional a, Typeable a) => Fractional (TracedExp a) | |

(Integral a, Typeable a) => Integral (TracedExp a) | |

(Num a, Typeable a) => Num (TracedExp a) | |

Ord a => Ord (TracedExp a) | |

(Real a, Typeable a) => Real (TracedExp a) | |

(RealFloat a, Typeable a) => RealFloat (TracedExp a) | |

(RealFrac a, Typeable a) => RealFrac (TracedExp a) | |

(Traceable a, Show a) => Show (TracedExp a) |