Re: [Ur] Ur/Web in production
Thanks for the write up. Eg the slow compliation speed for larger apps have been found by me by a simple dummy test application long time ago. Now you just proof that it happens in real world usage. urweb is cool - but eventually not the end yet. Time will tell. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Ur/Web in production
Excerpts from Vladimir Shabanov's message of Fri Jan 17 23:14:16 +0100 2014: Then I've switched from Postgres to Riak (needed to scale writes since RSS reader is very write heavy thing and to simplify cluster operations) and started to need more data processing and 3rd-party integration in frontend. So my Ur/Web app now links with Haskell and calls its functions via FFI. Maybe also smarter caching could work, eg only cache or keep in memory the info which feeds got read, and try to store them efficiently in memory (eg one bit per thread) - or try to pack by storing: read 1 to 5, 10 to 20 or such. Sometimes there is a lot you can do this way - just some thoughts without knowing all details. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] What about a new project - general purpose ur like language which collaborates with existing languages?
Excerpts from Adam Chlipala's message of Thu Nov 21 14:25:54 +0100 2013: Lately I'm more interested in replacing common programming languages than interoperating with them. A simple use case would be a library for ur. Most famous languages come with some kind of library management: - scala has sbt, - java: mvn, ivy, .. - ruby has gems/bundler - PHP (pear, maybe others? Never like this one) - Haskell: cabal - perl cpan - nodejs: npm - .. How would you propose solving this task without having a general purpose programming language? And if you used a general purpose programming language X you'd be have trouble to create something like hackage, because you would have to duplicate the code parsing package descriptions and the like eventually. Do you already have one in mind which (new language) you'd use to fill such gap because you say I'm interested in replacing existing languages? The main problem is tons of existing code nobody can rewrite fast. Thus there are two options: - stick to old technology and survive - choose newer one, rewrite everything, and consider missing deadlines Maybe its only my point of view. But Ruby, PHP etc have batteries included to create PDF and so on - that's why I keep telling that consider this to be important (to me only?) and why its hard for me to consider urweb to be an option for my projects at the moment. These are my honest concerns. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] What about a new project - general purpose ur like language which collaborates with existing languages?
Excerpts from Adam Chlipala's message of Thu Nov 21 14:25:54 +0100 2013: Lately I'm more interested in replacing common programming languages than interoperating with them. I agree on that. why target language X if you can do better anyway? Reasons would be avoiding bottle necks while development takes place. Thus the idea is to make transition to new technology smoother. Thanks again for your support and ideas. I guess my next urweb related project would be hack the compile so that a main.js can be generated which would run on node.js serving as cron-job/scripting case. That'll take some time. Thanks again for your support. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] What about a new project - general purpose ur like language which collaborates with existing languages?
Generating PHP or Node.js code defeats the purpose of Ur/Web to be safe (and fast) language for the web. JavaScript is interesting because - it as gc, thus you can write even desktop application in it - js is reasonably fast. - ur already supports JS generation. http://appjs.com/ http://www.tidesdk.org/ And many/many more (never tested any of those). Languages like Haskell show that it takes quite some time to get bindings to GTK/QT and so on. That's why escaping at a different language which already does this could be of interest in some specific cases. Sometimes you may have to feed a database with many data. Eg importing data with inserts only to mysql even using PHP makes the php process idle and mysql run at 100%. And this may take 8h. I know about mysqlimport and LOAD data as alternative. But even then an important of huge data sets can take long. Another use case would be exploring migrations without hacking the compiler etc. By targeting js nodejs would be toy, writing applications would be funnier. Thus succeeding in targeting nodejs would turn ur into a general purpose language fast. Maybe some kind of improved FFI would help, but rewriting the whole compiler to support generating PHP? Forget about PHP. Sorry for mentioning it :) its only interesting for low traffic sites where the customer knowns how to unzip the code base himself. Today there is mostly Server/Web. But in the future there will be clients such as smart phone/windows 8 apps as well google glasses extensions and the like .. I care less about source code transformation - as Adam said there may be tons of tools soon. I care more about how to describe my program/algorithm so that it can be translated easily with minimal loss (code size/speed/accuracy) Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] What about a new project - general purpose ur like language which collaborates with existing languages?
Excerpts from Adam Chlipala's message of Wed Nov 20 13:55:17 +0100 2013: These other ideas are too nebulous to me, I'd like to see - an artificial language which gets basics right such as knowing about side effects (monad), can rewrite continuation passing style (js backend), .. Has some kind of exception handling. Eg there must be a way to catch get_contents('file-which-doesn't-exist.txt) - be able to translate behaviour described in such artificial language to any project I'm working on whatever language that is. If its Ur/PHP/C/Haskell/Ocaml/Java/JS, so be it If such would exist all the tooling around ur could be written easily. Simple playground use cases: - parsing snippets / syntax highlighting for Vim/Emacs/jedit - encode emails properly (subject, body_html, body_text, list_of_attachements) returning blob - ... Ur could already be close. Supporting different backends would require conditional compilation. Some targets eg support latin1_to_utf8, other's don't. Business use cases would be translating API sample code accessing an online service to all the common languages out there including From PHP,Scala up to tcl. Eg like haxe I'd like to declare a # if js inline function query(sql : String, continuation: [rows] - m ()){ nodejs.query(sql, continuation); } # else if php inline function query(sql, continuation){ continuation(mysql_query(sql)); } #endif but use a compiler which is strong enough to remove the continuation for backends which don't require it (eg PHP). Haxe already comes close, but not close enough yet. Once you have such generic api implemented for different targets everything else would be simple. I guess what I'm looking for is still nebulous, but eventually clearer than before. Being able to reuse code is key. But sometimes there are constraints such as must be run in python interpreter .. AFAIK: ur comes very close, there is only one thing missing: more backends and spending more time .. ? Do you know about anything which already comes closer to my goals? Eg I know that the theorem prover Isabell is able to generate code for Haskell and ML or such. (I never used it) My research group does have some ongoing work on creating tools to make it easier to implement fancy languages like Ur/Web, and I would hope those tools will some day make a good starting point for project(s) like you propose! Please consider updating this mailinglist about progress/ links/ .. once in a while. In your research group there are also students? Do you think they would love to continue working on such stuff if there was funding ? Everybody wants to have a living .. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] What about a new project - general purpose ur like language which collaborates with existing languages?
Excerpts from Adam Chlipala's message of Sun Nov 17 13:49:59 +0100 2013: I would be looking for input from others on the best ways to modify the Ur/Web tools to support PhoneGap use. urweb is nice, and it shines if you use it in its solution space. However real world applications also need - migrations - may have to connect to multiple databases (Yes, I know I could reimplement mysql access using C bindings, but why?) - .. and suddenly urweb looks like to lock you in or cause additional work. Adam is likely to say urweb was written for high traffic .. I know. Still overall work could be simplified for ordinary projects, too. I'd like to stop reinventing the wheel. The ocaml/urweb like module system is genious: You can describe an idea, then instantiate a module and use it. Eg the example BinarySearchTree from http://impredicative.com/ur/tutorial/intro.html which is a module taking a paremeter of type Comparable and t. But why stop here? Why not allow to instantiate such a BinarySearchTree by telling the compile - which memory management to use - which target language - .. Sample use case assuming an imaginary special C preprocessor would exist: /* // preprocessed by bt = core.BinaryTree ( comparable = ... target-language: C target-memory-management: reference-counting ) bt = bt.add (2, text); int r = bt.lookup(2) */ printf(%d, r); Continuing in my imagination I see such (for C) JS_PARSER_C_1 = js_parser(for-c, use_boehmgc) JS_PARSER_C_2 = js_parser(for-c, use_urweb_style_memory_region_allocation_free_when_done) JS_PARSER_C_1.parse(string) JS_PARSER_C_2.parse(string) or such for js: JS_PARSER_JS = js_parser(for-javascript); JS_PARSER_JS.parse('string'0 and so on. I'm getting tired of reimplementing basic things such as maps, parsers. Do you know about existing work trying to achive this or getting close ? If it does not exist, what about trying to get funded by kickstarter and start work on such? Would anybody join such effort? Eg on Haskell there have been 2 job offers: http://www.haskell.org/pipermail/haskell-cafe/2013-November/111440.html In a private mail Tom replied that some of the technologies he's the job offer talks about might be open source. and this http://impredicative.com/ur/tutorial/intro.html Haskell (for server) objectiv-c and java (for client-side, such as smartphones) This shows that there are many use cases for such technology. Yes, I know about alt-js.org .. But if there is a project which requires using a java library I'd like to compile the server to JVM and be done. Eg Paul Phillips recently has quit TypeSafe. He contributed to the Scala compiler for multiple years. In his interview he said there is an order in getting things right = http://www.youtube.com/watch?v=TS1lpKBMkgg I cannot write a new compiler on my own, but I'd be willing to contribute to one. Eg haxe comes close solving the cross platform issue. But ther are at least two issues such as - string type is utf-8 (js backend), and byte string on almost all other target platforms. thus s[10] means something different depending on platform/encoding used. Luckily this doesn't matter for .split(',') or the like. - No callback contination abstraction (other then tha macro based monax monad implementation) which rerquires you to rewrite much code if you replace 2 by db.query('select ..', call_back) .. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] callbacks from the c ffi
Excerpts from Greg Samsa's message of Fri Sep 28 03:36:58 +0200 2012: I've been happily playing with Ur/Web and am pleased with the results so far. One problem I am stuck on however is creating a callback from Ur, in other words, calling a C function that can then call Ur functions. Unless I am misreading the docs this doesn't seem to be currently supported. Talk about what you want to do exactly. In looking at the generated C code, the api's generated are very straight forward, would it be possible to simply call those from a C function or would this have unintended consequences? Take care about memory management .. If you know whether this is fine you probably have the answer or you get close to it. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] exploring folders - I still don't get it.
Trying to copy paste all the definitions which I think I need to make the countFields sample from the tutorial work into my own file and prefixing it by my_ yields this code, and the error shown at the bottom. Which magic is happening in the standard library I've missed? Also where exactly is the recursion (repeat until the attribute set has been processed) happening? Is it somewhere hidden in the compiler? Marc Weber == CODE START == (* using my_ to get different names from top.ur / top.urs *) con my_folder = K == fn r :: {K} = tf :: ({K} - Type) - (nm :: Name - v :: K - r :: {K} - [[nm] ~ r] = tf r - tf ([nm = v] ++ r)) - tf [] - tf r fun my_fold [K] [tf :: {K} - Type] (f : (nm :: Name - v :: K - r :: {K} - [[nm] ~ r] = tf r - tf ([nm = v] ++ r))) (i : tf []) [r ::: {K}] (fl : my_folder r) = fl [tf] f i structure Folder = struct fun nil [K] [tf :: {K} - Type] (f : nm :: Name - v :: K - r :: {K} - [[nm] ~ r] = tf r - tf ([nm = v] ++ r)) (i : tf []) = i fun cons [K] [r ::: {K}] [nm :: Name] [v :: K] [[nm] ~ r] (my_fold : my_folder r) [tf :: {K} - Type] (f : nm :: Name - v :: K - r :: {K} - [[nm] ~ r] = tf r - tf ([nm = v] ++ r)) (i : tf []) = f [nm] [v] [r] (my_fold [tf] f i) fun concat [K] [r1 ::: {K}] [r2 ::: {K}] [r1 ~ r2] (f1 : my_folder r1) (f2 : my_folder r2) [tf :: {K} - Type] (f : nm :: Name - v :: K - r :: {K} - [[nm] ~ r] = tf r - tf ([nm = v] ++ r)) (i : tf []) = f1 [fn r1' = [r1' ~ r2] = tf (r1' ++ r2)] (fn [nm :: Name] [v :: K] [r1' :: {K}] [[nm] ~ r1'] (acc : [r1' ~ r2] = tf (r1' ++ r2)) [[nm = v] ++ r1' ~ r2] = f [nm] [v] [r1' ++ r2] acc) (fn [[] ~ r2] = f2 [tf] f i) fun mp [K1] [K2] [f ::: K1 - K2] [r ::: {K1}] (my_fold : my_folder r) [tf :: {K2} - Type] (f : nm :: Name - v :: K2 - r :: {K2} - [[nm] ~ r] = tf r - tf ([nm = v] ++ r)) (i : tf []) = my_fold [fn r = tf (map f r)] (fn [nm :: Name] [v :: K1] [rest :: {K1}] [[nm] ~ rest] (acc : tf (map f rest)) = f [nm] [f v] [map f rest] acc) i end open Folder fun countFields [ts :: {Type}] (fl : my_folder ts) : int = @my_fold [fn _ = int] (fn [nm ::_] [v ::_] [r ::_] [[nm] ~ r] n = n + 1) 0 fl val c:int = countFields [[A = int, B = float, C = string]] val main () = return xml head titleHello world!!/title /head body form {[c]} /form /body /xml == CODE END == main.ur|59 col 12| 59:58: Unification failure || Expression: countFields [[#A = int, #B = float, #C = string]] || Have con: || ((tf :: {Type} - Type - ||((nm :: Name - || v :: Type - ||r :: {Type} - || [[nm = ()] ~ r] = ((tf r) - tf (([nm = v]) ++ r))) - || ((tf ([])) - ||tf ([#A = Basis.int, #B = Basis.float, #C = Basis.string] || - Basis.int) || Need con: Basis.int || Incompatible constructors || Have: || ((tf :: {Type} - Type - ||((nm :: Name - || v :: Type - ||r :: {Type} - || [[nm = ()] ~ r] = ((tf r) - tf (([nm = v]) ++ r))) - || ((tf ([])) - ||tf ([#A = Basis.int, #B = Basis.float, #C = Basis.string] || - Basis.int) || Need: Basis.int ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Supporting 'style' attribute securely
Excerpts from Adam Chlipala's message of Sun Apr 15 20:12:00 +0200 2012: It's just like using eval() in an unsafe way, but Ur/Web rules out eval()! Can't you just use it as 'external' function and write a binding for it in .urp files? So the point is that all problems are known by reading the .urp file? So this discussion is about both: The urweb compiler and the HTML parser you wrote to sanitize / verify that user typed well formed HTML? Thus if a user wants to design his newsletter for a shop he should be prevented from using div style=something using a milicious url or the like? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] First-Class Polymorphism example
You're not far from a correct solution. Thanks - finally getting this piece feel so good :) You should consider adding this as optimization to the tutorial because it explains what @@ is about and it makes the example even nicer. What about kind polymorphic type level functions? con my_id :: K -- K - K = K1 == fn t :: K1 = t con my_id_2 = my_id my_id con my_id_3 = my_id gives errors: main.ur|130| 130:24: Some kind unification variables are undetermined in declaration This seems to work? Got it, it requires type annotations: con my_idX :: K -- K - K = K == my_id con my_idY :: K -- K - K = K == my_id my_id So trivial assignment is not guaranteed to work. I'm pretty sure this also is a very nice example.. Next thing I want to understand how fold and folder cooperate.. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] First-Class Polymorphism example
http://impredicative.com/ur/tutorial/tlc.html shows this example: type nat = t :: Type - t - (t - t) - t val zero : nat = fn [t :: Type] (z : t) (s : t - t) = z fun succ (n : nat) : nat = fn [t :: Type] (z : t) (s : t - t) = s (n [t] z s) val one = succ zero val two = succ one val three = succ two three [int] 0 (plus 1) == 3 three [string] (strcat !) == !!! Eg the succ function has t in its return type and in it n:nat arg. So should urweb be able to deduce type of t automatically? Should it be possible to replace the explicit :: by an implicit t ::: Type ? Trying to do so I get some unification errors - is it because I removed some [t] like args incorrectly? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] playing audio
Hi Gergely, I don't think this is an urweb issue. You should test that - the sound file is served (AFAIK for binary content the recommendation is to use another webserver such as apache, however writing an extension returning blobs for urweb should be easy) Thus verify that http://your-appp/foo.wav isn't 404 or such. - make sure that your browser supports the HTML tags. (just put everything into a directory and load the file via file:/// into the browser) If this fails you have to find a flash/silverlight/java applet based sound player This way you can track down what is causing the problem. Good luck. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] playing audio
Excerpts from Gergely Buday's message of Tue Jan 31 14:28:07 +0100 2012: It was not a question whether my browser supports the html tags I mentioned but they did not compile with urweb in the first place. Looks like you should add the missing tags to urweb then. Sorry for misunderstanding you. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] debugging xml data
Excerpts from Gergely Buday's message of Thu Jan 05 16:15:57 +0100 2012: I do not know whether there is already written routines for this task, but I have written some util functions to help debugging xml values. It strips html tags and newlines from already constructed xml data. Shouldn't we add regex support instead !? Then this all can be written as replace '[^]*|\n' with '' or the like ? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Bug Report
Try something like this: form action=your_logout_func_action input type=button value=logout /form :-( I'm not sure I understand this restriction either. Maybe there is a better explanation. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Linking to C Libraries
Excerpts from James Parker's message of Sat Dec 17 02:54:32 +0100 2011: http://darcsden.com/dbp/urweb-experiments/browse try http://www.impredicative.com/wiki/index.php/Libraries_and_FFI_bindings = uw-ruby http://gitorious.org/some-urweb-utility-libraries/uw-ruby the lib.urp shows how to do it. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] where to put disjointness proof when concatenating two type level records?
con con_type_level_record = fn (n :: Name) (n2 :: Name) (t :: Type) (t2 :: Type) = [n = t, n2 = t2] main.ur|141 col 84| 141:100: Couldn't prove field name disjointness || Con 1: [n = ()] || Con 2: [n2 = ()] || Hnormed 1: [n = ()] || Hnormed 2: [n2 = ()] Can this be done ? Probably it should look like this: [[n] ~ [n2]] Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] where to put disjointness proof when concatenating two type level records?
I remembered correctly: The wiki talks about it: http://www.impredicative.com/wiki/index.php/Disjointness_fun_-_creating_records_using_type_level_functions quote Constructing a record type taking two names and two types. Because disjointness can't be proofed at type level it must be done at expression level. My goal was to write a type level projection function - but looks like I can't do it for this reason. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] where to put disjointness proof when concatenating two type level records?
I don't think there's a good way to implement type-level projection from records. If you share some of the context where you want to use such an operation, I may be able to suggest an alternate idiomatic technique. Still toying around trying to understand more of the concepts and limitations. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] NEW USER NEED HELP WITH INSTALLATION
You should tell us which configure line you used. Eg retry using this explicitly setting installation path: ./configure --prefix=$HOME/urweb-install make install Then all the .so files can be found in ~/urweb-install/lib/* or such You can add ~/urweb-install/bin to PATH and you should be fine. If it doesn't I can offer an SSH account on which urweb just works. I don't have time to trouble shoot the issue right now. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] NEW USER NEED HELP WITH INSTALLATION
Excerpts from sampath kirupa shankar's message of Thu Dec 01 00:20:34 +0100 2011: please let me know what to do? I am a very eager student.and want to work on ur/Web.thank you You have to understand that - urweb creates a .c file and then - compiles it using gcc The compilation result of the .c file is then linked against precompiled code, shared or static libraries. In this stage a lot of unresolved references occur for whatever reason. Reasons may be the linker picking the wrong libraries or not finding them at all. If you're eager you can now study C and its compilation toolchain for weeks. Exporting export LD_LIBRARY_PATH=/usr/local/lib/urweb may just work - or it may not. What to do? Find the .ml code in urweb running gcc. Add some debugging/ trace statements so that you know exactly how gcc and the linker are invoked - then try to reproduce the errors show above in command line then try to fix them. alternatives: Get a operating system distribution supporting urweb such as nixos linux - or give me your SSH pub key - then I'll grant you access to a SSH account supporting urweb - then you can get started instantly. By the way: Writing in UPPER case is considered SHOUTING - and is very uncommon - maybe even discouraged. Its used by SPAM mails too often. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] 1/0 stopping server?
I'd the say the problem is that the resulting binary has even the possibility of crashing because of this kind of problem. Exiting with a stack-trace would be fine, but there is no reason the main process should exit just because in some Yes - I know we don't have stack traces. I'll open a ticket - because this crashing the server should be fixed. About Haskell you're right: But you can catch those issues and do both: show an error message to the user and send an email to the maintainer of the web-app.. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] ur ready for writing offline apps on windows?
Do you feel its suicide to use urweb for creating desktop based applications accessing local database data (offline) for Windows? Obviously the app would run in a localhost:XXX browser window then. Has anybody thought about making urweb udpate database schemes automatically? Then people can upgrade without knowing about database schemes? Which would be the best way to implement it? I'd just add a version table keeping data about updates. If there are newer scheme files = run updates before checking that the database still fits the scheme compiled into the application. Do you see any problems except compiling everything on Windows? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] MY_ORD = resolving eq class instance / functor?
How to make this work? Trying to understand how classes must be used: signature MY_ORD = sig class strict_less val lt : t ::: Type - strict_less t - t - t - bool val le : t ::: Type - strict_less t - t - t - bool end structure My_Ord : MY_ORD = struct class strict_less a = a - a - bool fun lt [a] (f: strict_less a) (x:a) (y:a) = f x y (* causing Can't resolve type class instance Class constraint: Basis.eq a *) fun le [a] (f: strict_less a) (x:a) (y:a) = f x y || x = y end The le implementation does not know which eq implementation to use ? Is using functor the way to go? I can't trivially apply the max sample from: http://www.impredicative.com/ur/tutorial/intro.html Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] MY_ORD = resolving eq class instance / functor?
Excerpts from Adam Chlipala's message of Mon Nov 28 15:19:04 +0100 2011: Perhaps it would be useful for you to review the concept of type classes in Haskell. They are very similar in Ur. I know the Haskell concept inside out. I'm still new to ur :) Two solutions that come to mind: 1) Add an [eq a] argument to [le]. That's what the tutorial did? Does work now. Sorry for the noise. Don't know what I did wrong previously. 2) Extend the definition of [strict_less a] to contain an [eq a], too. (Though this seems to create some dissonance with the words strict less!) That would have been structure My_Ord class strict_less a = (eq a) - a - a - bool ... ? I hopefully finally got it. Thanks. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] MY_ORD = resolving eq class instance / functor?
Excerpts from Adam Chlipala's message of Mon Nov 28 23:57:50 +0100 2011: No, it would be a pair of values, like eq a * (a - a - bool) or perhaps a record would be nicer. Does it make a difference passing a - b or (a * b) or {A = a, B = b} ? For readability only? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] stateful structure?
Is it possible to write a monad in ur? Of course it is. Search the mailinglist. There has been some discussion about it because there are some sealed monads meaning you can't reuse the definition - but you could duplicate them. hash in ur? ur has more powerful features: type checked dictionaries. If you want to find out whether ur provides hash like structures I'd grep for option because there must be a function returning either a value of a key or nothing. If it does not exist it can be implemented easily using data types. Eg have a look at Haskell's source and the Map type: http://haskell.org/hoogle/?hoogle=Map You can click on the Source links. I don't know exactly whether ur ships with such an implementation. Would be trivial to write though. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Compiling code at runtime
Excerpts from Anand Patil's message of Fri Oct 07 19:08:43 +0200 2011: I'm wondering about Ur/Web's suitability as a compilation target for scripting languages that are used from a web console. As a very simple example, I'd like to write an Ur/Web web application featuring a text entry field, in which users can paste Ur programs (perhaps using only a subset of Ur), which are then compiled and executed. How feasible would this be? The only way to run ur dynamically is by - compiling ur - invoking ur using kind of proxying There is no eval like function. In theory the JS backend is using kind of interpreter so eventually it would be doable in some way.o It would definitely require some internal changes because the list of urls urweb apps reply to is hardcoded in the .c files currently You may want to wait until someone else with deeper knowledge confirms or corrects my statements. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] 4th day on working on demo
postgresql setup: follow any howto. Then createdb NAME psql NAME # does this work? # load dump: psql dump.sql # dump.sql is created by urweb Then configure your urweb app to use database NAME. If you want to learn more about the postgresql authentication you have to read the manual (pdf). If you run urweb using standalone there should not be that much about authentication to worry about? This all has not much to do with urweb. Its only about how to connect to postgresql database. If you still can't connect to urweb ping me on irc.freenode.net, channel #ur, nickname MarcWeber and I'll try to help you get started. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] last type decl wins?
Should this be rejected? You can put this into a .ur file top level and still compile it!? type type_int = int val y:type_int = 2 type type_int = string val x:type_int = o type_int is assigned int and string! Or am I totally missunderstanding something here? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] A direction for Ur/Web
Excerpts from Adam Chlipala's message of Sat Mar 26 18:56:48 +0100 2011: I don't understand which hypothetical design structure of an Ur/Web library you are considering here. What do you want to do and what do you think would go wrong? If you use PHP, Ruby, Plone, any dynamic CMS you have a directory called /templates/main.template. If you look into it you find html{ var here }/html like syntax. So this is very very easy for anybody to customize. You don't even have to know the language the CMS was written in. Urweb can't do this easily - because everything is compile time. Now of course you could rewrite the urweb compiler using ur processing templates at runtime .. That's what I had in mind. in mind does not mean I want to code it. It was an attepmt to find out what Gergely had in mind exactly by providing some ideas because his description about configurability was not accurate when thinking about what can commonly be done using PHP CMS systems. If you let your customers edit the templates you also have to refuse all kind of guarantees - but that's another story :) I'm sure many people use WordPress without being prepared to write any PHP code from scratch. To me, it doesn't seem crazy that a similar situation could be created for an Ur/Web library, especially when equipped with a GUI for configuration. Well - all PHP tools which are used by mainstream have this setup: 1) upload to www directory 2) run in browser, configure database access, provide admin password, .. 3) remove /setup direcotry or file Now setting up the admin password can be done trivially - but not setting up database connection. You're right that urweb could go another way: offer a website which precompiles a binary after database access data has been entered. Then the binary can be uploaded .. (this means they have to trust your site doing the compilation ...) Of course this all can be done - but on job market places you commonly see requests like - got code from page xy - now make these adjustments: ... (change logo ,add flash ,integrate ...) And this kind of job is easy using PHP (at least those people buying the codes may have the impression. However I can't imagine how this customization takes place without starting a business around urweb offering exactly that: customizations. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] [PATCH] Allow alt attribute on img
Excerpts from Karn Kallio's message of Mon Jan 24 22:02:30 +0100 2011: Rationale: The possibility of an Ur/Web application generating invalid XHTML ( such as empty lists ) has come up on this list before ... in cases such as list nesting the programmer can produce code that does not do that. But the image element requires an alt attribute and currently Ur/Web does not allow one. The programmer cannot both use images and avoid invalid XHTML. Adding an optional alt attribute allows the programmer the choice. If you managed to understand how this all works in detail explain it to me so that I can use a DTD of XHTML to generate correct rules (minor some practical changes such as allowing ul/ul) Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Announcing an OpenID library
Excerpts from Adam Chlipala's message of Sun Jan 02 17:33:50 +0100 2011: P.S.: I noticed that, the last time I announced repos for separate It was me. I missed that. I thought the static page was static and I never looked for changes. I'm going to remove them adding a pointer to the static page instead. Thanks! Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] little benchmark on querying a table only
Excerpts from Gian Perrone's message of Mon Dec 20 08:34:23 +0100 2010: I see. Is the server and client running on the same machine? If they are, I can't see that as being a particularly valid test. yes. I don't see why this would make the test totally useless? Caching may take place. Usually I run the same test multiple times eg PHP - Ur - PHP - Ur If the first and second run differ significantly I hit something you described. But this time I didn't. I reran the test using 10,000 rows: urweb: 24.816 tota php:0.502 total This time I even used $s .= ... instead of echo ...; in PHP. its still faster. Adding ob_start(); (output caching) doesn't make a big difference. Of course you don't serve 10,000 rows usually. I also retried with one row only. Then the difference gets smaller. So the speed difference occurs somewhere from querying to concatenating the output. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] little benchmark on querying a table only
Excerpts from Chris Double's message of Mon Dec 20 09:56:27 +0100 2010: I tried a quick version that uses an 'each' instead of a List.app of a temporary list. Unfortunately my initial attempt resulted in a program that never seems to complete compilation. See mantis issue 44. Adams reply on mantis: This is an undocumented behavior of the optimizer, which tries to remove all uses of higher-order functions. For your example, this involves building a version of [each] for every possible argument, which of course includes 1000 different possibilities here! If you separate [f] into a separate argument, and put it first (since the optimizer only specializes a prefix of initial arguments with function types), then everything works fine. Nevertheless its unsatisfactory that the compiler doesn't stop/ fail in reasonable time. If there is an easy way aborting in such case (where its known that there are 1000+ cases - can you make the compiler fail ?) It always is a lot better to have a message which tells you what was going wrong. I didn't find a way to add a comment to that issue. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] little benchmark on querying a table only
Excerpts from Marc Weber's message of Mon Dec 20 23:19:37 +0100 2010: Excerpts from Chris Double's message of Mon Dec 20 09:56:27 +0100 2010: I tried a quick version that uses an 'each' instead of a List.app of a temporary list. Unfortunately my initial attempt resulted in a program that never seems to complete compilation. See mantis issue 44. Adams reply on mantis: This is an undocumented behavior of the optimizer, which tries to remove all uses of higher-order functions. For your example, this involves building a version of [each] for every possible argument, which of course includes 1000 different possibilities here! If you separate [f] into a separate argument, and put it first (since the optimizer only specializes a prefix of initial arguments with function types), then everything works fine. Another question: Does ml provide some profiling ? Or how do you find out where the compiler is spending most time? Did you use this: http://www.smlnj.org/doc/Compiler/pages/profile.html ? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] simple example about constructing rects - guarded types?
Excerpts from Marc Weber's message of Mon Dec 20 02:41:06 +0100 2010: http://impredicative.com/wiki/index.php/Disjointness_fun_-_creating_records_using_type_level_functions I've tried summarizing the examples on the wiki - because they illustrate several features: - type level function yielding a function creating an expression - disjointness annotations In which way is this related to the e! guarded expression application? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] simple example about constructing rects - guarded types?
Excerpts from Adam Chlipala's message of Tue Dec 21 00:42:14 +0100 2010: Marc Weber wrote: In which way is this related to the e! guarded expression application? The points where these need to be inserted are usually inferred. The demos make use of it multiple times: ./more/bulkEdit.ur|46| List.app (fn user = dml (update [map fst visible] ! ./more/versioned.ur|50| (SQL t.{nm} = {[v]} AND {e [[nm = t] ++ after] !})) ./more/versioned.ur|53| [_] ! ./more/dbgrid.ur|385| val wholeRow = @Folder.concat ! M.keyFolder M.rowFolder ./more/dbgrid.ur|406| (WHERE T.{nm} = {...@sql_inject meta.Inj v} AND {exp [[nm = t] ++ rest] !})) ./more/dbgrid.ur|409| [_] ! ./more/conference.ur|353| dml (update [map fst M.review] ! (ensql M.review r M.reviewFolder) ./more/orm.ur|73| ++ acc [[nm = ts] ++ after] !) ./more/orm.ur|76| [[Id = (id, row)]] ! Or do those ! have a different meaning? eg the first line is using update I've tried adding the ! everywhere at the examples you posted. But nothing compiled. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] simple example about constructing rects - guarded types?
I want to build a simple type constructor: It takes two names and two types and should build the record type {name1 = type1, name2 = type2} So this is the trivial implementation (?) con build_record :: Name - Name - Type - Type - {Type} = fn (a::Name) (b::Name) (c::Type) (d::Type) = [ a = c ] ++ [ b = d] And of course urweb can't proof that name1 differs from name2: typeexperiments.ur|16 col 69| 16:78: Couldn't prove field name disjointness || Con 1: [a = ()] || Con 2: [b = ()] || Hnormed 1: [a = ()] || Hnormed 2: [b = ()] So how to fix is? Is this a case where guarded types must be used? I couldn't find out how to apply it here. Also looking at this example: http://impredicative.com/wiki/index.php/Using_Top.Fold_to_count_fields_of_a_record: con rr :: {Type} = [One = int, Two = string, Three = bool, Four = list float] val q : int = @@fold [fn (rx :: {Type}) = (int)] (fn [nm :: Name] [t :: Type] [r :: {Type}] [[nm] ~ r] acc = 1 + acc) (0) [rr] (_ : folder rr) I don't understand why the arguments of the fn lambda are put in square brackets. Is this the polymorphic function abstraction: lambda [x ? kappa] = e which is listed in the expression section of the manual? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] segmentation fault when inserting 10000 instead of 1000 rows?
segfault occurs using both: http and fastcgi implementation. code: https://github.com/MarcWeber/urweb-benchmark (this replace Enum module by ur implementation only which still segfaults). Replacing the fill function by this variant (using 1 instead of 1000) makes it segfault: fun fill () = dml (DELETE FROM t WHERE 1=1); List.app ( fn i = (nv - nextval s; (dml (INSERT INTO t (Id, S1, S2, S3, S4) VALUES ({[nv]}, {[S1]}, {[S2]}, {[S3]}, {[S4]} ) (Enum.to 0 10); return (page fill xmldone/xml) However this works: fun fill () = dml (DELETE FROM t WHERE 1=1); max - return 1; List.app ( fn i = (nv - nextval s; (dml (INSERT INTO t (Id, S1, S2, S3, S4) VALUES ({[nv]}, {[S1]}, {[S2]}, {[S3]}, {[S4]} ) (Enum.to 0 max); return (page fill xmldone {[max]}/xml) (The difference is that I assign max to 1 and output it after done) So its the second bad behaviour I found using urweb using maybe non idiomatic code. If urweb should be used in production there is still a long way to go. A comprehensive test suite is missing which catches some cases. A type system catching most bugs upfront doesn't help me if the resulting application does not behave the way it should. So who is interested in stress testing urweb? Which is the best way to setup test suites which will catch regression in the future? Even if urweb behaves correctly gcc might introduce a bug - and I really don't want customers to find them. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] segmentation fault when inserting 10000 instead of 1000 rows?
So who is interested in stress testing urweb? Which is the best way to setup test suites which will catch regression in the future? Even if urweb behaves correctly gcc might introduce a bug - and I really don't want customers to find them. I added ticket 43 to mantis. I gave priority major because I feel this is the weakest point of the whole urweb system. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] little benchmark on querying a table only
Excerpts from Gian Perrone's message of Mon Dec 20 07:58:21 +0100 2010: I'm not sure how one is meant to interpret these results, exactly, but I'm not convinced that PHP _is_ faster according to the benchmark you've posted there. The 'user' and 'system' values are smaller for the Ur implementations. What is the final 'total' column meant to mean? I thought the output from 'ab' indicated how many requests you can serve per second in total, and hence a larger number in the final column would be better? Its the time output of zsh. ab is the benchmark tool which ships with apache. So you don't see the CPU time of the server process, but the one of the benchmark tool. The total time is the time it takes until you see the shell prompt again. I also compared with http -t20 and -c 10 (concurrency). Apache + PHP was a lot faster as well. PHP time drops very fast if you start load configuration options loading classes. In a real application urweb would outperform PHP very fast. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] Wiki: Polymorphic_Variants_Usage_Example
http://impredicative.com/wiki/index.php/Polymorphic_Variants_Usage_Example (* The commented out functions below do not compile .. the Medium constructor is not polymorphic; * it must decide on one of temp or size type *) If you replace the first Medium by _ it compiles. do those constructors Hot, Medium, Cold, Large, Small share the same namepsace? If not can I identify the first medium somehow, eg temp.Medium? If so declaration should be prohibited. If its not - why fun tempvalue temp = case temp of Hot = 10 | Medium = 5 (* replace Medium by _ and it compiles *) | Cold = 1 fun sizevalue size = case size of Large = 8 | Medium = 4 | Small = 2 From reading the definitions in basis.urs I find it hard to find out how to use them. How do you think about comments like this: (* See manual or http://impredicative.com/wiki/index.php/Polymorphic_Variants_Usage_Example *) Or do you think this kind of documentation will break thus causing more trouble than value? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] SQL error using sqlite
I should have taken more care reading the message. Excerpts from Adam Chlipala's message of Thu Dec 16 16:04:29 +0100 2010: BTW, this turns out not to have anything to do with SQLite. I expect the same error would show up with the other DBMSes. All of them are meant to be supported soundly by Ur/Web. The concepts of sequnces (pg) and autoinc (mysql) are very different. Eg in PG you can have OIDS (auto value which is not an incrementing number). I don't know how to implement this in MySQL off my head. (Using triggers would be a way - but does mysql_last_id() return it?) That's why I'm not sure whether urweb can (and wants!) to support all RDBMS in the same way. In fact you must write special code. Eg MySQL allows REPLACE INTO which es very convenient to use - but isn't (and won't be) supported by PG for transactional reasons or such. I'm pretty sure you can use MySQL to write something up which behaves like sequences - but its not the native autoinc solution. Unfortunately code is not that portable. I didn't even try how well MySQL or sqlite works yet. I saw that urweb supports sequences concluding incomplete MySQL support - which may have been a false (but definitely healthy :) assumption. P.S.: It can be hard to tell whether a message is a bug report, a question, or a discussion starter. This one seems like a bug report to me, in which case it's more convenient for me if it's opened as an issue in the Ur Mantis, rather than sent to the mailing list. In general, if you can get a parse error from GCC or a DBMS, then it's a bug. :) (Except in some cases where you use the FFI to do obscene things) That's why we post first letting you judge. Discussing issues is more convenient here. I tested the following quotings for table names: MYSQL: use `foo-bar` or `foo bar` sqlite: use foo bar postgresql: use foo bar Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] How to implement top-level id function f a = a ?
I tried solving the following task: Write function which maps a function a - b on all values of a record. Because I still have a to try and error :) I tried splitting the task into pieces: 1) I started using a simple map only (works): val app : a ::: Type - b ::: Type - (a - b) - a - b fun app [a] [b] f v1 = f v1 2) create an id function ensuring the argument is a record. However I didn't get to trying to ensure its a record because this test case fails: == main.urs == val main : unit - transaction page val recIdTopLevel: a ::: Type - a - a == main.ur == fun recIdTopLevel [a] b = b fun main () : transaction page = let fun recId [a ::: Type] (b:a) : a = b in return xmlhead/head body {[ (recId 7) ]} ok {[ (recIdTopLevel 7) ]} fails see below /body /xml end ERROR: main.ur|41 col 14| 41:27: Substitution in constructor is blocked by a too-deep unification variable || Replacement: UNIF:U127::UNIF:X ||Body: (UNIF:P::Type - UNIF:P::Type) Note: recIdTopLevel and recId should behave the same way. However only recId compiles (?!) I'm sure I'm missing something obvious again - or nobody ever tried writing a simple id function before (?) Is this a bug? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] CMS like features ? unsafe XML - encodings?
Excerpts from Adam Chlipala's message of Wed Dec 15 15:35:32 +0100 2010: types), then simple code like this gets the job done. Thanks If we are at it: Does it make sense to encode the encoding of a string somehow? Maybe so, but I'm woefully underinformed about encodings. The last time I looked into this, I think my conclusion was that sticking with UTF-8 could please everybody reasonably well. Let me quote two lines from gians blog code: Body = {Nam = Entry Body, Show = (fn b = xml{[if strlen b 25 then substring b 0 25 else b]}.../xml), I don't expect C's substring to be UTF-8 aware. In UTF-8 some bytes may be represented by up to 4 bytes. And for PDF files there may be a difference - because non-UTF8 fonts shipped with the viewers in the past - so .pdf files can be smaller. That is no longer mandatory for the future - however it still seems to work. But that's a corner case. So for now that case is not important enough. Eg In Haskell you could use phantom types: data UTF8 data ISOXX data Buffer a = Buffer String let x : (Buffer UTF8) = Buffer text class ConcatStrs a b c | a,b - c where concat :: Buffer a - Buffer b - Buffer c instance ConcatStrs a a a where -- same encoding: trivial By not providing an instance for ConcatStrs UTF8 ISOXX you disallow concatenating them. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Handling POST requests that aren't from forms
Excerpts from Chris Double's message of Wed Dec 15 09:40:40 +0100 2010: How can I write something in Ur/Web to handle this POST? Whatever the result of this discussion is - do you mind adding it to the a FAQ on the wiki? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] json implementation - need some help understanding what's happening here?
Excerpts from Marc Weber's message of Tue Dec 14 17:26:51 +0100 2010: 1) map json? Now: What does map json exacly mean? What does mapping over a class (json is a class?) do? just got that part. It gets the class for a record type. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] CMS like features ? unsafe XML - encodings?
Many web applications are using kind of xml += div#{xml_content_from_db}/div; which of course is unsafe. Which is the urweb way? Is there a blessXml function ? How can you render unsafe xml in a page? I had a look at the only listed application on the wiki: https://github.com/gian/urblog But it seems to be using kind of markup. Neither does it compile. Something broke it. Last change was in 2009. Which is the urweb way storing xml in a database and including it into a page? If we are at it: Does it make sense to encode the encoding of a string somehow? Eg Ruby 1.9 fixed the encoding hell by disallowing concatenating different encodings etc - of course nothing is typed statically. You do something liket this: string.force_encoding(UTF-8).encode(ISO-8859-1) which means assume its UTF-8, then encode as ISO-.. Encoding and xml validation has one in common: maybe invalid code may be taken out of a database - and ur should be able to use it and pass it over to the user. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] --- operator
Although I fully understand what it does I still don't know how .ur code looks like which uses --- operator. Can someone just replace the (* now drop AA .. *) comment by working code so that I can learn how this is done? In which way would the existing typing rule have helped me figuring out what to place there? let val rc1rc2 = {AA = 7, B = 8} val r = rc1rc2 --- (* now drop AA using --- operator *) (* using -- would be: rc1rc2 -- #AA *) in r.B end Thanks Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Using Ur/Web to create standalone JS applications
Well - do they say something about bandwidth? Using modem speed you can have unlitimed traffic - and you still can't serve your customers. Eg Germany - Korea makes a big difference. linode is about 10 times faster than xencon. So comparing different hosting services is not always easy. Some even let you buy additional traffic. Which kind of application do you have in mind where this really matters? Maybe we can help you find an alternative (Eg Amazon cloud like stuff) You are not specific enough. Which web application do you have in mind? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Using Ur/Web to create standalone JS applications
Excerpts from Adam Chlipala's message of Sun Dec 12 17:29:17 +0100 2010: If you still like it and lack of super-cheap hosting services is an issue, we may be able to work out some VPS sharing on this list. I wouldn't necessarily be against subsidizing a big chunk of the cost, if the language, tools, and community are being advanced. I put up the summary on this page: http://impredicative.com/wiki/index.php/Ur-based_Hosting I'd be willing to help supporting urweb users as well. So unless you do something like smugmug.com its very unlikely that hosting will be a constraint (unless your customer imposes them) Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] More questions
1) Is using mapM the best choice? Haskell has sequence or sequence_ Anyway: No inserts take place. What am I doing wrong? fun speed_test_insert () = let val numbers = Enum.to 1 10 in dml (DELETE FROM st WHERE 1 = 1); list - (List.mapM (fn i = dml (INSERT INTO st (Id, A, B, C) VALUES ({[i]}, {[TEXT A]}, {[TEXT B]}, {[TEXT C]}) ) ) numbers); return (page refreshed xml{[show numbers]}/xml) end 2) Tree demo: A witness that key belongs to the type class sql_injectable_prim, which indicates that both key and option key are fair game to use with SQL What does this exactly mean? Anyway: What about documenting that in basis.urs? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] More questions
Excerpts from Adam Chlipala's message of Mon Dec 13 00:16:13 +0100 2010: Marc Weber wrote: I don't see any obvious problem in the above that would lead to no rows being inserted, but I don't know which code for [Enum.to] you have in mind. I'd guess there's a bug where it's returning an empty list. The code can be found in the library playground (- wiki). You can see that I added {[show numbers]} and the page showed 0 :: 1 :: 2 [...] :: 10 :: Nil or such. postgresql server says: LOG: statement: BEGIN ISOLATION LEVEL SERIALIZABLE LOG: execute uw2: DELETE FROM uw_Main_st AS T_T WHERE (1::int8 = 1::int8) LOG: execute uw3: INSERT INTO uw_Main_st (uw_A, uw_B, uw_C, uw_Id) VALUES (E'TEXT A'::text, E'TEXT B'::text, $1::text, (- 20::int8)) DETAIL: parameters: $1 = '1 :: 2 :: 3 :: 4 :: 5 :: 6 :: 7 :: 8 :: 9 :: 10 :: []' LOG: statement: COMMIT for this code (pay attention to the last lonely INSERT which inserts the list itself to proof that its not empty): table st : {Id : int, A : string, B: string, C: string} fun speed_test_insert () = let val numbers = Enum.to 1 10 in dml (DELETE FROM st WHERE 1 = 1); list - (List.mapM (fn i = dml (INSERT INTO st (Id, A, B, C) VALUES ({[i]}, {[TEXT A]}, {[TEXT B]}, {[TEXT C]}) ) ) numbers); dml (INSERT INTO st (Id, A, B, C) VALUES (-20, {[TEXT A]}, {[TEXT B]}, {[show numbers]}) ); return (page refreshed xml{[show numbers]}/xml) end So would you mind running the same test on your machine? BTW, you could write [TRUE] instead of [1 = 1]. IMO, it's slightly nicer looking. I'd say ur could support DELETE without dummy where. That would be even prettier :) 2) Tree demo: A witness that key belongs to the type class sql_injectable_prim, which indicates that both key and option key are fair game to use with SQL What does this exactly mean? [sql_injectable] is an abstract type family. This means that its [...] I'll delay trying to understand all details. I tried asking: Why is this line necessary. I would have no chance coming up with that line myself. Shouldn't the information whether a key is nullable be encoded in the type ? The code looks like this: functor Make(M : sig type key [...] val key_inj : sql_injectable_prim key Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] what about adding short documentation to core library (.urs files)
Hi list, I feel the lib/ur/*.urs files should contain a little bit more documentation. Eg there is incl.urs - and I still have no idea what it is about at all. Everybody knows what option.urs is about. But what does mem.urs contain? Having short names is fine. I'd still appreciate having a short description such as (* option.urs: This file contains additional functions supporting the option type which either holds a value or doesn't *) Then you get an idea about wheter you want to learn more about that code or not immediately. Has anyone already written kind of hash / map ? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] More questions
Excerpts from Adam Chlipala's message of Mon Dec 13 01:33:11 +0100 2010: http://adam.chlipala.net/tmp/test.c gcc-4.4.3 (-O0) It only prints Outer once. Should I also try other gcc versions? With my GCC (and presumably with Marc's, too), it prints only one line of output, though I was expecting two. It seems GCC is dropping certain side effects that occur inside struct initializers in certain contexts. That is the root cause of the dropped SQL side effects from the larger example. So I'm happy that I didn't try debugging it. This kind of external issue is something which should be catched by test suites. That's why we should start one. New gcc versions will be released. Code will break. We don't want live systems to catch them. My reasoning here was that it would be way too easy to accidentally delete all rows from a table. The need to include an explicit 'WHERE' clause is a kind of are you sure? prompt. - http://impredicative.com/wiki/index.php/Won't_fix Nobody else will propose this again :) Thank you! Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Using Ur/Web to create standalone JS applications
Hi Vag, you may want to consider reading the posts on the archive which were posted within the last days. A Very similar question was asked. Adam's reply was something like: - JS could be done - but nobody spent time on it yet ( The question was about v8 using js on the server side) It seems that you have to persuade him to do so. - PHP ? Have fun. You probably really don't want it for speed reasons. (I know there are other reasons - so I see the value - but I also think that getting more examples / tutorials / libraries up and runinng is much more important) Because you can already generate JS - generating PHP would be doable. If you want this maybe try HaXe, it can already generate PHP - but you can't compare it to Ur/web Adam: I hope this reply reflects your attitude. It may be worth to create a wiki page labeled FAQ ? HTH Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] urweb-library playground - and question about how to complete implemention of enum like class
Excerpts from Adam Chlipala's message of Wed Dec 08 23:17:34 +0100 2010: There's already a non-trivial standard library in the compiler distribution. I'm also planning to take that meta.tgz tarball I linked to and turn it into a supplementary standard library specific to metaprogramming (and yes, I'll add a public Mercurial repo Real Soon Now). You're right, That's why I changed the meaning. https://github.com/MarcWeber/urweb-library Also pay attention to its description: http://impredicative.com/wiki/index.php/Libraries_and_FFI_bindings quoting myself: code which could be moved into the core library later. http://github.com/MarcWeber/urweb-library Contact MarcWeber using the github page to get push / commit access I would have liked to create a repository which is easier to get access to (eg by registering at github only) But I didn't find a way. I'm fine with creating a more neutral name such as github.com/urweb later if several users start contributing. (I also tried gitorious - but got yet another I'm sorry error .. ) Hope that's fine to everyone for now. I'm willing to change everything - but for now I use what I'm used to - which works best for me. So join this effort and let's create some useful code everybody can use. I also added a test branch. It adds the functions next and prev to enum - howver it doesn't compile. What am I doing wrong? == .urs file == class enum val mkEnum : a ::: Type - {ToInt : a - int, FromInt : int - a } - enum a == .ur file == class enum a = { ToInt : a - int, FromInt : int - a, Next: a - a, Prev: a - a } val mkEnum [a] (x : { ToInt : a - int, FromInt : int - a }) = { ToInt = fn a = x.ToInt a , FromInt = fn a = x.FromInt a , Next= fn a = x.ToInt (x.FromInt (a + 1)) , Prev= fn a = x.ToInt (x.FromInt (a - 1)) } I try to derive next, prev using FromInt, ToInt. There may exist optimized versions. Is it even worth allowing passing those optimized versions - if so how would this be done? In Haskell this all is only: class MyEnm a where toInt : a - Int fromInt : Int - a -- note how next and prev is using toInt and fromInt which will be -- defined in instances below next : a - a next = fromInt . (+1) . toInt prev : a - a prev = fromInt . (-1) . toInt instance MyEnm Int where toInt = id fromInt = id -- prev, next already defined above. But optimized versions could be -- specified here If I look at the amount of code I have to write Haskell wins. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] Howto make urweb generate invalid XHTML code?
Embed the result of this function into your xml. Eg fun lis lis = xml ul id=otnh { List.mapX (fn (i) = xmlli{[i]}/li/xml) lis } /ul /xml embed this xml into your main xml code: xml {lis (Nil: list int)}br/ /xml Eg try this validator: http://validator.w3.org/check?uri=http%3A%2F%2Fmawercer.de%2F%7Emarc%2Ftest.htmlcharset=%28detect+automatically%29doctype=Inlinegroup=0 (The html file was generated and uploaded to my server previously) What's the issue? ul/ul without li tags is not allowed according to XHTML. I agree that its very hard / impossible to check. Eg this would require special list types which ensure having at least one element or generating different HTML eg 0 elements: ul lino elements/li /ul vs 1+ elements: ul lifirst element/li /ul Without such different handling for the empty list case you end up trying to proof this case: items - queryCol (a sql query); return xml {lis items} /xml whose validness depends on the state of the database. I don't want to blame ur. I'm glad that it makes an exception. Anyway I think the manual should tell about such corner cases. ur/web should be honest to its users if possible. A footnote would be good enough. So I don't consider this a being a bug of Ur - but of its documentation. How do you think about this? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Howto make urweb generate invalid XHTML code?
Its getting worse: http://impredicative.com/ur/demo/Demo/Tree/main Insert this into the w3c validator: (14 errors). The dtd says: !ELEMENT ul (li)+ which means an ul must contain one ore more li elements. However the ur code of the demo looks like this: fun recurse (root : option key) = queryX' (SELECT * FROM tab WHERE {eqNullable' (SQL tab.{parent}) root}) (fn r = children - recurse (Some r.Tab.id); return xml li {f r.Tab}/li ul {children} /ul /xml) which results in HTML code like this: ul li.../li ul - only li tags allowed here. /ul So in that case ur doesn't even validate nesting order of tags (which WASH showed that its possible easily) So what's happening here? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] left join on same table?
I tried copy pasting the example from the demos to try whether ur supports join on the same table: xml - queryX (SELECT a.Id, a.A, b.Id, b.A FROM t1 as a LEFT JOIN t1 as b ON (a.id = b.id)) (fn r = xml /xml) It seems it does not - I get messages that a (the alias name) is an unkown table. So is the only way generating such joins by using views ? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] urweb-library playground - and question about how to complete implemention of enum like class
Excerpts from Adam Chlipala's message of Sun Dec 12 01:51:15 +0100 2010: Marc Weber wrote: I would expect that the compiler error messages do a good job of *g* - thanks. You've been right. The issue was me not using mkEnum at all. Works now. Added a second mkEnum2 constructor and used it for the int instance. So sorry for the noise. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Howto make urweb generate invalid XHTML code?
Excerpts from Adam Chlipala's message of Sun Dec 12 02:02:31 +0100 2010: You're not seeing some deep technical limitation in Ur/Web, which _does_ check nesting order of tags in a 100% sound way. Rather, I wasn't aware of this XHTML restriction when I wrote the types for the standard library's HTML tag combinators. Such code displays well in all the major browsers, right? I'm not sure it's worth changing, since that means more complicated types in the standard library. It is. For this reasons: Customers hear that pages should validate. So they find a validator and try to validate a page. If they see 20 errors although the page should be guaranteed to be bug free .. But maybe its not that important right now. Are those the lines which specify HTML tag orders? val p : bodyTag boxAttrs I tried enhancing the WASH idea and tried writing a XML library for Haskell which does 100% validation. However learning about the ul thing I also introduced a fuzzier wash like checking. It should be easy to tweak my library outputting the ur code instead of Haskell code. It reads the .dtd file. Now I know why I never found the dtd spec in urweb :) I'd be interested in how fast urweb still is if you do a more strict validation (let's say ensure 100% of tag order) I loved the head declaration most (XHTML strict): !ELEMENT head (%head.misc;, ((title, %head.misc;, (base, %head.misc;)?) | (base, %head.misc;, (title, %head.misc; Note how you have two choices to put title ! Trying to verify this can be done - but its getting really really funny then :) I really don't get why they made the standard that complicated - and probably browsers won't care anyway - but validators do ;) Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] left join on same table?
Excerpts from Adam Chlipala's message of Sun Dec 12 02:17:36 +0100 2010: The other problem is that the SQL syntax extension only recognizes SQL keywords in all caps, so you need to change 'as' to 'AS'. ok. compiles and runs - great! Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] interfacing with ruby
Excerpts from Marc Weber's message of Wed Dec 08 12:45:51 +0100 2010: http://gitorious.com/some-urweb-utility-libraries/uw-ruby I added it to the library and ffi page on the wiki http://impredicative.com/wiki/index.php/Libraries_and_FFI_bindings#uw-process Enjoy and provide feedback. I could'nt compile a function which does not take arguments (passing the conntext id) - so I had to add a dummy parameter. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] missunderstanding - or serious memory handling issue?
If you're suggesting special memory management for Ruby objects, that would probably be the best long-term solution, but it might not be much better than just using malloc(). Ruby has its own gc - you have to tell the gc to that it should not collect some vars - because you're holding references to them on C side. I wondered about whether ur should be able to control the amount of memory being used by a context. If you use malloc you can hold arbitrary much data. If you used uw_malloc you knew that ur could apply a limit and fail. I rewrote it using malloc / free. Its not worth thinking about for those view bytes. I was also wondering whether uw_malloc should be used for serving files etc. - probbaly not. The next I wasn't sure about was speed: Is it worth trying to avoid some mallocs or not. If uw_malloced data was valid until all callbacks finished running - I could have used uw_malloc which probbaly is faster than malloc. Worse: mallocing 2 bytes could realloc prevent from resizing continuously triggering a retry (?) I don't know enough about malloc implementations to make a judgment. Because ur has special knowledge about the memory (it will no longer be used after a run has finished) it can much better than malloc and free. That's why it could be worth adding a uw_malloc_keep_valid_until_all_callbacks_were_called function - or changing the semantics of the existing uw_malloc. But then you can no longer use realloc. I should and will stop thinking about it now. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] interfacing with ruby
Excerpts from Adam Chlipala's message of Wed Dec 08 15:25:52 +0100 2010: I'm not sure exactly what you're referring to, but, if this is meant as a description of something you wish you could do but haven't been able to, I might be able to help if you can provide details. I copy pasted the wrong tag. I tried pasting -ruby: http://impredicative.com/wiki/index.php/Libraries_and_FFI_bindings#uw-ruby I tried saying: Try the code interfacing with Ruby now - it seems to work here. I also added your JSON download to that page. I hope that's fine. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Documentation codes
Excerpts from Karn Kallio's message of Wed Dec 08 16:08:21 +0100 2010: http://www.impredicative.com/wiki/index.php/Using_Top.Fold_to_count_fields_of_a_record Great. Does it make sense to create a new page for each snippet? I'd start a ur-snippets page and add all of them to one page. Then you can even subscribe to changes - so you won't miss new ones. Even better: What about creating a snippet library? urweb eliminates dead code so collecting code at the begging could be interesting to all. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Documentation codes
Excerpts from Davor Ocelic's message of Wed Dec 08 16:31:45 +0100 2010: We could even post snippets with description what we'd like done, and wait for someone to fill the solution in ;-) which vcs ? I'd suggest one of fossil, git, mercurial, bazaar, monotone I think its very important that everybody can push without asking. I know about github and gitorious (git hosting services) which let you add collaborators easily. A git gist could do the job as well - however I don't know how long they live. fossil is great because it includes a wiki and a bug tracker. So you could eventually also add tutorials (?) and read them offline. Any preferences? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Documentation codes
Excerpts from Davor Ocelic's message of Wed Dec 08 17:15:58 +0100 2010: But any other means wouldn't hurt either... git repos (and probably all others) can easily be browsed from the web. You can't copy paste the wiki and run test code easily. Neither can you use it as library without copy pasting code. Moving towards a ur standard library would be fine :) If nobody has a different preference I'm going to create a git gist tomorrow. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] missunderstanding - or serious memory handling issue?
Excerpts from Adam Chlipala's message of Wed Dec 08 02:16:39 +0100 2010: None of the callbacks introduced by the compiler itself will ever touch memory in the context-local heaps (which is the kind of memory that uw_malloc() manages). Think about it this way: request 1: is using uw_malloc to store some pointers in the memory block request 1: is using uw_malloc to get a huge memory block. realloc will be called returning a different pointer. context change. request2 is issued. request 2: is using uw_malloc to get some bytes. It is writing to them. Those bytes happen to be the ones I stored pointers in (request 1) calling sleep 3 request 1: now free is invoked. Trying to read pointer from memory which was overridden by request 2: request 1: segfault. fine, By free I mean uw_register_transactional free callback or uw_push_cleanup callback functions. You're right: ur itself is not writing to the memory. There is still a segfault. What's wrong ? Should I be using malloc only? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Strategy - UrWeb Backend
My position is that the total time the whole Ur/Web community spends writing libraries to access with the FFI should be negligible compared to the time spent writing the main applications. Sure, it can be a pain to get C code right, but it's probably worth it, given the long-term performance gains. Reasonable people may disagree on this. I find it very encouraging that an informed developer besides me (i.e., you :]) was able to wrap a Ruby interpreter so easily. I personally would be more inclined to build an ML or Haskell interface, I thought about Haskell. But interfacing would have been more complicated. This way you can use Ur to create Ruby objects and read them easily - the way you serialized JSON objects. There is no C function haskell_list_cons(head, tail) you can call AFAIK. In ruby you can do: uw_Ruby_return_dummy_arrray(...){ VALUE i = rb_int_new(20); VALUE ar = rb_ary_new(); rb_ary_add(ar, i); // prevent them from being garbage collected by ruby gc: protect_value(i); protect_value(ar); return ar; } Because ruby is dynamic you can pretty easily wrap almost everything without coding more C. Of course you could have written yet another tool to generate AGDTs for both: Haskell and UR.. But I want to keep thinks simple. If ruby failed I maybe would have tried racket - or tried getting my job done using Haskell. I don't know. It seems that I'm very close so I do no longer think about it. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] How to design JSON interface?
is recursive types beyond lists; They can't be serialized AFAIK. There is no representation. eg var d1 = {} d1.dict = d1; So it's fine. Eg this is what PHP is doing: $a = array(); $a['dict'] = $a; // be careful and assign a reference. = would make a copy! echo json_encode($a); || Warning: json_encode(): recursion detected in /home/marc/test.php on line 5 || {dict:{dict:null}} I'll give it a try. Thank you for being that responsive. :) Yours Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Generalizing transactions
Excerpts from Karn Kallio's message of Tue Nov 30 16:24:43 +0100 2010: Adam, now that somebody ( Marc Weber ) is working on an application ( payment gateway ) where the transaction model of Ur/Web does not cleanly apply, is there a chance of you generalizing Ur/Web transactions in a safe, principled way ( that allows representing the semantics of the application's effectful operations within Ur/Web )? For example, I think that the problem of leaving a permanent record of an event ( e.g. receiving an order and not removing it on failure rollback ) could be handled with a SAGA that has a null compensation for the process of writing the record. Karn Kallio: I don't know yet whether I'm going to implement them all - or writing some interfaces to reuse existing code. SAGA? Wikipedia is refering to: * SAGA (computing), a Simple API for Grid Applications * SAGA GIS, a geographic information system Do you talk about any of these two? The manual says: context is the type of state that persists across handling a client request So it looks like I can use uw_(set,get)_global and uw_malloc to keep caches. I can use the uw_set_global rollback / commit handler to set a flag to succeeded or failed in the data structure. I know that the free handler will be called after the request finished (giving up (fatal error) or suceeding). The flag will tell me whether I have to trace a failure in a logfile. Do you want users to print to stderr for logging - or do you want to introduce a logging function which also adds time stamps etc? (good idea IMHO) - Does it already exist? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] How to design JSON interface?
I'd like to implement toJson and fromJson which can read typed values from json representation and back automatically. I still don't know how to represent this in urweb: I found: - the eq class in basis.ur - but the implementation of mkEq is written in ml (?) - the classes in tests/ - but those methods don't take a type of t worse: When copy pasting type_classMod2.ur into my own .ur file it fails to compile: main.ur|27 col 30| 27:34: syntax error: replacing TYPE with UNDER Line 27 : val default = fn t :: Type = fn v : c t = v Is using a class the best way at to implement a formJSON and toJSON code? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] NEW USER NEED HELP WITH INSTALLATION
Excerpts from sampath kirupa shankar's message of Wed Dec 01 05:45:09 +0100 2010: Hi everybody, I am Kirupashankar Sampath, a grad student at CSU Fresno, CA. I am interested in Ur and have started a project of proving the safety theorems of Ur language. I am not able to install Ur from the instructions on the home page. I have a windows vista.could anybody please give me a step by step procedure for the installation. Thank you. If a shell is good enough I can provide an account which is able to run urweb easily (running nixos linux). Send me an email if you're interested. For windows you have the following options: - linux using virtualization (eg virtualbox) (32 and 64bit) - linux using a linux kernel which urns natively on Windows (eg colinux, 32bit only) - try cygwin (probably nobody has tried running urweb on cygwin before. So if you want to get started I'd not spend too much time on it - depending on settings cygwin also executes slower due to permission checkings etc - Thus its likely that you would be spending more time than necessary on configuring etc ) If you have virtualizing support in your computer virtualbox will be the most simple solution to get up a linux system running because networking just works etc. By the way: WRITING UPPER case only could be considered shouting - writing everything in upper case will triggers a this is spam feeling in my mind. So I tend to delete mails like this without reading. Maybe that's because I missed it in the first place (?) regards Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Generalizing transactions
Excerpts from Adam Chlipala's message of Wed Dec 01 15:50:26 +0100 2010: Yes and no. The global functions will accomplish what you want. However, pointers allocated by uw_malloc() should not be referenced across requests. You should use regular malloc() for such memory. Note that uw_set_global() allows you to specify a function to call to free the value you set; for anything that lasts across requests, you do need to start thinking about explicit freeing. What does request mean exactly? The user (browser) issues a request. Then urweb will run code and maybe retry. Therefore its still the same request. 1) request made 2) urweb runs code, C is calling abort (retry) 3) urweb reruns code - this time there is success. Now will pointers be freed after 2) or after 3)? From reading request in docs I assumed its always freed after 3). So you should be more explicit. Probably its best to clarify this in the description of uw_malloc. Between 2) and 3) heap may increase. But when will the old heap be freed? if it was freed after 3) you could use uw_malloc for keeping the cache data (improving speed) Even some of the already-implemented protocols will ignore stderr output. There is some generic logging stuff implemented now, but only for use by the protocols, as it isn't exposed via contexts. This seems like a reasonable change to make, and I'll look into it if you open a Mantis issue. done. I think its not important to have the perfect logging implementation. I think its important to add function which can be used so that the implementation can be made perfect without grepping for printf or cout .. statements. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Generalizing transactions
Excerpts from Adam Chlipala's message of Wed Dec 01 16:14:56 +0100 2010: This could have a big impact on memory usage. You'd essentially need a separate heap for each failed execution whose pointers you want to keep valid. How often do you retry? How often do you expect retries? Complexity would be about adding a linked list. So it would be bearable :) I'm fine with your judgement though. You should also add the info to uw_{set,get}_global Maybe consider making a difference between request and run and define it. What about uw_push_cleanup and uw_pop_cleanup() uw_pop_cleanup runs the handler. So it looks like the handler should be run always. However you don't say what happens when you don't pop and there is no error. Is the hnadler run then ? Thus are all cleanup functinos run always? It looks like a bug to me not popping handlers yourself. It can't hurt saying so if that's the case. Eg adding You should always pop the cleanup function if there is no error yourself would suffice. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] interfacing with C or other languages - example system
Excerpts from Adam Chlipala's message of Tue Nov 30 00:37:53 +0100 2010: Couldn't you just as easily write a C function that takes options as input and then always executes verify-pay-confirm with those options? That would make sure the Ur/Web layer can't introduce zany non-transactional behavior. In the end you're right. The way to go is create bindings for curl and cache the replies. If restart happens the cached reply will be returned. Issue solved. Does a transaction always last form the begin of generating a result page until the end? Thus could I use the commit callback to remove the cache ? Could I use the context pointer as key to find a cached reply within one attempt to generate the output page which may be retried? Thus will the same ctx be passed when a request is rerun? Or is there no way to limit caching to a HTTP request only? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] interfacing with C or other languages - example system
Excerpts from Adam Chlipala's message of Sun Nov 28 21:58:18 +0100 2010: That's right. The runtime system will also restart if an optimistic SQL concurrency violation is detected, when certain errors are signaled, etc.. Don't know yet whether that's smart behaviour. How exactly is determined how much heap will be allocated for a request? There are some cases where you don't want to retry; Some payment systems redirect customers using a return url which tells the web system that the customer has entered all the data. Then the web system is supposed to verify and confirm the data - because the return url parameters can be manipulated by the user. However you can't run that confirmation query - which is typically a http request - twice. The second time they'll return an error telling you that transaction id has been used previously. Worse: Because urweb rolls back everything db related you don't even have traces about it. So the custmer has to pay - and you don't have an order. I can see 3 solutions: a) write a layer between urweb and the payment service which is caching the confirmation results. Bad: You can't use urweb for writing it. You could do this caching in C as well - but I'd like to use a higher order language to get my jobs done.. b) tell urweb to use a huge heap size so that its very unlikely that the issue appears - is there a project configuration option specifying a min heap size? c) never fail for heap reasons. Use a linked list of heap blocks. If one is full allocate another one which is large enough and continue. About the pointer; I'm lucky that it worked. http://gitorious.org/some-urweb-utility-libraries/uw-process/commit/ff620ea22b3209c73482c50ec24909ea581ac4ab Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] new list of companies / freelancers supporting urweb in the future
Excerpts from Adam Chlipala's message of Thu Nov 18 20:31:05 +0100 2010: Right now, this is hard, since I have the wiki set up to require explicit granting of write access. Anyone who wants this access just needs to e-mail me with a wiki account name. I added some minimal documentation: http://www.impredicative.com/wiki/index.php/Contributing_to_this_wiki So interested people will find it. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] Some more questions:
CGI doesn't support channels, while FastCGI involves multiple threads in a single process. Pending channel sends are only stored in-memory and would certainly be lost in a sudden crash. So its important to tell webservers to only start one instance. #{..} :-( my fault. I should have recognized it. Back to system(). I made the example from the wiki compile. I don't understand the scope of regions yet. quote (manual): void *uw_malloc(uw_context, size_t); [...] Thus, there is no uw free(), but you need to be careful not to keep ad-hoc C pointers to this area of memory. For performance and correctness reasons, it is usually preferable to use uw malloc() instead of malloc(). The former manipulates a local heap that can be kept allocated across page requests, while the latter uses global data structures that may face contention during concurrent execution. 1) looking at urweb.h there is a uw_free(). So ist he documentation out of date here? Or is it an internal function? 2) can be kept allocated across page requests Can I tell urweb to keep or throw away the memory after a request completes? When is such a region guaranteed to end so that the memory will be freed? When serving files that way you don't want urweb to eat up all your memory. Why not use apache? Using urweb it is easier to restrict access. I don't have a use case - I'd like to be aware of the limitations. Let's assume I used system(cat 200mb.file) and send this to the user using blob (less than optimal because its not streamed .. But I don't care for now) .. When would the buffer I allocated to keep the stdout data be freed again? Because there is no uw_realloc (?) is the way to go using realloc, malloc copying the data into a uw_malloc'ed buffer before returning? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
[Ur] howto serve arbitrary files (PDF/ icons), and more
1) Which is the ur way to serve arbitrary files such as content-type application/pdf ? The PDF files could be - generated on the fly (eg by running latex, lout, ...) - read from a file? Eg adding allow url css/* to the configuration file a link to css/css.css complied. Status is still 404 (not found) I also tried adding path css=./css strace showed that urweb didn't even try to load a css.css file. 2) Does urweb support the system() FFI command? If not is there a small example which could help getting started with exploring FFI? system could be used for many quick dirty implementations. 3) How to specify the index file which will be used if no path is given? Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Re: [Ur] HTTP client requests
Excerpts from Chris Double's message of Wed Nov 03 09:36:29 +0100 2010: Are there any libraries available in Ur/Web for making HTTP requests to other servers? I'd like to be able to call REST and JSON services on a remote server and use the results in pages returned by an Ur/Web app. If there aren't any existing libraries, any thoughts on a good way of doing this? The C library curl is a possible solution which should be evaluated ? Some APIs require HTTPs. API's I've seen and used requiring HTTP(S) include SMS and payment serivces.. Marc Weber ___ Ur mailing list Ur@impredicative.com http://www.impredicative.com/cgi-bin/mailman/listinfo/ur