view 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
line wrap: on
line source
con link = fn t :: Type => unit

con meta = fn col :: Type => {
              Link : link col,
              Inj : sql_injectable col
              }

functor Table(M : sig
                  con cols :: {Type}
                  val cols : $(map meta cols)
                  constraint [Id] ~ cols
                  val folder : folder cols
              end) = struct
    type id = int
    val inj = _
    val id : meta id = {Link = (),
                        Inj = inj}

    sequence s
    table t : ([Id = id] ++ M.cols)

    fun create (r : $M.cols) =
        id <- nextval s;
        dml (insert t ({Id = sql_inject id}
                           ++ map2 [meta] [Top.id] [sql_exp [] [] []]
                           (fn [t ::: Type] (meta : meta t) (v : t) => @sql_inject meta.Inj v)
                           [_] M.folder M.cols r));
        return id
end