summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-01-01 10:08:22 -0500
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-01-01 10:08:22 -0500
commit62e9d88be744f971152166280d522e78f4ddb574 (patch)
tree29c1a18a15edea62d79e1761e3c63cfc14644d2b
parentc25af86ae9310055dd594f6330e39f93c9f24cb7 (diff)
Source containing an int
-rw-r--r--jslib/urweb.js2
-rw-r--r--src/jscomp.sml1
-rw-r--r--src/prim.sml8
-rw-r--r--tests/stypes.ur5
-rw-r--r--tests/stypes.urp3
5 files changed, 18 insertions, 1 deletions
diff --git a/jslib/urweb.js b/jslib/urweb.js
index 508f4318..e661a739 100644
--- a/jslib/urweb.js
+++ b/jslib/urweb.js
@@ -40,3 +40,5 @@ function dyn(s) {
document.body.appendChild(x);
s.h = cons(function() { x.innerHTML = s.v }, s.h);
}
+
+function ts(x) { return x.toString() }
diff --git a/src/jscomp.sml b/src/jscomp.sml
index bc407db8..9a67e286 100644
--- a/src/jscomp.sml
+++ b/src/jscomp.sml
@@ -34,6 +34,7 @@ structure E = MonoEnv
structure U = MonoUtil
val funcs = [(("Basis", "alert"), "alert"),
+ (("Basis", "htmlifyInt"), "ts"),
(("Basis", "htmlifyString"), "escape"),
(("Basis", "new_client_source"), "sc"),
(("Basis", "set_client_source"), "sv")]
diff --git a/src/prim.sml b/src/prim.sml
index 468b28d5..95df6e02 100644
--- a/src/prim.sml
+++ b/src/prim.sml
@@ -47,6 +47,12 @@ fun int2s n =
else
Int64.toString n ^ "LL"
+fun int2s' n =
+ if Int64.compare (n, Int64.fromInt 0) = LESS then
+ "-" ^ Int64.toString (Int64.~ n)
+ else
+ Int64.toString n
+
fun float2s n =
if Real64.compare (n, Real64.fromInt 0) = LESS then
"-" ^ Real64.toString (Real64.~ n)
@@ -55,7 +61,7 @@ fun float2s n =
fun toString t =
case t of
- Int n => int2s n
+ Int n => int2s' n
| Float n => float2s n
| String s => s
diff --git a/tests/stypes.ur b/tests/stypes.ur
new file mode 100644
index 00000000..6368d5c9
--- /dev/null
+++ b/tests/stypes.ur
@@ -0,0 +1,5 @@
+fun main () : transaction page =
+ sInt <- source 0;
+ return <xml><body>
+ <dyn signal={n <- signal sInt; return <xml>{[n]}</xml>}/> <a onclick={set sInt 1}>Change</a><br/>
+ </body></xml>
diff --git a/tests/stypes.urp b/tests/stypes.urp
new file mode 100644
index 00000000..353ea9e6
--- /dev/null
+++ b/tests/stypes.urp
@@ -0,0 +1,3 @@
+debug
+
+stypes