Index: sizechecking/branches/macs/Ops.hs
===================================================================
--- sizechecking/branches/macs/Ops.hs	(revision 20)
+++ sizechecking/branches/macs/Ops.hs	(revision 21)
@@ -1,3 +1,37 @@
+{-# LANGUAGE FlexibleInstances #-}
+
 module Ops where
 
+import qualified Data.Supply as S
+import Prelude (String, Int, ($), (.))
+import qualified Prelude
 import Lambda
+
+class (Lambda l) => LOps l where
+    infixop :: String -> Int -> (a -> b -> c) -> l a -> l b -> l c
+    fun :: String -> a -> l a
+
+    (+) :: l Int -> l Int -> l Int
+    (+) = infixop "+" 4 (Prelude.+)
+
+    (-) :: l Int -> l Int -> l Int
+    (-) = infixop "-" 4 (Prelude.-)
+
+    (*) :: l Int -> l Int -> l Int
+    (*) = infixop "*" 5 (Prelude.*)
+
+
+instance LOps Q where
+    infixop _ _ f lhs rhs = Q (eval lhs `f` eval rhs)
+    fun _ = Q
+
+instance LOps S where
+    fun name _ = S (\_ p -> Prelude.showsPrec p name)
+
+    infixop name prec _ lhs rhs = S(\s p ->
+        let (s1, s2) = S.split2 s
+        in Prelude.showParen (p Prelude.> prec) $
+            unS lhs s1 prec .
+            Prelude.showString name .
+            unS rhs s2 (Prelude.succ prec)
+        )
Index: sizechecking/branches/macs/tests/LambdaTest.hs
===================================================================
--- sizechecking/branches/macs/tests/LambdaTest.hs	(revision 20)
+++ sizechecking/branches/macs/tests/LambdaTest.hs	(revision 21)
@@ -1,10 +1,27 @@
 {-# LANGUAGE NoMonomorphismRestriction #-}
 
+module Tests.LambdaTest where
+
 import Lambda
-import Ops
-import Prelude ( ($), Int )
+import Prelude ( ($), Int, (==), return, sequence, (>>=), and, (.), IO, Bool )
+import qualified Control.Monad
 
 test1 :: (Lambda l) => l Int
 test1 = app (lam $ \_ -> const 3) (const 2)
 
+test1ast :: IO Bool
+test1ast = do
+    t <- ast test1
+    return $ t "" == "(Î»a.3) 2"
 
+test1eval :: IO Bool
+test1eval = return $ eval test1 == 3
+
+tests :: [IO Bool]
+tests = [ 
+      test1ast
+    , test1eval
+    ]
+
+runTests :: IO Bool
+runTests = Control.Monad.liftM and $ sequence tests
Index: sizechecking/branches/macs/tests/Main.hs
===================================================================
--- sizechecking/branches/macs/tests/Main.hs	(revision 21)
+++ sizechecking/branches/macs/tests/Main.hs	(revision 21)
@@ -0,0 +1,13 @@
+module Tests.Main where
+
+import qualified Tests.LambdaTest (tests)
+import qualified Tests.OpsTest (tests)
+import Control.Monad
+
+tests :: [IO Bool]
+tests = Tests.LambdaTest.tests 
+     ++ Tests.OpsTest.tests
+
+main :: IO ()
+main = liftM and ( sequence tests ) >>= print
+
Index: sizechecking/branches/macs/tests/OpsTest.hs
===================================================================
--- sizechecking/branches/macs/tests/OpsTest.hs	(revision 21)
+++ sizechecking/branches/macs/tests/OpsTest.hs	(revision 21)
@@ -0,0 +1,27 @@
+{-# LANGUAGE NoMonomorphismRestriction #-}
+
+module Tests.OpsTest where
+
+import Ops
+import Lambda
+import Prelude ( ($), Int, (==), return, sequence, (>>=), and, (.), IO, Bool )
+import qualified Control.Monad
+
+test1 :: (LOps l) => l Int
+test1 = app (lam $ \x -> const 3 + x) (const 2)
+
+test1ast :: IO Bool
+test1ast = do
+    t <- ast test1
+    return $ t "" == "(Î»a.3+a) 2"
+test1eval :: IO Bool
+test1eval = return $ eval test1 == 5
+
+tests :: [IO Bool]
+tests = [ 
+      test1ast
+    , test1eval
+    ]
+
+runTests :: IO Bool
+runTests = Control.Monad.liftM and $ sequence tests
