[Haskell-cafe] Has anyone worked on checking SQL-queries at compile
time?
Marc Weber
marco-oweber at gmx.de
Sun May 25 22:34:48 EDT 2008
Yes, I know about haskelldb.. But some more advanced optimizations can't
be expressed.. so I'd like to ask if someone has done some work in the
other direction not ensuring type safety by using the haskell type
system to derive SQL queries but to use template haskell to derive
functions from given SQL queries thereby checking them for syntax error ?
It be a little bit like SQLJ (Java tool for db connectivity)
Eg $(q "SELECT '2', 4") should result in
[(String, Int)]
and
$(q "INSERT INTO foo (2, ?1, ?2)" ) should result in
Int -> <whatever type ?1 is> -> <whatever type ?2 is> -> IO ()
Ideally this would not only result in a query but in a prepared
statement.
I have no clue how much RDBMS such as Postgresql provide some help
determining type of parameters or results without acutally doing a query
(but bcause Postgresql provides transactions this should not be a
problem)
I see the following benefits:
You can use your existing SQL- Knowledge and don't have to dive into
deep type hackery yet gettitng as much type safety as possible
Marc Weber
More information about the Haskell-Cafe
mailing list