[Ur] More questions: sql_injectable, reactivity and interaction with CSS

Adam Chlipala adamc at impredicative.com
Mon Jan 11 07:57:10 EST 2010


Artyom Shalkhakov wrote:
> First, Is there any way to write an sql_injectable instance?

Yes, but only by building on the instances included in [Basis].

> I'd like
> to serialize and deserialize a tree data structure (xbody in
> particular) to store it in the database.
>    

The Ur/Web version in the public Mercurial repo includes a new type 
family [Basis.serialized], such that any [serialized t] is 
[sql_injectable].  See basis.urs for the details.  I should make a new 
release in the next few days, and it will contain this functionality 
(and you can use the repo's version for now, if you can't wait).

> So is Ur "reactive" in the sense that modification of
> sources is automatically propagated to every dependent dyn tag?
>    

That's right.  None of the event-y stuff associated with traditional FRP 
is included.  Perhaps I should change the way I describe these features 
in documentation.

> I'm trying to write a simple in-place editor for text. Given some text
> on a webpage, users can double-click on a paragraph, say, which turns
> the text into a text box and two buttons (apply and cancel). I don't
> know how to do this.
>    

Well, you could, say, create a [source bool] that is changed by the 
[onclick] handler of the paragraph.  The paragraph content would be a 
<dyn> that does different things based on the source's value.

> Third, what is the approach to styling elements? ATM, the only way to
> communicate with CSS is via classes, but is full CSS embedding worth
> it?
>    

I think many would say that it is "good programming practice" to 
encapsulate all styles inside classes, and so we have at least that one 
benefit of the present architecture. ;-)

Supporting embedded CSS safely would be non-trivial, as CSS supports 
executable code (for instance, in a property like url(javascript:...)).  
Support for 'style' attributes is not on my near-term to-do list.

> And finally, can you compare Ur to OPA of<www.mlstate.com>?
>    

I think you can get a good sense for the two languages' aesthetic feels 
by comparing the demos that are online.  That is my only source of 
information on OPA, as I have not tried it myself.

I believe OPA is more or less "an ML," while Ur has a much more 
expressive type system.  I first started working on Ur to support new 
kinds of metaprogramming, most of which are impossible in OPA or any 
other essentially ML-like language.  OPA also seems to lack support for 
relational programming, which Ur/Web gives through interfacing with an 
external DBMS.

There are probably some other important differences, but MLstate is 
being too secretive thus far for me to find them easily.



More information about the Ur mailing list