-- 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.1


-- | Simple reflection of haskell expressions containing variables.
module Debug.SimpleReflect.Expr

-- | A reflected expression
data Expr

-- | Conversion from <tt>Expr</tt> 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 <tt>reduce (1 + 2 + 3 + 4) == 3 + 3 + 4</tt>
reduce :: Expr -> Expr

-- | Show all reduction steps when evaluating an expression.
reduction :: Expr -> [Expr]
instance Eq Associativity
instance Monoid Expr
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 <tt>Expr</tt>, except for <tt>f</tt>, <tt>g</tt>
--   and <tt>h</tt>, which are generic functions. This means that <tt>show
--   (f x :: Expr) == "f x"</tt>, but that <tt>show (a x :: Expr)</tt>
--   gives a type error. On the other hand, the type of <tt>g</tt> in
--   <tt>show (f g)</tt> 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:
--   
--   <pre>
--   &gt; sum [1..5] :: Expr
--   0 + 1 + 2 + 3 + 4 + 5
--   </pre>
--   
--   <pre>
--   &gt; foldr1 f [a,b,c]
--   f a (f b c)
--   </pre>
--   
--   <pre>
--   &gt; take 5 (iterate f x)
--   [x,f x,f (f x),f (f (f x)),f (f (f (f x)))]
--   </pre>
--   
--   <pre>
--   &gt; mapM_ print $ reduction (1+2*(3+4))
--   1 + 2 * (3 + 4)
--   1 + 2 * 7
--   1 + 14
--   15
--   </pre>
module Debug.SimpleReflect
