-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Simple reflection of expressions containing variables -- -- This package allows simple reflection of expressions containing -- variables. Reflection here means that a Haskell expression is turned -- into a string. The primary aim of this package is teaching and -- understanding; there are no options for manipulating the reflected -- expressions beyond showing them. @package simple-reflect @version 0.1 -- | Simple reflection of haskell expressions containing variables. module Debug.SimpleReflect.Expr -- | A reflected expression data Expr -- | Conversion from Expr to other types class FromExpr a fromExpr :: (FromExpr a) => Expr -> a -- | A variable with the given name var :: String -> Expr -- | A generic function variable fun :: (FromExpr a) => String -> a -- | Force something to be an expression. expr :: Expr -> Expr -- | Reduce (evaluate) an expression once. -- -- For example reduce (1 + 2 + 3 + 4) == 3 + 3 + 4 reduce :: Expr -> Expr -- | Show all reduction steps when evaluating an expression. reduction :: Expr -> [Expr] instance Eq Fixity instance Bounded Expr instance Enum Expr instance Floating Expr instance Fractional Expr instance Integral Expr instance Real Expr instance Num Expr instance Ord Expr instance Eq Expr instance (Show a, FromExpr b) => FromExpr (a -> b) instance FromExpr Expr instance Show Expr -- | Single letter variable names. -- -- All names have type Expr, except for f, g -- and h, which are generic functions. This means that show -- (f x :: Expr) == "f x", but that show (a x :: Expr) -- gives a type error. On the other hand, the type of g in -- show (f g) is ambiguous. module Debug.SimpleReflect.Vars a :: Expr b :: Expr c :: Expr d :: Expr e :: Expr i :: Expr j :: Expr k :: Expr l :: Expr m :: Expr n :: Expr o :: Expr p :: Expr q :: Expr r :: Expr s :: Expr t :: Expr u :: Expr v :: Expr w :: Expr x :: Expr y :: Expr z :: Expr f :: (FromExpr a) => a f' :: (FromExpr a) => a f'' :: (FromExpr a) => a g :: (FromExpr a) => a h :: (FromExpr a) => a -- | Simple reflection of haskell expressions containing variables. -- -- Some examples: -- --
-- > sum [1..5] :: Expr -- 0 + 1 + 2 + 3 + 4 + 5 ---- --
-- > foldr1 f [a,b,c] -- f a (f b c) ---- --
-- > take 5 (iterate f x) -- [x,f x,f (f x),f (f (f x)),f (f (f (f x)))] ---- --
-- > mapM_ print $ reduction (1+2*(3+4)) -- 1 + 2 * (3 + 4) -- 1 + 2 * 7 -- 1 + 14 -- 15 --module Debug.SimpleReflect