summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-08-09 16:48:32 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-08-09 16:48:32 -0400
commit3e59b823392701f538f972d689d04b0182696e51 (patch)
tree5a4f935084c734ee1634b76abe5d2d5f1abf8bcc /tests
parente699687ba2ff0cc2c7c185c4d99669f77093473b (diff)
Lists all the way through
Diffstat (limited to 'tests')
-rw-r--r--tests/list.lac19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/list.lac b/tests/list.lac
new file mode 100644
index 00000000..a4602d0e
--- /dev/null
+++ b/tests/list.lac
@@ -0,0 +1,19 @@
+datatype list a = Nil | Cons of a * list a
+
+val isNil = fn t ::: Type => fn ls : list t =>
+ case ls of Nil => True | _ => False
+
+val show = fn b => if b then "True" else "False"
+
+val rec delist : list string -> xml body [] [] = fn x =>
+ case x of
+ Nil => <body>Nil</body>
+ | Cons (h, t) => <body>{cdata h} :: {delist t}</body>
+
+val main : unit -> page = fn () => <html><body>
+ {cdata (show (isNil (Nil : list bool)))},
+ {cdata (show (isNil (Cons (1, Nil))))},
+ {cdata (show (isNil (Cons ("A", Cons ("B", Nil)))))}
+
+ <p>{delist (Cons ("X", Cons ("Y", Cons ("Z", Nil))))}</p>
+</body></html>