# HG changeset patch # User Adam Chlipala # Date 1220796782 14400 # Node ID 77a28e7430bfdc3a8208c1e7d82f30a9c9603ea6 # Parent c0e4ac23522d7b8226a84ae6c29f1f3ffe9a9087 intToString diff -r c0e4ac23522d -r 77a28e7430bf include/urweb.h --- a/include/urweb.h Sun Sep 07 10:02:27 2008 -0400 +++ b/include/urweb.h Sun Sep 07 10:13:02 2008 -0400 @@ -67,3 +67,5 @@ lw_Basis_bool lw_Basis_sqlifyBool(lw_context, lw_Basis_bool); char *lw_Basis_ensqlBool(lw_Basis_bool); + +lw_Basis_string lw_Basis_intToString(lw_context, lw_Basis_int); diff -r c0e4ac23522d -r 77a28e7430bf lib/basis.urs --- a/lib/basis.urs Sun Sep 07 10:02:27 2008 -0400 +++ b/lib/basis.urs Sun Sep 07 10:13:02 2008 -0400 @@ -6,6 +6,8 @@ datatype bool = False | True +(*datatype option t = None | Some of t*) + (** Basic type classes *) @@ -21,6 +23,9 @@ val strcat : string -> string -> string +val intToString : int -> string + + (** SQL *) diff -r c0e4ac23522d -r 77a28e7430bf src/c/urweb.c --- a/src/c/urweb.c Sun Sep 07 10:02:27 2008 -0400 +++ b/src/c/urweb.c Sun Sep 07 10:13:02 2008 -0400 @@ -670,3 +670,14 @@ else return (char *)&true; } + +lw_Basis_string lw_Basis_intToString(lw_context ctx, lw_Basis_int n) { + int len; + char *r; + + lw_check_heap(ctx, INTS_MAX); + r = ctx->heap_front; + sprintf(r, "%lld%n", n, &len); + ctx->heap_front += len+1; + return r; +} diff -r c0e4ac23522d -r 77a28e7430bf src/elaborate.sml --- a/src/elaborate.sml Sun Sep 07 10:02:27 2008 -0400 +++ b/src/elaborate.sml Sun Sep 07 10:13:02 2008 -0400 @@ -1923,6 +1923,10 @@ val nxs = length xs - 1 val t = ListUtil.foldli (fn (i, _, t) => (L'.CApp (t, (L'.CRel (nxs - i), loc)), loc)) t xs + val (env', denv') = foldl (fn (x, (env', denv')) => + (E.pushCRel env' x k, + D.enter denv')) (env, denv) xs + val (xcs, (used, env, gs)) = ListUtil.foldlMap (fn ((x, to), (used, env, gs)) => @@ -1931,9 +1935,9 @@ NONE => (NONE, t, gs) | SOME t' => let - val (t', tk, gs') = elabCon (env, denv) t' + val (t', tk, gs') = elabCon (env', denv') t' in - checkKind env t' tk k; + checkKind env' t' tk k; (SOME t', (L'.TFun (t', t), loc), gs' @ gs) end val t = foldl (fn (x, t) => (L'.TCFun (L'.Implicit, x, k, t), loc)) t xs diff -r c0e4ac23522d -r 77a28e7430bf tests/option.ur --- a/tests/option.ur Sun Sep 07 10:02:27 2008 -0400 +++ b/tests/option.ur Sun Sep 07 10:13:02 2008 -0400 @@ -9,15 +9,15 @@ val show2 = fn x => case x of None => "None'" | Some x => show x -val page = fn x => +val page = fn x => return {cdata (show x)} -val page2 = fn x => +val page2 = fn x => return {cdata (show2 x)} -val main : unit -> page = fn () => +val main : unit -> transaction page = fn () => return
  • None1
  • Some1
  • None2
  • diff -r c0e4ac23522d -r 77a28e7430bf tests/option.urp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/option.urp Sun Sep 07 10:13:02 2008 -0400 @@ -0,0 +1,5 @@ +debug +database dbname=test +exe /tmp/webapp + +option diff -r c0e4ac23522d -r 77a28e7430bf tests/toString.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/toString.ur Sun Sep 07 10:13:02 2008 -0400 @@ -0,0 +1,3 @@ +fun main () : transaction page = return + 6 = {cdata (intToString 6)} + diff -r c0e4ac23522d -r 77a28e7430bf tests/toString.urp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/toString.urp Sun Sep 07 10:13:02 2008 -0400 @@ -0,0 +1,5 @@ +debug +database dbname=test +exe /tmp/webapp + +toString