adamc@990: con link :: (Type * Type) -> Type
adamc@990: val noParent : t ::: Type -> link (t, unit)
adamc@987: 
adamc@1002: con meta = fn (col :: Type, parent :: Type) => {
adamc@1002: 	      Link : link (col, parent),
adamc@1002: 	      Inj : sql_injectable col
adamc@987: 	      }
adamc@987: 
adamc@991: val local : t :: Type -> sql_injectable t -> meta (t, unit)
adamc@991: 
adamc@987: functor Table(M : sig
adamc@990: 		  con cols :: {(Type * Type)}
adamc@987: 		  val cols : $(map meta cols)
adamc@987: 		  constraint [Id] ~ cols
adamc@987: 		  val folder : folder cols
adamc@987: 	      end) : sig
adamc@987:     type id
adamc@990:     type row' = $(map fst M.cols)
adamc@990:     type row = $([Id = id] ++ map fst M.cols)
adamc@990: 
adamc@987:     val inj : sql_injectable id
adamc@990:     val id : meta (id, row)
adamc@987: 
adamc@990:     val create : row' -> transaction row
adamc@988:     val delete : row -> transaction unit
adamc@988:     val save : row -> transaction unit
adamc@988:     val lookup : id -> transaction (option row)
adamc@988:     val list : transaction (list row)
adamc@989: 
adamc@989:     con col :: Type -> Type
adamc@989:     val idCol : col id
adamc@1002:     val cols : $(map (fn (colm :: Type, parent :: Type) =>
adamc@1002:                          {Col : col colm,
adamc@1002:                           Parent : row -> transaction (option parent)}) M.cols)
adamc@989: 
adamc@989:     type filter
adamc@990:     val find : filter -> transaction (option row)
adamc@989:     val search : filter -> transaction (list row)
adamc@989: 
adamc@989:     val eq : t ::: Type -> col t -> t -> filter
adamc@989:     val ne : t ::: Type -> col t -> t -> filter
adamc@989:     val lt : t ::: Type -> col t -> t -> filter
adamc@989:     val le : t ::: Type -> col t -> t -> filter
adamc@989:     val gt : t ::: Type -> col t -> t -> filter
adamc@989:     val ge : t ::: Type -> col t -> t -> filter
adamc@989: 
adamc@989:     val _and : filter -> filter -> filter
adamc@989:     val or : filter -> filter -> filter
adamc@987: end