-- 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.3.3 -- | 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, overloaded, function variable fun :: FromExpr a => String -> a -- | This data type specifies the associativity of operators: left, right -- or none. data Associativity InfixL :: Associativity Infix :: Associativity InfixR :: Associativity -- | An infix operator with the given associativity, precedence and name op :: Associativity -> Int -> String -> Expr -> Expr -> Expr -- | 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 GHC.Classes.Eq Debug.SimpleReflect.Expr.Associativity instance Debug.SimpleReflect.Expr.FromExpr Debug.SimpleReflect.Expr.Expr instance (GHC.Show.Show a, Debug.SimpleReflect.Expr.FromExpr b) => Debug.SimpleReflect.Expr.FromExpr (a -> b) instance GHC.Num.Num Debug.SimpleReflect.Expr.Expr instance GHC.Real.Integral Debug.SimpleReflect.Expr.Expr instance GHC.Real.Fractional Debug.SimpleReflect.Expr.Expr instance GHC.Float.Floating Debug.SimpleReflect.Expr.Expr instance Data.Semigroup.Semigroup Debug.SimpleReflect.Expr.Expr instance GHC.Base.Monoid Debug.SimpleReflect.Expr.Expr instance GHC.Show.Show Debug.SimpleReflect.Expr.Expr instance GHC.Classes.Eq Debug.SimpleReflect.Expr.Expr instance GHC.Classes.Ord Debug.SimpleReflect.Expr.Expr instance GHC.Real.Real Debug.SimpleReflect.Expr.Expr instance GHC.Enum.Enum Debug.SimpleReflect.Expr.Expr instance GHC.Enum.Bounded Debug.SimpleReflect.Expr.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 -- | A non-associative infix 7 operator (⊗) :: Expr -> Expr -> Expr infix 7 ⊗ -- | A non-associative infix 6 operator (⊕) :: Expr -> Expr -> Expr infix 6 ⊕ -- | A non-associative infix 9 operator (@@) :: Expr -> Expr -> Expr infix 9 @@ -- | 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