On 08/20/2015 07:54 PM, Stefan Scott wrote:
I'm attempting create a simple demo using this syntax.
The demo should define a function (eg `table_to_xml aTable aField`)
which accepts a table name and a field name.
Then this function is called using different table names and field
names, to run some SQL queries and generate some XML.
I haven't found any concrete examples of this sort of thing in the
manual or online, so the following is just a wild guess:
(* INCORRECT/tableToXml.ur *)
table t1 : { F1 : string }
table t2 : { F2 : string }
fun table_to_xml
aTable (** OK? **)
aField (** OK? **)
The basic problem here is that both of these should be constructor-level
parameters, enclosed in square brackets, not value-level parameters, as
they are defined above.
The less basic problem is that you will need to provide more involved
annotations, including a disjointness constraint and a value-level
parameter for the table, to get it all to type check. I do believe that
Chapter 2 of the official Ur/Web tutorial goes into sufficient detail on
those concepts.
=
queryX1
( SELECT {aField} (** OK? **)
Every field projection in a query needs an explicit 'table.' part.
FROM {{aTable}} ) (** OK? **)
I believe this needs an explicit 'AS' clause.
{[r.{aField}]} (** Q (1) **)
Looks fine here.
t1x <- table_to_xml t1 #F1 (** Q (2) **)
;
t2x <- table_to_xml t2 #F2 (** Q (2) **)
;
You'll need to enclose the actual parameters in square brackets, too.
_______________________________________________
Ur mailing list
[email protected]
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur