changeset 586:1c969230ee7f

Reactive bool
author Adam Chlipala <adamc@hcoop.net>
date Thu, 01 Jan 2009 11:13:08 -0500
parents 35471f067980
children 4c899701bd28
files jslib/urweb.js src/jscomp.sml tests/stypes.ur
diffstat 3 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/jslib/urweb.js	Thu Jan 01 11:04:09 2009 -0500
+++ b/jslib/urweb.js	Thu Jan 01 11:13:08 2009 -0500
@@ -42,4 +42,6 @@
 }
 
 function ts(x) { return x.toString() }
+function bs(b) { return (b ? "True" : "False") }
+
 function pf() { alert("Pattern match failure") }
--- a/src/jscomp.sml	Thu Jan 01 11:04:09 2009 -0500
+++ b/src/jscomp.sml	Thu Jan 01 11:13:08 2009 -0500
@@ -34,6 +34,7 @@
 structure U = MonoUtil
 
 val funcs = [(("Basis", "alert"), "alert"),
+             (("Basis", "htmlifyBool"), "bs"),
              (("Basis", "htmlifyFloat"), "ts"),
              (("Basis", "htmlifyInt"), "ts"),
              (("Basis", "htmlifyString"), "escape"),
@@ -110,6 +111,8 @@
                 fun patCon pc =
                     case pc of
                         PConVar n => str (Int.toString n)
+                      | PConFfi {mod = "Basis", con = "True", ...} => str "true"
+                      | PConFfi {mod = "Basis", con = "False", ...} => str "false"
                       | PConFfi {con, ...} => str ("\"_" ^ con ^ "\"")
 
                 fun isNullable (t, _) =
--- a/tests/stypes.ur	Thu Jan 01 11:04:09 2009 -0500
+++ b/tests/stypes.ur	Thu Jan 01 11:13:08 2009 -0500
@@ -4,6 +4,7 @@
     sBoth <- source (7, 42.1);
 
     sOpt <- source None;
+    sBool <- source True;
 
     return <xml><body>
       <dyn signal={n <- signal sInt; return <xml>{[n + 3]}</xml>}/> <a onclick={set sInt 1}>Change</a><br/>
@@ -20,4 +21,6 @@
                                          None => return <xml>None</xml>
                                        | Some n => return <xml>{[n]}</xml>}/>
         <a onclick={set sOpt (Some 7)}>Change</a><br/>
+
+      <dyn signal={b <- signal sBool; return <xml>{[b]}</xml>}/> <a onclick={set sBool False}>Change</a><br/>
     </body></xml>