[Haskell-cafe] Using Template Haskell to make type-safe database
wss at Cs.Nott.AC.UK
Mon May 5 10:49:48 EDT 2008
> I was wondering if anybody had experimented with using Template
> (TH) and ordinary SQL to make type-safe database access?
I know HaskellDB, for example, does something quite similar. There's a
preprocessor that generates a Haskell file with a Haskell
representation of the types of the database's tables. You could of
course replace this with a TH function. There are two very nice papers
about the design of HaskellDB:
I think there may a bit of problem with the approach you suggest: as
the type returned by the query is computed by the SQL server (if I
understand you correctly), it's very hard to do anything with the
result of the query - the Haskell compiler has no idea what type the
result has, so you can't do anything with it. I think it makes much
more sense to bookkeep type information on the Haskell side.
Hope this helps,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe