adamc@580: function cons(v, ls) { adamc@580: return { n : ls, v : v }; adamc@580: } adamc@579: function callAll(ls) { adamc@579: for (; ls; ls = ls.next) adamc@579: ls.v(); adamc@579: } adamc@574: adamc@580: function sc(v) { adamc@580: return {v : v, h : null}; adamc@580: } adamc@580: function sv(s, v) { adamc@580: s.v = v; adamc@580: callAll(s.h); adamc@580: } adamc@579: adamc@580: function ss(s) { adamc@580: return s; adamc@580: } adamc@580: function sr(v) { adamc@580: return {v : v, h : null}; adamc@580: } adamc@580: function sb(x,y) { adamc@580: var z = y(x.v); adamc@580: var s = {v : z.v, h : null}; adamc@580: adamc@580: function reZ() { adamc@580: z.h = cons(function() { s.v = z.v; callAll(s.h); }, z.h); adamc@580: } adamc@580: adamc@580: x.h = cons(function() { z = y(x.v); reZ(); s.v = z.v; callAll(s.h); }, x.h); adamc@580: reZ(); adamc@580: adamc@580: return s; adamc@580: } adamc@571: adamc@571: function dyn(s) { adamc@571: var x = document.createElement("span"); adamc@571: x.innerHTML = s.v; adamc@571: document.body.appendChild(x); adamc@580: s.h = cons(function() { x.innerHTML = s.v }, s.h); adamc@571: }