summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/js/urweb.js12
-rw-r--r--lib/ur/monad.ur2
-rw-r--r--lib/ur/monad.urs3
-rw-r--r--lib/ur/top.ur17
-rw-r--r--lib/ur/top.urs9
-rw-r--r--src/compiler.sig1
-rw-r--r--src/compiler.sml4
-rw-r--r--src/elaborate.sml14
8 files changed, 52 insertions, 10 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] =>
diff --git a/src/compiler.sig b/src/compiler.sig
index c36ae2cc..73605d7c 100644
--- a/src/compiler.sig
+++ b/src/compiler.sig
@@ -120,6 +120,7 @@ signature COMPILER = sig
val toSpecialize : (string, Core.file) transform
val toShake3 : (string, Core.file) transform
val toEspecialize : (string, Core.file) transform
+ val toReduce2 : (string, Core.file) transform
val toShake4 : (string, Core.file) transform
val toMarshalcheck : (string, Core.file) transform
val toEffectize : (string, Core.file) transform
diff --git a/src/compiler.sml b/src/compiler.sml
index 622b0e62..c99c0eeb 100644
--- a/src/compiler.sml
+++ b/src/compiler.sml
@@ -779,7 +779,9 @@ val toShake3 = transform shake "shake3" o toSpecialize
val toEspecialize = transform especialize "especialize" o toShake3
-val toShake4 = transform shake "shake4" o toEspecialize
+val toReduce2 = transform reduce "reduce2" o toEspecialize
+
+val toShake4 = transform shake "shake4" o toReduce2
val marshalcheck = {
func = (fn file => (MarshalCheck.check file; file)),
diff --git a/src/elaborate.sml b/src/elaborate.sml
index f0aa8d7a..6b25cedb 100644
--- a/src/elaborate.sml
+++ b/src/elaborate.sml
@@ -1116,6 +1116,18 @@
fun elabHead (env, denv) infer (e as (_, loc)) t =
let
+ fun unravelKind (t, e) =
+ case hnormCon env t of
+ (L'.TKFun (x, t'), _) =>
+ let
+ val u = kunif loc
+
+ val t'' = subKindInCon (0, u) t'
+ in
+ unravelKind (t'', (L'.EKApp (e, u), loc))
+ end
+ | t => (e, t, [])
+
fun unravel (t, e) =
case hnormCon env t of
(L'.TKFun (x, t'), _) =>
@@ -1184,7 +1196,7 @@
| t => (e, t, [])
in
case infer of
- L.DontInfer => (e, t, [])
+ L.DontInfer => unravelKind (t, e)
| _ => unravel (t, e)
end