[Ur] Advice on SQL tables needed

Adam Chlipala adamc at impredicative.com
Thu Jan 21 03:41:02 EST 2010


Artyom Shalkhakov wrote:
> Having written a bit more of my application, I encountered a pattern
> which I'd rather abstract away, but don't know how.
>
> In my case, there are about four tables, each of which is equipped
> essentially the same code (namely, CRUD operations). What I'd like is
> to provide such table to a parameterized module, which would give me
> the following functions:
>
> val create: row' ->  transaction row
> val read: id ->  transaction (option row)
> val update: row ->  transaction unit
> val delete: row ->  transaction unit
>
> (here, row' would be the schema of the table without the primary key,
> whereas row would contain the primary key -- here, the primary key
> would be a simple auto-incrementing integer)
>
> I've studied the samples (orm and crud), but one of them unnecessarily
> ties UI to the table structure, and another tries to abstract tables
> away, which I don't want to do.
>    

I would do this with a functor much like that of the Orm1 demo, but 
accepting the table as a value within the functor's input module.



More information about the Ur mailing list