annotate jslib/urweb.js @ 593:f277f5faebcd

Injected a record
author Adam Chlipala <adamc@hcoop.net>
date Fri, 02 Jan 2009 12:42:39 -0500
parents 102e81d975e3
children d49d58a69877
rev   line source
adamc@580 1 function cons(v, ls) {
adamc@580 2 return { n : ls, v : v };
adamc@580 3 }
adamc@579 4 function callAll(ls) {
adamc@585 5 for (; ls; ls = ls.n)
adamc@579 6 ls.v();
adamc@579 7 }
adamc@574 8
adamc@580 9 function sc(v) {
adamc@580 10 return {v : v, h : null};
adamc@580 11 }
adamc@580 12 function sv(s, v) {
adamc@580 13 s.v = v;
adamc@580 14 callAll(s.h);
adamc@580 15 }
adamc@579 16
adamc@580 17 function ss(s) {
adamc@580 18 return s;
adamc@580 19 }
adamc@580 20 function sr(v) {
adamc@580 21 return {v : v, h : null};
adamc@580 22 }
adamc@580 23 function sb(x,y) {
adamc@580 24 var z = y(x.v);
adamc@580 25 var s = {v : z.v, h : null};
adamc@580 26
adamc@580 27 function reZ() {
adamc@580 28 z.h = cons(function() { s.v = z.v; callAll(s.h); }, z.h);
adamc@580 29 }
adamc@580 30
adamc@580 31 x.h = cons(function() { z = y(x.v); reZ(); s.v = z.v; callAll(s.h); }, x.h);
adamc@580 32 reZ();
adamc@580 33
adamc@580 34 return s;
adamc@580 35 }
adamc@571 36
adamc@571 37 function dyn(s) {
adamc@571 38 var x = document.createElement("span");
adamc@571 39 x.innerHTML = s.v;
adamc@571 40 document.body.appendChild(x);
adamc@580 41 s.h = cons(function() { x.innerHTML = s.v }, s.h);
adamc@571 42 }
adamc@582 43
adamc@582 44 function ts(x) { return x.toString() }
adamc@586 45 function bs(b) { return (b ? "True" : "False") }
adamc@586 46
adamc@584 47 function pf() { alert("Pattern match failure") }
adamc@589 48