diff tests/specialize.ur @ 315:e21d0dddda09

Unpoly non-recursive function
author Adam Chlipala <adamc@hcoop.net>
date Thu, 11 Sep 2008 09:36:47 -0400
parents
children 04ebfe929a98
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/specialize.ur	Thu Sep 11 09:36:47 2008 -0400
@@ -0,0 +1,26 @@
+datatype list a = Nil | Cons of a * list a
+
+fun isNil (t ::: Type) (ls : list t) : bool =
+        case ls of
+          Nil => True
+        | Cons _ => False
+
+(*fun append (t ::: Type) (ls1 : list t) (ls2 : list t) : list t =
+        case ls1 of
+          Nil => ls2
+        | Cons (x, ls1') => Cons (x, append ls1' ls2)
+
+fun delist (ls : list string) : xml body [] [] =
+        case ls of
+          Nil => <body>Nil</body>
+        | Cons (h, t) => <body>{cdata h} :: {delist t}</body>*)
+
+val ls = Cons ("X", Cons ("Y", Cons ("Z", Nil)))
+
+fun main () : transaction page = return <html><body>
+        {if isNil ls then <body>It's Nil.</body> else <body>It's not Nil.</body>}
+</body></html>
+
+
+(*        <p>{delist ls}</p>*)
+