« Return to Thread: Using Template Haskell to make type-safe database access

Using Template Haskell to make type-safe database access

by Mads Lindstrøm :: Rate this Message:

Reply to Author | View in Thread

Hi,

I was wondering if anybody had experimented with using Template Haskell
(TH) and ordinary SQL to make type-safe database access?

To clarify what I am thinking about I will sketch how it could be done.

The TH function should take two inputs. SQL (as a string) and a database
source name (DSN). It should return an IO action as output.

The TH-function should:

1. Connect to the database using the DSN
2. Ask the database which types will be returned from the expression
3. Build an IO action which can be used to execute the SQL at run-time.
The action could return the result as a (lazy) list. Due to step two we
can make the returned values type-safe.



Greetings,

Mads Lindstrøm


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@...
http://www.haskell.org/mailman/listinfo/haskell-cafe

 « Return to Thread: Using Template Haskell to make type-safe database access