Friday, February 1, 2008

Haskell HSQL/SQLite with ghc 6.8 setup is ...a little...messed up?

I am doing my research on the intertubes and it looks like database access with ghc/haskell is not that high on the list of priorities. I am sure, somewhere in the that haskell source is working code. It is just a matter of getting it to work with the most recent stuff; like Cabal 1.2+, GHC6.8+, and gasp Sqlite. I didn't even think about messing with postgres/sqlite.

This the difference between opensource and commercial software. Not that there are sometimes issues with the code. It is an issue of doing the right thing and/or making people happy. Most opensource projects do it the right way? Huh? Ideally, you don't want to mix the base haskell system with the database drivers. GHC has done just that. E.g. Java may include a whole mess of garbage that you don't normally need. In theory, it doesn't make sense.

But, if you are a lazy developer, sometimes being able to just run your database code is a lot easier even though, theoretically, the base compiler should be separate from
external libraries.

It would nice if I could just write my SQL code and go about my day, but I can understand the decoupling of components. Only drawback is that the things that normally would be be important in modern development like database access. Shrug.

I will keep you up to date.

Some of my research.

"> something seemed to have changed in cabal
> (compiling hsql-1.7 with ghc version
> HSQL/MySQL$ runhaskell Setup.lhs configure -p -O
> Setup.lhs:8:33:
> Module
> `Distribution.Simple.Utils'
> does not export
> `rawSystemVerbose'
> (same: )
> is there a workaround?

The api that the Setup.lhs is using has changed, it's not just rawSystemVerbose.
The return types are now IO () not IO ExitCode and verbosity is now a proper
Verbosity type, not an Int. The Setup.lhs can be considerably simplified by
using configurations and other new features.

So basically it needs updating for the newer cabal. It may also need to be
updated for the fact that many modules from the base package have been split off.

I've attached an example updated Setup.lhs and hsql-mysql.cabal files.

Don was suggesting we start a wiki page with advice to package maintainers on
what updates are common for the transition to ghc-6.8 and cabal-1.2. This is a
certainly a good idea. By trying a range of packages it should also tell us if
there are any minor cabal changes that we could do to make the transition
smoother (eg adding back rawSystemVerbose with a deprecation warning)."


andrew said...

i have used your blog to get hsql to compile, but now i have the rawsystemverbose problem with hsql-mysql. could you put the promised example files on the web?
thank you for a great help!

Berlin Brown said...

I couldn't find the exact cabal and source files that I mentioned. But, here is similar code.

Also, I haven't worked with haskell in several months. I hope if you are using the most recent version that this stuff still works.

Berlin Brown said...

Nevermind, that was the answer you were looking for. I think this is my hsql cabal fix:

name: hsql
version: 1.7
license: BSD3
author: Krasimir Angelov []
category: Database
description: Simple library for database access from Haskell.
build-depends: base, old-time
extensions: ForeignFunctionInterface, TypeSynonymInstances, CPP, Rank2Types, DeriveDataTypeable

Berlin Brown said...

andrew said...

thank you for the quick reaction. i used this cabal fix already (thank you!), but got stuck with the hsql-mysql cabal.
you mentioned that you had a fix.. which would be helpful (also, the versions of hsql-mysql you were using at the time).
thank you a lot!

andrew said...

i have since switched to use HDBC, which installed (nearly) without a glitch. it looks more complicated, but at the end it boiled down to very few changes in my code (less time spent to change code than previously spent on problems of installing HSQL; a pitty there is no maintenance)
thank you for your help!