summaryrefslogtreecommitdiff
path: root/tests/list.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-04-30 11:07:29 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-04-30 11:07:29 -0400
commit7a3ba5558cb363006aae188e02dd57dda833d356 (patch)
treebe8dc60f901b2cab9ec630d505bf152d1d19340e /tests/list.ur
parent0264695e9a76f87e6164c489c34af63fa893889d (diff)
Basis.list
Diffstat (limited to 'tests/list.ur')
-rw-r--r--tests/list.ur30
1 files changed, 14 insertions, 16 deletions
diff --git a/tests/list.ur b/tests/list.ur
index a4602d0e..815c0075 100644
--- a/tests/list.ur
+++ b/tests/list.ur
@@ -1,19 +1,17 @@
-datatype list a = Nil | Cons of a * list a
+fun isNil (t ::: Type) (ls : list t) =
+ case ls of
+ Nil => True
+ | _ => False
-val isNil = fn t ::: Type => fn ls : list t =>
- case ls of Nil => True | _ => False
+fun delist (ls : list string) : xbody =
+ case ls of
+ Nil => <xml>Nil</xml>
+ | Cons (h, t) => <xml>{[h]} :: {delist t}</xml>
-val show = fn b => if b then "True" else "False"
+fun main () = return <xml><body>
+ {[isNil (Nil : list bool)]},
+ {[isNil (Cons (1, Nil))]},
+ {[isNil (Cons ("A", Cons ("B", Nil)))]}
-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>
+ <p>{delist (Cons ("X", Cons ("Y", Cons ("Z", Nil))))}</p>
+</body></xml>