summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbringert <bringert@cs.chalmers.se>2005-11-29 18:15:15 +0000
committerbringert <bringert@cs.chalmers.se>2005-11-29 18:15:15 +0000
commit5b9249a422cb1ac172d6b5f1f03d5cde629d6216 (patch)
tree357db7dd0d5d6340bbca68803be6d26807e3c552
parentf6159d4bffe1f163914a41f33afea36a499bc89a (diff)
Split widesnake example. Changed examples to use rec and sig keywords.
-rw-r--r--transfer/examples/overload.tr6
-rw-r--r--transfer/examples/pair.tr4
-rw-r--r--transfer/examples/stoneage.tr16
-rw-r--r--transfer/examples/widesnake.tr19
4 files changed, 24 insertions, 21 deletions
diff --git a/transfer/examples/overload.tr b/transfer/examples/overload.tr
index 58ef1b7ce..cb3862d7a 100644
--- a/transfer/examples/overload.tr
+++ b/transfer/examples/overload.tr
@@ -1,15 +1,15 @@
Additive : Type -> Type
-Additive A = { zero : A; plus : A -> A -> A }
+Additive A = sig { zero : A; plus : A -> A -> A }
additive_Integer : Additive Integer
-additive_Integer = { zero = 0; plus = prim_add_Int }
+additive_Integer = rec { zero = 0; plus = prim_add_Int }
sum : (A:Type) -> Additive A -> List A -> A
sum _ d (Nil _) = d.zero
sum A d (Cons _ x xs) = d.plus x (sum A d xs)
Showable : Type -> Type
-Showable A = { show : A -> String }
+Showable A = sig { show : A -> String }
--Compositional : Type -> Type
diff --git a/transfer/examples/pair.tr b/transfer/examples/pair.tr
index bdd517d9c..1b70411e8 100644
--- a/transfer/examples/pair.tr
+++ b/transfer/examples/pair.tr
@@ -1,8 +1,8 @@
Pair : Type -> Type -> Type
-Pair A B = { p1 : A; p2 : B }
+Pair A B = sig { p1 : A; p2 : B }
pair : (A:Type) -> (B:Type) -> A -> B -> Pair A B
-pair _ _ x y = { p1 = x; p2 = y }
+pair _ _ x y = rec { p1 = x; p2 = y }
fst : (A:Type) -> (B:Type) -> Pair A B -> A
fst _ _ p = case p of Pair _ _ x _ -> x
diff --git a/transfer/examples/stoneage.tr b/transfer/examples/stoneage.tr
index f67aa66e7..2b7257f65 100644
--- a/transfer/examples/stoneage.tr
+++ b/transfer/examples/stoneage.tr
@@ -1,5 +1,3 @@
-import bool
-
data Cat : Type where {
CN : Cat ;
NP : Cat ;
@@ -207,17 +205,3 @@ data Tree : (_ : Cat)-> Type where {
derive composOp Tree
derive composFold Tree
-
-monoid_Bool = { zero = False; plus = \x -> \y -> x && y }
-
-isSnake : (A : Tree) -> Tree A -> Bool
-isSnake _ x = case x of
- Snake -> True
- _ -> composFold_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
-
diff --git a/transfer/examples/widesnake.tr b/transfer/examples/widesnake.tr
new file mode 100644
index 000000000..23ffac631
--- /dev/null
+++ b/transfer/examples/widesnake.tr
@@ -0,0 +1,19 @@
+import bool
+import stoneage
+
+monoid_Bool : sig { zero : Bool; plus : Bool -> Bool -> Bool }
+monoid_Bool = rec
+ zero = False
+ plus = \x -> \y -> x && y
+
+isSnake : (A : Tree) -> Tree A -> Bool
+isSnake _ x = case x of
+ Snake -> True
+ _ -> composFold_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
+