summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2010-12-23 17:46:40 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2010-12-23 17:46:40 -0500
commit38d3bc508b3b882e81599bdb0e1d4a2572c23dd0 (patch)
tree31bbf2f979aa12d31eb3977bb6c0cdfe2c57bae9 /lib
parent867a11af44827af8974250e6dbb5e96b6268b44f (diff)
[De]serialization of times in JavaScript; proper integer division in JavaScript; Basis.crypt; Top.mkRead'; more aggressive Mono-level inlining, for values of function-y types
Diffstat (limited to 'lib')
-rw-r--r--lib/js/urweb.js2
-rw-r--r--lib/ur/basis.urs5
-rw-r--r--lib/ur/top.ur7
-rw-r--r--lib/ur/top.urs2
4 files changed, 15 insertions, 1 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index f98476b7..bba58453 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -19,7 +19,9 @@ function plus(x, y) { return x + y; }
function minus(x, y) { return x - y; }
function times(x, y) { return x * y; }
function div(x, y) { return x / y; }
+function divInt(x, y) { var n = x / y; return n < 0 ? Math.ceil(n) : Math.floor(n); }
function mod(x, y) { return x % y; }
+function modInt(x, y) { var n = x % y; return n < 0 ? Math.ceil(n) : Math.floor(n); }
function lt(x, y) { return x < y; }
function le(x, y) { return x <= y; }
diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs
index 8cf516f8..95deb982 100644
--- a/lib/ur/basis.urs
+++ b/lib/ur/basis.urs
@@ -146,6 +146,11 @@ val minusSeconds : time -> int -> time
val timef : string -> time -> string (* Uses strftime() format string *)
+(** * Encryption *)
+
+val crypt : string -> string -> string
+
+
(** HTTP operations *)
con http_cookie :: Type -> Type
diff --git a/lib/ur/top.ur b/lib/ur/top.ur
index 32d06a43..19259e92 100644
--- a/lib/ur/top.ur
+++ b/lib/ur/top.ur
@@ -89,7 +89,7 @@ fun read_option [t ::: Type] (_ : read t) =
None => None
| v => Some v)
-fun txt [t] [ctx ::: {Unit}] [use ::: {Type}] (_ : show t) (v : t) =
+fun txt [t] [ctx ::: {Unit}] [use ::: {Type}] (_ : show t) (v : t) : xml ctx use [] =
cdata (show v)
fun map0 [K] [tf :: K -> Type] (f : t :: K -> tf t) [r ::: {K}] (fl : folder r) =
@@ -343,3 +343,8 @@ fun eqNullable' [tables ::: {{Type}}] [agg ::: {{Type}}] [exps ::: {Type}]
case e2 of
None => (SQL {e1} IS NULL)
| Some _ => sql_binary sql_eq e1 (sql_inject e2)
+
+fun mkRead' [t ::: Type] (f : string -> option t) (name : string) : read t =
+ mkRead (fn s => case f s of
+ None => error <xml>Invalid {txt name}: {txt s}</xml>
+ | Some v => v) f
diff --git a/lib/ur/top.urs b/lib/ur/top.urs
index a18bf437..74b04ed1 100644
--- a/lib/ur/top.urs
+++ b/lib/ur/top.urs
@@ -231,3 +231,5 @@ val eqNullable' : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type}
-> sql_exp tables agg exps (option t)
-> option t
-> sql_exp tables agg exps bool
+
+val mkRead' : t ::: Type -> (string -> option t) -> string -> read t