diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-07-19 17:45:02 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-07-19 17:45:02 -0400 |
commit | 94a1373401529f500640b0c0628e7173612cdabe (patch) | |
tree | 89ce0f6149e50fdfece4b083c2be2033c7727c63 /lib | |
parent | 19cd9e965929d541e6714f62154f01b9e487a712 (diff) |
Working on Grid; have gone from one dynamic table bizareness to another
Diffstat (limited to 'lib')
-rw-r--r-- | lib/js/urweb.js | 12 | ||||
-rw-r--r-- | lib/ur/monad.ur | 2 | ||||
-rw-r--r-- | lib/ur/monad.urs | 3 | ||||
-rw-r--r-- | lib/ur/top.ur | 17 | ||||
-rw-r--r-- | lib/ur/top.urs | 9 |
5 files changed, 35 insertions, 8 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 3d4dbea2..dd66b55e 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -223,12 +223,17 @@ function lastParent() { return pos.parentNode; } +function parent() { + return thisScript ? thisScript.parentNode : lastParent(); +} + function addNode(node) { if (thisScript) { thisScript.parentNode.appendChild(node); thisScript.parentNode.removeChild(thisScript); - } else + } else { lastParent().appendChild(node); + } } function setHTML(html) { @@ -266,10 +271,8 @@ function runScripts(node) { // Dynamic tree entry points -var dynDepth = 0; - function dyn(s) { - var x = document.createElement("span"); + var x = parent(); x.dead = false; x.signal = s; x.sources = null; @@ -298,7 +301,6 @@ function dyn(s) { x.closures = cls.v; runScripts(x); }; - addNode(x); populate(x); } diff --git a/lib/ur/monad.ur b/lib/ur/monad.ur index 41f44d3a..73001094 100644 --- a/lib/ur/monad.ur +++ b/lib/ur/monad.ur @@ -5,3 +5,5 @@ fun exec [m ::: Type -> Type] (_ : monad m) [ts ::: {Type}] r (fd : folder ts) = others <- acc; return ({nm = this} ++ others)) (return {}) [ts] fd r + +fun ignore [m ::: Type -> Type] (_ : monad m) [t] (v : m t) = x <- v; return () diff --git a/lib/ur/monad.urs b/lib/ur/monad.urs index cfe0ef8e..b3cb3d6f 100644 --- a/lib/ur/monad.urs +++ b/lib/ur/monad.urs @@ -1,2 +1,5 @@ val exec : m ::: (Type -> Type) -> monad m -> ts ::: {Type} -> $(map m ts) -> folder ts -> m $ts + +val ignore : m ::: (Type -> Type) -> monad m -> t ::: Type + -> m t -> m unit diff --git a/lib/ur/top.ur b/lib/ur/top.ur index 785a9c8c..3dac7ff0 100644 --- a/lib/ur/top.ur +++ b/lib/ur/top.ur @@ -51,7 +51,7 @@ end fun not b = if b then False else True -con idT (t :: Type) = t +con id = K ==> fn t :: K => t con record (t :: {Type}) = $t con fst = K1 ==> K2 ==> fn t :: (K1 * K2) => t.1 con snd = K1 ==> K2 ==> fn t :: (K1 * K2) => t.2 @@ -92,11 +92,24 @@ fun read_option [t ::: Type] (_ : read t) = fun txt [t] [ctx ::: {Unit}] [use ::: {Type}] (_ : show t) (v : t) = cdata (show v) +fun mp [K] [tf1 :: K -> Type] [tf2 :: K -> Type] (f : t ::: K -> tf1 t -> tf2 t) [r :: {K}] (fl : folder r) = + fl [fn r :: {K} => $(map tf1 r) -> $(map tf2 r)] + (fn [nm :: Name] [t :: K] [rest :: {K}] [[nm] ~ rest] acc r => + acc (r -- nm) ++ {nm = f r.nm}) + (fn _ => {}) + +fun map2 [K1] [K2] [tf1 :: K1 -> Type] [tf2 :: K2 -> Type] [tf :: K1 -> K2] + (f : t ::: K1 -> tf1 t -> tf2 (tf t)) [r :: {K1}] (fl : folder r) = + fl [fn r :: {K1} => $(map tf1 r) -> $(map tf2 (map tf r))] + (fn [nm :: Name] [t :: K1] [rest :: {K1}] [[nm] ~ rest] acc r => + acc (r -- nm) ++ {nm = f r.nm}) + (fn _ => {}) + fun foldUR [tf :: Type] [tr :: {Unit} -> Type] (f : nm :: Name -> rest :: {Unit} -> [[nm] ~ rest] => tf -> tr rest -> tr ([nm] ++ rest)) - (i : tr []) [r :: {Unit}] (fl : folder r)= + (i : tr []) [r :: {Unit}] (fl : folder r) = fl [fn r :: {Unit} => $(mapU tf r) -> tr r] (fn [nm :: Name] [t :: Unit] [rest :: {Unit}] [[nm] ~ rest] acc r => f [nm] [rest] ! r.nm (acc (r -- nm))) diff --git a/lib/ur/top.urs b/lib/ur/top.urs index 4ed64075..33c90651 100644 --- a/lib/ur/top.urs +++ b/lib/ur/top.urs @@ -21,7 +21,7 @@ end val not : bool -> bool -con idT = fn t :: Type => t +con id = K ==> fn t :: K => t con record = fn t :: {Type} => $t con fst = K1 ==> K2 ==> fn t :: (K1 * K2) => t.1 con snd = K1 ==> K2 ==> fn t :: (K1 * K2) => t.2 @@ -45,6 +45,13 @@ val read_option : t ::: Type -> read t -> read (option t) val txt : t ::: Type -> ctx ::: {Unit} -> use ::: {Type} -> show t -> t -> xml ctx use [] +val mp : K --> tf1 :: (K -> Type) -> tf2 :: (K -> Type) + -> (t ::: K -> tf1 t -> tf2 t) + -> r :: {K} -> folder r -> $(map tf1 r) -> $(map tf2 r) +val map2 : K1 --> K2 --> tf1 :: (K1 -> Type) -> tf2 :: (K2 -> Type) -> tf :: (K1 -> K2) + -> (t ::: K1 -> tf1 t -> tf2 (tf t)) + -> r :: {K1} -> folder r -> $(map tf1 r) -> $(map tf2 (map tf r)) + val foldUR : tf :: Type -> tr :: ({Unit} -> Type) -> (nm :: Name -> rest :: {Unit} -> [[nm] ~ rest] => |