diff tests/jsinj.ur @ 596:d1ec54288b1a

Injected a polymorphic, recursive type
author Adam Chlipala <adamc@hcoop.net>
date Thu, 08 Jan 2009 10:15:45 -0500
parents 02c8ab9f3e8b
children d49d58a69877
line wrap: on
line diff
--- a/tests/jsinj.ur	Thu Jan 08 09:57:45 2009 -0500
+++ b/tests/jsinj.ur	Thu Jan 08 10:15:45 2009 -0500
@@ -13,6 +13,13 @@
 
 val show_color = mkShow colorToString
 
+datatype list a = Nil | Cons of a * list a
+
+fun delist ls : xbody =
+    case ls of
+        Nil => <xml>Nil</xml>
+      | Cons (h, t) => <xml>{cdata h} :: {delist t}</xml>
+
 cookie int : int
 cookie float : float
 cookie string : string
@@ -20,6 +27,7 @@
 cookie pair : int * float
 cookie option : option int
 cookie color : color
+cookie list : list string
 
 fun main () : transaction page =
     n <- getCookie int;
@@ -50,6 +58,10 @@
     c <- return (getOpt c White);
     sc <- source Blue;
 
+    l <- getCookie list;
+    l <- return (getOpt l (Cons ("A", Cons ("B", Nil))));
+    sl <- source Nil;
+
     return <xml><body>
       <dyn signal={n <- signal sn; return <xml>{[n]}</xml>}/>
       <a onclick={set sn n}>CHANGE</a><br/>
@@ -73,4 +85,7 @@
 
       <dyn signal={c <- signal sc; return <xml>{[c]}</xml>}/>
       <a onclick={set sc c}>CHANGE</a><br/>
+
+      <dyn signal={l <- signal sl; return <xml>{delist l}</xml>}/>
+      <a onclick={set sl l}>CHANGE</a><br/>
     </body></xml>