# HG changeset patch # User Adam Chlipala # Date 1230827194 18000 # Node ID 5803b4f041cb054b419fc2f1a5fcefea5b8baa60 # Parent 4c899701bd282ca57d51b4fa863e39801f55f77f Basic datatype reactives diff -r 4c899701bd28 -r 5803b4f041cb src/jscomp.sml --- a/src/jscomp.sml Thu Jan 01 11:16:57 2009 -0500 +++ b/src/jscomp.sml Thu Jan 01 11:26:34 2009 -0500 @@ -182,7 +182,22 @@ str ":", succ, str ")"] - | PCon _ => raise Fail "PCon" + | PCon (_, pc, NONE) => + strcat [str ("(d" ^ Int.toString depth ^ "=="), + patCon pc, + str "?", + succ, + str ":", + fail, + str ")"] + | PCon (_, pc, SOME p) => + strcat [str ("(d" ^ Int.toString depth ^ ".n=="), + patCon pc, + str ("?(d" ^ Int.toString depth ^ "=d" ^ Int.toString depth ^ ".v,"), + succ, + str "):", + fail, + str ")"] | PRecord xps => let val (_, succ) = foldl diff -r 4c899701bd28 -r 5803b4f041cb tests/stypes.ur --- a/tests/stypes.ur Thu Jan 01 11:16:57 2009 -0500 +++ b/tests/stypes.ur Thu Jan 01 11:26:34 2009 -0500 @@ -1,3 +1,25 @@ +datatype color = Red | White | Blue + +fun c2s c = + case c of + Red => "Red" + | White => "White" + | Blue => "Blue" + +val show_color = mkShow c2s + +datatype list a = Nil | Cons of a * list a + +fun isNil (t ::: Type) (ls : list t) = + case ls of + Nil => True + | _ => False + +fun delist (ls : list string) : xml body [] [] = + case ls of + Nil => Nil + | Cons (h, t) => {[h]} :: {delist t} + fun main () : transaction page = sInt <- source 0; sFloat <- source 1.23; @@ -6,6 +28,9 @@ sOpt <- source None; sBool <- source True; + sColor <- source White; + sList <- source Nil; + return {[n + 3]}}/> Change
@@ -25,4 +50,12 @@ {[b]}}/> Yes else return No}/> Change
+ + {[c]}}/> + Red + White + Blue
+ + {[isNil ls]}}/> + Change