Does anyone here have experience with HDBC? I am very interested in using Haskell in a risk-rating system for cross-collateralized loans and bonds, but I absolutely need solid support for working with Sybase and SQL Server. We've used Clojure in our prototypes, and JDBC is top notch. However, Clojure lets you get away with a lot, while Haskell forces a level of discipline and gives a proper debugger. Also, I could really use Haskell's algebraic data types for performing operations on relational data and applying rules that have lots of exceptions. The system we're replacing is a mess of CASE WHENs and stored procedures operating on views built on views. I'd really like to use Haskell, but absolutely need solid database integration.
HDBC is fairly similar to JDBC. I consider it a fairly direct to the database affair. You can go lower level or higher with other APIs. If you want magic Haskell foo you probably need to look elsewhere, but if you like the database and like SQL it's quite reasonable.
Note that in practice, in OCaml, I found it easier to write my own Oracle bindings than use the "standard" one: http://gaiustech.github.com/ociml/
The mainstream community of both Haskell and OCaml, I get the feeling, doesn't really care too much about RDBMS access, as it's not something academics often need, so you will often find yourself on your own if you have a problem. The only mainstream functional language that does take RDBMSs seriously is F#, which it gets "for free" as C# needs it.
Thank you very much. I've never seen such beautiful database code before. I think it's here where the power of monads really shines; they keep all the statefullness of the database from cluttering up the rest of the code. I will stick with the JVM because of legacy integration. Although I must say, the more I use Haskell, the cleaner my code in other languages gets. Haskell is almost like poetry in this regard.
You might want to see if the code for the postgres-simple library can be ported to use those other databases c libs rather than the libpostgres one.
Reasons: in the context of Postgres, the above lib allows you to do full sql with proper escaping of parameters and also is extensible with respect to defining how to serialize values to and from the db side representation.
Full disclosure: I'm using that lib because it's the only one that lets me exploit postgres' geometry functionality while still using a rich query api thats type safe