On 10/17/2013 09:26 AM, Adam Chlipala wrote:
With (1), you can do (in Template.urs):
con product_constraints :: {{Unit}}
constraint [Pkey] ~ product_constraints
val product : sql_table [Id = int, Caption = string, Slogan =
string, Logo = string, PageId = int]
([Pkey = [Id]] ++ product_constraints)
It might be worth extending the [table] syntactic sugar to do
something like the above automatically; maybe I'll try it later.
OK, I've now pushed that extension, and it seems to work well! Here's
an example, demonstrating a kind of subtyping over the constraints of
tables. That is, a table may be considered to implement a signature
item that only declares a subset (possibly empty) of the full constraint
set.
functor F(M : sig
table t : { A : int, B : int }
PRIMARY KEY A
end) = struct
open M
fun getByA a = oneRow1 (SELECT * FROM t WHERE t.A = {[a]})
end
table u : { A : int, B : int }
PRIMARY KEY A,
CONSTRAINT B UNIQUE B
open F(struct
val t = u
end)
_______________________________________________
Ur mailing list
[email protected]
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur