summaryrefslogtreecommitdiff
path: root/testsuite/runtime/paraphrase/Nat.gf
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/runtime/paraphrase/Nat.gf')
-rw-r--r--testsuite/runtime/paraphrase/Nat.gf34
1 files changed, 34 insertions, 0 deletions
diff --git a/testsuite/runtime/paraphrase/Nat.gf b/testsuite/runtime/paraphrase/Nat.gf
new file mode 100644
index 000000000..b55333472
--- /dev/null
+++ b/testsuite/runtime/paraphrase/Nat.gf
@@ -0,0 +1,34 @@
+abstract Nat = {
+
+cat Nat ;
+
+data
+ Zero : Nat ;
+ Succ : Nat -> Nat ;
+
+fun one : Nat ;
+def one = Succ Zero ;
+
+fun plus : Nat -> Nat -> Nat ;
+def plus x Zero = x ;
+def plus x (Succ y) = Succ (plus x y) ;
+
+fun twice : Nat -> Nat ;
+def twice x = plus x x ;
+
+fun times : Nat -> Nat -> Nat ;
+def times x Zero = Zero ;
+def times x (Succ y) = plus (times x y) x ;
+
+fun four : Nat ;
+def four = twice (twice one) ;
+
+fun exp : Nat -> Nat ;
+def exp Zero = one ;
+def exp (Succ x) = twice (exp x) ;
+
+fun plus' : Nat -> Nat -> Nat ;
+def plus' Zero = \y -> y ;
+def plus' (Succ x) = \y -> Succ (plus x y) ;
+
+}