use Q style
[clean-tests.git] / datatype / Main.hs
index 35d5ae6..ec7c51b 100644 (file)
@@ -8,6 +8,7 @@ import Language
 
 import Compiler
 import Printer
+import Interpreter
 import Language.Quote
 
 import Tuple
@@ -39,8 +40,9 @@ main
 --  >> putStrLn (show $ interpret 50 <$> runCompiler (unmain f6))
 --  >> putStrLn (runPrint $ unmain f7)
 --  >> putStrLn (show $ interpret 50 <$> runCompiler (unmain f7))
---  >> putStrLn (runPrint $ unmain f7')
---  >> putStrLn (show $ interpret 100 <$> runCompiler (unmain f7'))
+  >> putStrLn (runPrint $ unmain f7')
+  >> putStrLn (show $ interpret 100 <$> runCompiler (unmain f7'))
+  >> putStrLn (show $ runInterpreter (unmain f7'))
 
 e0 :: Expression v => v Int
 e0 = lit 2 -. lit 8
@@ -105,6 +107,7 @@ f6 :: (TupleR' v, Expression v, Function (v (TupleR Int Char)) v) => Main (v Int
 f6
     = fun ( \firstfun->(\l->[dsl|case l of
                 TupleR {first=f} -> f
+                t -> t.first
             |])
 --    :- Main {unmain=sumf $ lit (1 :: Int) `cons` (lit 2 `cons` (lit 3 `cons` nil))}
     :- Main {unmain=firstfun $ tupler (lit 1) (lit 'c')}
@@ -124,6 +127,7 @@ f7'
     =    fun ( \fromto->(
             \(from, to)->[dsl|if from > to then nil else from `cons` fromto (from + 1, to)|]
     ) :- fun ( \mullist->(
+--            \l->if' (isNil l) (lit 1) (consf0' l *. mullist (consf1' l))
             \l->[dsl|case l of
                 Cons e rest -> e * mullist(rest)
                 Nil -> 1