summaryrefslogtreecommitdiff
path: root/transfer/examples
diff options
context:
space:
mode:
authorbringert <bringert@cs.chalmers.se>2005-11-30 18:42:45 +0000
committerbringert <bringert@cs.chalmers.se>2005-11-30 18:42:45 +0000
commit12ca29b32b50fd924c5f69a30d204e4332dff4f9 (patch)
tree0515af794def1a1737e1edf9fffad5becc5d73e7 /transfer/examples
parent01d1715994d2e7c58ef97fdd81dd7015a9118b17 (diff)
Transfer: derive instances, not functions.
Diffstat (limited to 'transfer/examples')
-rw-r--r--transfer/examples/exp.tr7
-rw-r--r--transfer/examples/numerals.tr16
-rw-r--r--transfer/examples/stoneage.tr4
-rw-r--r--transfer/examples/test.tr4
-rw-r--r--transfer/examples/widesnake.tr4
5 files changed, 20 insertions, 15 deletions
diff --git a/transfer/examples/exp.tr b/transfer/examples/exp.tr
index d6c077c03..e54b82055 100644
--- a/transfer/examples/exp.tr
+++ b/transfer/examples/exp.tr
@@ -1,3 +1,5 @@
+import prelude
+
data Cat : Type where
Stm : Cat
Exp : Cat
@@ -20,11 +22,12 @@ data Tree : Cat -> Type where
NilStm : Tree ListStm
ConsStm : Tree Stm -> Tree ListStm -> Tree ListStm
-derive composOp Tree
+derive Compos Tree
rename : (String -> String) -> (C : Type) -> Tree C -> Tree C
rename f C t = case t of
V x -> V (f x)
- _ -> composOp_Tree C (rename f) t
+ _ -> composOp ? ? compos_Tree C (rename f) t
+main = rename (const ? ? "apa") Stm (SAss (V "y") (EAdd (EVar (V "x")) (EInt 2))) \ No newline at end of file
diff --git a/transfer/examples/numerals.tr b/transfer/examples/numerals.tr
index 2b6628100..1a6e8d064 100644
--- a/transfer/examples/numerals.tr
+++ b/transfer/examples/numerals.tr
@@ -33,9 +33,15 @@ data Tree : (_ : Cat)-> Type where {
pot3plus : (_ : Tree Sub1000)-> (_ : Tree Sub1000)-> Tree Sub1000000
}
+derive Compos Tree
-num2int : (A : Cat) -> Tree A -> Integer
-num2int _ n = case n of
+monoid_plus_Int : Monoid Integer
+monoid_plus_Int = rec mzero = 0
+ mplus = (\x -> \y -> x + y)
+
+
+num2int : (C : Cat) -> Tree C -> Integer
+num2int C n = case n of
n2 -> 2
n3 -> 3
n4 -> 4
@@ -44,14 +50,10 @@ num2int _ n = case n of
n7 -> 7
n8 -> 8
n9 -> 9
- num x -> num2int ? x
- pot0 x -> num2int ? x
pot01 -> 1
- pot0as1 x -> num2int ? x
pot1 x -> 10 * num2int ? x
pot110 -> 10
pot111 -> 11
- pot1as2 x -> num2int ? x
pot1plus x y -> 10 * num2int ? x + num2int ? y
pot1to19 x -> 10 + num2int ? x
pot2 x -> 100 * num2int ? x
@@ -59,3 +61,5 @@ num2int _ n = case n of
pot2plus x y -> 100 * num2int ? x + num2int ? y
pot3 x -> 1000 * num2int ? x
pot3plus x y -> 1000 * num2int ? x + num2int ? y
+ _ -> composFold ? ? compos_Tree ? monoid_plus_Int C num2int n
+
diff --git a/transfer/examples/stoneage.tr b/transfer/examples/stoneage.tr
index 2b7257f65..3a4b5393b 100644
--- a/transfer/examples/stoneage.tr
+++ b/transfer/examples/stoneage.tr
@@ -203,5 +203,5 @@ data Tree : (_ : Cat)-> Type where {
You_One : Tree NP
}
-derive composOp Tree
-derive composFold Tree
+derive Compos Tree
+
diff --git a/transfer/examples/test.tr b/transfer/examples/test.tr
index 3eac456f1..8d03f2f66 100644
--- a/transfer/examples/test.tr
+++ b/transfer/examples/test.tr
@@ -1,3 +1 @@
-import nat
-
-main = natToInt (intToNat 100) \ No newline at end of file
+main = ? \ No newline at end of file
diff --git a/transfer/examples/widesnake.tr b/transfer/examples/widesnake.tr
index 23ffac631..e27bd5981 100644
--- a/transfer/examples/widesnake.tr
+++ b/transfer/examples/widesnake.tr
@@ -9,11 +9,11 @@ monoid_Bool = rec
isSnake : (A : Tree) -> Tree A -> Bool
isSnake _ x = case x of
Snake -> True
- _ -> composFold_Tree Bool monoid_Bool ? isSnake x
+ _ -> composFold ? ? compos_Tree Bool monoid_Bool ? isSnake x
wideSnake : (A : Cat) -> Tree A -> Tree A
wideSnake _ x = case x of
Wide y -> let y' : CN = wideSnake ? y
in if isSnake CN y' then Thick y' else Wide y'
- _ -> composOp_Tree ? wideSnake x
+ _ -> composOp ? ? compos_Tree ? wideSnake x