support all other patterns and nested patterns
[clean-tests.git] / datatype / Main.hs
index 42e0473..72dede0 100644 (file)
@@ -1,6 +1,7 @@
 {-# LANGUAGE TemplateHaskell #-}
 {-# LANGUAGE FlexibleContexts #-}
 {-# LANGUAGE QuasiQuotes #-}
+{-# LANGUAGE DeriveGeneric #-}
 module Main where
 
 import Language
@@ -88,9 +89,17 @@ f5 :: (List' v, Expression v, Function (v (List Int)) v) => Main (v Int)
 f5
     = fun ( \sumf->(\l->[cp|case l of
                 Cons e rest -> e +. sumf rest
-                _ -> 0
---                Cons e (Cons f rest) -> e +. f +. sum rest
-{-blup-}
+                Nil -> 0
             |])
+--    :- Main {unmain=sumf $ lit (1 :: Int) `cons` (lit 2 `cons` (lit 3 `cons` nil))}
     :- Main {unmain=sumf $ lit (1 :: Int) `cons` (lit 2 `cons` (lit 3 `cons` nil))}
     )
+
+f6 :: (TupleR' v, Expression v, Function (v (TupleR Int Char)) v) => Main (v Int)
+f6
+    = fun ( \firstfun->(\l->[cp|case l of
+                TupleR{first=f} -> f
+            |])
+--    :- Main {unmain=sumf $ lit (1 :: Int) `cons` (lit 2 `cons` (lit 3 `cons` nil))}
+    :- Main {unmain=firstfun $ tupler (lit 1) (lit 'c')}
+    )