From adamc at csail.mit.edu Fri Sep 13 10:26:22 2013 From: adamc at csail.mit.edu (Adam Chlipala) Date: Fri, 13 Sep 2013 10:26:22 -0400 Subject: [Ur] Non-printable character 10 in blob to SQLify In-Reply-To: References: Message-ID: <5233208E.70300@csail.mit.edu> Sorry for the delayed response. I've imported your patch and made a small tweak, so that a simple database upload example works in all 3 supported DBMSes. The new code is pushed to the public Ur/Web Mercurial repo. On 08/20/2013 02:38 PM, Sergey Mironov wrote: > Hi. I've faced 'non-printable character' error while trying to insert > a blob into the database. The error was mentioned in [1], but that was > all about strings, not blobs. Quick investigation shows that Ur > supports either E-string or plain syntax, and E-string is disabled for > the SQLite case (in sqlite.sml) . Fortunately, I've found the third > way - X-strings (X stands for hex) [2]. Simple hacky patch (attached) > illustrates the idea. Is it sqlite specific syntax extension? can we > use this approach for other databases? > > Sergey > > > > [1] - http://www.impredicative.com/pipermail/ur/2012-February/001059.html > [2] - http://stackoverflow.com/a/10214217/1133157 > From grrwlf at gmail.com Wed Sep 18 07:57:49 2013 From: grrwlf at gmail.com (Sergey Mironov) Date: Wed, 18 Sep 2013 15:57:49 +0400 Subject: [Ur] changing built-in ccompiler Message-ID: Hi. I've created a couple of patches adding the following new command line options: -ccompiler and -print-ccompiler. They allow to get/set the compiler in runtime. The reason is to make sure that the same ccompiler is used for both ur/web itself and custom C parts FFIed into the project on machines with several compilers available. Please, consider applying! Regards, Sergey. -------------- next part -------------- A non-text attachment was scrubbed... Name: 02-ccompiler.patch Type: application/octet-stream Size: 802 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 01-ccompiler.patch Type: application/octet-stream Size: 2608 bytes Desc: not available URL: From grrwlf at gmail.com Mon Sep 23 05:18:00 2013 From: grrwlf at gmail.com (Sergey Mironov) Date: Mon, 23 Sep 2013 13:18:00 +0400 Subject: [Ur] -root option is broken? Message-ID: Hi. Looks like I can't trigger 'Alternate module naming convention' as stated in the Manual. Here is my simple project: . ??? App.urp ??? Makefile ??? src ??? A.ur ??? A.urs ??? Main.ur ??? Main.urs Main.ur's content is just fun main {} = t <- Top.A.amazingText {}; return The page {t} A.ur contains amazingText function returning some plain xbody. When I invoke urweb as follows: $ urweb -root Top src -dbms sqlite App it errors with /home/grwlf/proj/urdesign/src/Main.ur:3:7: (to 3:24) Unbound structure A but $ urweb -root Top src -dbms sqlite App -moduleOf src/A Top.A Did I found a bug? Regards, Sergey From grrwlf at gmail.com Thu Sep 26 12:30:05 2013 From: grrwlf at gmail.com (Sergey Mironov) Date: Thu, 26 Sep 2013 20:30:05 +0400 Subject: [Ur] constructor-level constraints and more Message-ID: Hi. A question about Ur's type-level facilities: I have a function `add' which adds a field #JQ to the record `t'. con dpage = fn deps => [ Hdr = record deps, Bdy = transaction page] val add : t ::: {Type} -> css_class -> [t ~ [JQ]] => record (dpage (t ++ [JQ = url])) -> record (dpage (t ++ [JQ = url])) it works, but since I'm going to write many different adders, I'd like to make their signatures shorter. My plan was to add a shorthand for `record (dpage (t ++ [JQ = url]))' like this: con my = fn t => record (dpage (t++[JQ=url])) and then rewrite `add' as val add : t ::: {Type} -> css_class -> [t ~ [JQ]] => my t -> my t Unfortunately, Ur doesn't allow me to do that. Even `con my ..' line alone issues the error: dev:[grwlf at greyblade:~/proj/urdesign]$ urweb -dbms sqlite App && ./App.exe /home/grwlf/proj/urdesign/src/menu_jq/Menu_jq.ur:16:41: (to 16:54) Couldn't prove field name disjointness Con 1: t Con 2: [JQ = ()] Hnormed 1: t Hnormed 2: [JQ = ()] Naturally, `con my' doesn't have a constraint and I don't know how to add it. Is there a solution? Do we have a general quick way to say that record r contains field n? Regards, Sergey From adamc at csail.mit.edu Thu Sep 26 15:19:59 2013 From: adamc at csail.mit.edu (Adam Chlipala) Date: Thu, 26 Sep 2013 15:19:59 -0400 Subject: [Ur] constructor-level constraints and more In-Reply-To: References: Message-ID: <524488DF.6010308@csail.mit.edu> Possibly this point should go in the Ur/Web FAQ. ;) On 09/26/2013 12:30 PM, Sergey Mironov wrote: > My plan was to add a shorthand for > `record (dpage (t ++ [JQ = url]))' like this: > > con my = fn t => record (dpage (t++[JQ=url])) > The Ur type system doesn't support this sort of abstraction. The recommended approach is to avoid introducing an abbreviation. From adamc at csail.mit.edu Thu Sep 26 16:29:24 2013 From: adamc at csail.mit.edu (Adam Chlipala) Date: Thu, 26 Sep 2013 16:29:24 -0400 Subject: [Ur] -root option is broken? In-Reply-To: References: Message-ID: <52449924.1090109@csail.mit.edu> Your example is close to working properly. There are two "bugs" in your code, plus a few in the Ur/Web compiler that I've fixed in a patch pushed to the public Mercurial repo. First, the bugs in your code: The semantics of '-root' are such that your example here is compiled as though it were written in a single file like: structure Top = struct structure A = (* ... *) structure Main = (* ... *) end The reference in Main.ur to [Top.A] would be dropped in literally, at the appropriate point above, making it an attempt to reference module [Top] recursively in its own definition. Ur/Web doesn't support recursive module definitions, so this is a variable reference error. Instead of [Top.A], you'd just write [A]. The other bug in your code is that [Top] is already a module from the standard library that is included and [open]ed in every project implicitly, so you wind up with some quite confusing name shadowing! I've patched the compiler to complain about such cases. No one had used this '-root' business in quite a while, so I had to make two more small changes. One was to prevent an overzealous error message from a check that hadn't been tested with '-root'. The other change was to make '-root' support relative filesystem paths (as in your example), rather than just absolute. On 09/23/2013 05:18 AM, Sergey Mironov wrote: > Hi. Looks like I can't trigger 'Alternate module naming convention' as > stated in the Manual. Here is my simple project: > . > ??? App.urp > ??? Makefile > ??? src > ??? A.ur > ??? A.urs > ??? Main.ur > ??? Main.urs > > Main.ur's content is just > > fun main {} = > t<- Top.A.amazingText {}; > return > > The page > > > {t} > > > > A.ur contains amazingText function returning some plain xbody. When I > invoke urweb as follows: > > $ urweb -root Top src -dbms sqlite App > > it errors with > > /home/grwlf/proj/urdesign/src/Main.ur:3:7: (to 3:24) Unbound structure A > > but > > $ urweb -root Top src -dbms sqlite App -moduleOf src/A > Top.A > > Did I found a bug? > From grrwlf at gmail.com Mon Sep 30 11:48:15 2013 From: grrwlf at gmail.com (Sergey Mironov) Date: Mon, 30 Sep 2013 19:48:15 +0400 Subject: [Ur] Mailing list problem Message-ID: Hi. I've got a problem receiving emails from the Ur mailing list. Basically, I receive digests mails only, no 'normal' mail. Am I alone facing this? Spam filter looks clear. Regards, Sergey From grrwlf at gmail.com Mon Sep 30 12:21:06 2013 From: grrwlf at gmail.com (Sergey Mironov) Date: Mon, 30 Sep 2013 20:21:06 +0400 Subject: [Ur] code bug Message-ID: Consider following code: fun noDml (q:dml) : transaction {} = e <- tryDml q; return {} task initialize = fn {} => noDml (INSERT INTO page(Id, Caption) VALUES (0, "Top")); noDml (INSERT INTO page(Id, Caption) VALUES (1, "Top")); return {} When compiling, urweb issues the following error: dev:[grwlf at greyblade:~/proj/urdesign]$ LANG=C make building stamp1 urweb -dbms sqlite AppMM /tmp/filestFy18/webapp.c:371:37: error: unknown type name 'uw_Basis_dml' /tmp/filestFy18/webapp.c: In function 'uw_initializer': /tmp/filestFy18/webapp.c:645:29: error: unknown type name 'uw_Basis_dml' /tmp/filestFy18/webapp.c:646:30: error: initialization makes integer from pointer without a cast [-Werror] /tmp/filestFy18/webapp.c:646:30: error: (near initialization for '__uwr___2') [-Werror] /tmp/filestFy18/webapp.c:648:29: error: implicit declaration of function '__uwn_noDml_1781' [-Werror=implicit-function-declaration] /tmp/filestFy18/webapp.c:654:31: error: unknown type name 'uw_Basis_dml' /tmp/filestFy18/webapp.c:655:32: error: initialization makes integer from pointer without a cast [-Werror] /tmp/filestFy18/webapp.c:655:32: error: (near initialization for '__uwr___3') [-Werror] cc1: all warnings being treated as errors make: *** [stamp1] Error 1 Note, that if I remove first noDml call, everything would be fine. Removing noDml also works task initialize = fn {} => e <- tryDml (INSERT INTO page(Id, Caption) VALUES (0, "Top")); e <- tryDml (INSERT INTO page(Id, Caption) VALUES (1, "Top")); return {} Please, advise Sergey From grrwlf at gmail.com Mon Sep 30 12:27:01 2013 From: grrwlf at gmail.com (Sergey Mironov) Date: Mon, 30 Sep 2013 20:27:01 +0400 Subject: [Ur] code bug In-Reply-To: References: Message-ID: Related question: How can I review webapp.c temp file (/tmp/filestFy18/webapp.c) before compiler deletes it? Sergey 2013/9/30 Sergey Mironov : > Consider following code: > > fun noDml (q:dml) : transaction {} = > e <- tryDml q; > return {} > > task initialize = fn {} => > noDml (INSERT INTO page(Id, Caption) VALUES (0, "Top")); > noDml (INSERT INTO page(Id, Caption) VALUES (1, "Top")); > return {} > > When compiling, urweb issues the following error: > > dev:[grwlf at greyblade:~/proj/urdesign]$ LANG=C make > building stamp1 > urweb -dbms sqlite AppMM > /tmp/filestFy18/webapp.c:371:37: error: unknown type name 'uw_Basis_dml' > /tmp/filestFy18/webapp.c: In function 'uw_initializer': > /tmp/filestFy18/webapp.c:645:29: error: unknown type name 'uw_Basis_dml' > /tmp/filestFy18/webapp.c:646:30: error: initialization makes integer > from pointer without a cast [-Werror] > /tmp/filestFy18/webapp.c:646:30: error: (near initialization for > '__uwr___2') [-Werror] > /tmp/filestFy18/webapp.c:648:29: error: implicit declaration of > function '__uwn_noDml_1781' [-Werror=implicit-function-declaration] > /tmp/filestFy18/webapp.c:654:31: error: unknown type name 'uw_Basis_dml' > /tmp/filestFy18/webapp.c:655:32: error: initialization makes integer > from pointer without a cast [-Werror] > /tmp/filestFy18/webapp.c:655:32: error: (near initialization for > '__uwr___3') [-Werror] > cc1: all warnings being treated as errors > make: *** [stamp1] Error 1 > > Note, that if I remove first noDml call, everything would be fine. > Removing noDml also works > > task initialize = fn {} => > e <- tryDml (INSERT INTO page(Id, Caption) VALUES (0, "Top")); > e <- tryDml (INSERT INTO page(Id, Caption) VALUES (1, "Top")); > return {} > > Please, advise > Sergey From grrwlf at gmail.com Mon Sep 30 13:06:55 2013 From: grrwlf at gmail.com (Sergey Mironov) Date: Mon, 30 Sep 2013 21:06:55 +0400 Subject: [Ur] code bug In-Reply-To: References: Message-ID: I've found the workaround, it's even better that my original attempt: fun no [t] (c : transaction t) : transaction {} = x <- c ; return {} task initialize = fn {} => no( tryDml (INSERT INTO page(Id, Caption) VALUES (0, "Top"))); no( tryDml (INSERT INTO page(Id, Caption) VALUES (1, "Top"))); return {} Still, the bug exists. 2013/9/30 Sergey Mironov : > Related question: How can I review webapp.c temp file > (/tmp/filestFy18/webapp.c) before compiler deletes it? > > Sergey > > 2013/9/30 Sergey Mironov : >> Consider following code: >> >> fun noDml (q:dml) : transaction {} = >> e <- tryDml q; >> return {} >> >> task initialize = fn {} => >> noDml (INSERT INTO page(Id, Caption) VALUES (0, "Top")); >> noDml (INSERT INTO page(Id, Caption) VALUES (1, "Top")); >> return {} >> >> When compiling, urweb issues the following error: >> >> dev:[grwlf at greyblade:~/proj/urdesign]$ LANG=C make >> building stamp1 >> urweb -dbms sqlite AppMM >> /tmp/filestFy18/webapp.c:371:37: error: unknown type name 'uw_Basis_dml' >> /tmp/filestFy18/webapp.c: In function 'uw_initializer': >> /tmp/filestFy18/webapp.c:645:29: error: unknown type name 'uw_Basis_dml' >> /tmp/filestFy18/webapp.c:646:30: error: initialization makes integer >> from pointer without a cast [-Werror] >> /tmp/filestFy18/webapp.c:646:30: error: (near initialization for >> '__uwr___2') [-Werror] >> /tmp/filestFy18/webapp.c:648:29: error: implicit declaration of >> function '__uwn_noDml_1781' [-Werror=implicit-function-declaration] >> /tmp/filestFy18/webapp.c:654:31: error: unknown type name 'uw_Basis_dml' >> /tmp/filestFy18/webapp.c:655:32: error: initialization makes integer >> from pointer without a cast [-Werror] >> /tmp/filestFy18/webapp.c:655:32: error: (near initialization for >> '__uwr___3') [-Werror] >> cc1: all warnings being treated as errors >> make: *** [stamp1] Error 1 >> >> Note, that if I remove first noDml call, everything would be fine. >> Removing noDml also works >> >> task initialize = fn {} => >> e <- tryDml (INSERT INTO page(Id, Caption) VALUES (0, "Top")); >> e <- tryDml (INSERT INTO page(Id, Caption) VALUES (1, "Top")); >> return {} >> >> Please, advise >> Sergey From mstarzyk at gmail.com Mon Sep 30 16:23:16 2013 From: mstarzyk at gmail.com (Maciek Starzyk) Date: Mon, 30 Sep 2013 22:23:16 +0200 Subject: [Ur] code bug In-Reply-To: References: Message-ID: On Mon, Sep 30, 2013 at 6:27 PM, Sergey Mironov wrote: > Related question: How can I review webapp.c temp file > (/tmp/filestFy18/webapp.c) before compiler deletes it? > > If you add 'debug' directive to the urp file, then the compiler will use /tmp/webapp.c, and not delete it upon exit. Cheers, -- Maciek -------------- next part -------------- An HTML attachment was scrubbed... URL: From adamc at csail.mit.edu Mon Sep 30 16:25:48 2013 From: adamc at csail.mit.edu (Adam Chlipala) Date: Mon, 30 Sep 2013 16:25:48 -0400 Subject: [Ur] Mailing list problem In-Reply-To: References: Message-ID: <5249DE4C.7020400@csail.mit.edu> On 09/30/2013 11:48 AM, Sergey Mironov wrote: > Hi. I've got a problem receiving emails from the Ur mailing list. > Basically, I receive digests mails only, no 'normal' mail. Am I alone > facing this? > > Spam filter looks clear. > I would guess that you enabled digests for yourself in the Mailman web interface, reachable from the URL at the end of each list message. I believe it is the _intended_ behavior that no regular messages are sent out when digests are enabled. So, you could follow that link and turn digests off if you don't want that mode. From adamc at csail.mit.edu Mon Sep 30 16:38:09 2013 From: adamc at csail.mit.edu (Adam Chlipala) Date: Mon, 30 Sep 2013 16:38:09 -0400 Subject: [Ur] code bug In-Reply-To: References: Message-ID: <5249E131.6020305@csail.mit.edu> On 09/30/2013 12:21 PM, Sergey Mironov wrote: > Consider following code: > > fun noDml (q:dml) : transaction {} = > e<- tryDml q; > return {} > > task initialize = fn {} => > noDml (INSERT INTO page(Id, Caption) VALUES (0, "Top")); > noDml (INSERT INTO page(Id, Caption) VALUES (1, "Top")); > return {} > > When compiling, urweb issues the following error: > > dev:[grwlf at greyblade:~/proj/urdesign]$ LANG=C make > building stamp1 > urweb -dbms sqlite AppMM > /tmp/filestFy18/webapp.c:371:37: error: unknown type name 'uw_Basis_dml' > Ah, this was just a case of a bad error message. I meant for the compiler to complain that you haven't used a 'database' directive to declare the database connection of this application, so it is not legal to use SQL actions. There was a bug in the analysis for detecting when SQL is used in program code, and your experience with small program variants "fixing" the problem is just based on the particularities of that bug. It's fixed now, in a changeset pushed to the public repo.