Safe Haskell | None |
---|---|
Language | Haskell2010 |
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.
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) | |
Typeable (* -> *) Traced | |
(Traceable a, Liftable b tb) => Liftable (a -> b) (Traced a -> tb) |
unknown :: Traceable a => String -> Traced a Source
Create a named thing with no value. Cannot be used where a real value is needed.
tracedD :: Traceable a => Traced a -> TracedD Source
Extract the expression tree from a traced value.
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 -> String Source
Show the expression tree of a traced value, also show the value of each variable.
(%==) :: (Traceable a, Eq a) => Traced a -> Traced a -> Traced Bool infix 4 Source
Comparisons generating traced booleans.
(%/=) :: (Traceable a, Eq a) => Traced a -> Traced a -> Traced Bool infix 4 Source
Comparisons generating traced booleans.
A wrapper for Traced
to show it with full details.
(Enum a, Show a, Typeable * a) => Enum (TracedExp a) | |
Eq a => Eq (TracedExp a) | |
(Floating a, Show a, Typeable * a) => Floating (TracedExp a) | |
(Fractional a, Show a, Typeable * a) => Fractional (TracedExp a) | |
(Integral a, Show a, Typeable * a) => Integral (TracedExp a) | |
(Num a, Show a, Typeable * a) => Num (TracedExp a) | |
Ord a => Ord (TracedExp a) | |
(Real a, Show a, Typeable * a) => Real (TracedExp a) | |
(RealFloat a, Show a, Typeable * a) => RealFloat (TracedExp a) | |
(RealFrac a, Show a, Typeable * a) => RealFrac (TracedExp a) | |
(Traceable a, Show a) => Show (TracedExp a) | |
Typeable (* -> *) TracedExp |