improvements to examples/
[coq-hetmet.git] / examples / Demo.hs
index 7a6aee8..fb8666f 100644 (file)
@@ -1,14 +1,33 @@
 {-# OPTIONS_GHC -XModalTypes -fflatten -funsafe-skolemize -dcore-lint -XScopedTypeVariables -fsimpleopt-before-flatten #-}
-module Demo (demo) where
+module Demo ({-sample1,sample2,-}sample5,sample6) where
 
-{-
-demo const mult =
+sample5 :: forall c . (Int -> <{Int}>@c) ->  <{Int -> Int -> Int}>@c -> <{Int -> Int}>@c
+sample5 const <[ (*) ]> =
+ <{ \y ->
+    let   foo  = (~~(const 3) * foo) * y
+    in    foo }>
+
+sample6 :: forall c . (Int -> <{Int}>@c) -> <{Int -> Int -> Int}>@c -> <{Int -> Int}>@c
+sample6 const <{ (*) }> = pow 6
+   where
+     --pow :: Int -> <{ Int -> Int }>@a
+     pow 0 = <{ \x -> ~~(const 1) }>
+     pow 1 = <{ \x -> x }>
+     pow n = <{ \x -> x * ~~(pow (n - 1)) x }>
+
+demo2 ::
+    forall c . 
+         (Int -> <{Int}>@c) -> 
+        <{Int -> Int -> Int}>@c ->
+        <{Int -> Int}>@c
+
+demo2 const mult =
   <{ \y ->
      ~~mult
-       (~~mult y y)
+       (~~(const 1))
        (~~mult y y)
    }>
--}
+
 
 
 
@@ -54,12 +73,6 @@ demo const mult =
 
 
 
-demo const mult =
- <{ \y ->
-    let   foo  = ~~mult (~~mult foo (~~mult y foo)) y
-    in    foo }>
-
-
 
 
 
@@ -143,11 +156,6 @@ demo const mult =
       in  four
     }>
 -}
-demo ::
-    forall c . 
-         (Int -> <{Int}>@c) -> 
-        <{Int -> Int -> Int}>@c ->
-        <{Int -> Int}>@c
 
 {-
 demo const mult =