annotate demo/more/orm.ur @ 987:6dd122f10c0c

Better location calculation for record unification error messages; infer kind arguments to module-projected variables
author Adam Chlipala <adamc@hcoop.net>
date Mon, 05 Oct 2009 16:36:38 -0400
parents
children d923b47e483d
rev   line source
adamc@987 1 con link = fn t :: Type => unit
adamc@987 2
adamc@987 3 con meta = fn col :: Type => {
adamc@987 4 Link : link col,
adamc@987 5 Inj : sql_injectable col
adamc@987 6 }
adamc@987 7
adamc@987 8 functor Table(M : sig
adamc@987 9 con cols :: {Type}
adamc@987 10 val cols : $(map meta cols)
adamc@987 11 constraint [Id] ~ cols
adamc@987 12 val folder : folder cols
adamc@987 13 end) = struct
adamc@987 14 type id = int
adamc@987 15 val inj = _
adamc@987 16 val id : meta id = {Link = (),
adamc@987 17 Inj = inj}
adamc@987 18
adamc@987 19 sequence s
adamc@987 20 table t : ([Id = id] ++ M.cols)
adamc@987 21
adamc@987 22 fun create (r : $M.cols) =
adamc@987 23 id <- nextval s;
adamc@987 24 dml (insert t ({Id = sql_inject id}
adamc@987 25 ++ map2 [meta] [Top.id] [sql_exp [] [] []]
adamc@987 26 (fn [t ::: Type] (meta : meta t) (v : t) => @sql_inject meta.Inj v)
adamc@987 27 [_] M.folder M.cols r));
adamc@987 28 return id
adamc@987 29 end