Tuesday, May 15, 2007

Trying to learn Haskell, database.

I've been trying to learn Haskell for a couple months now, I can say I fell in love with the language, while at the same time feeling like I will never understand all of it.

Anyway I wanted to try accessing a MySQL database.

I didn't know what package to use :
  • HDBC, HaSQL rely on ODBC for MySQL, which I don't like.
  • HaskellDB doesn't let you write your own SQL queries, it relies on a higher level description of the database.
  • MySQL-hs is discontinued
  • And there's HSQL.

My home computer's OS is kubuntu feisty, and fortunately there's a package for HSQL available.

I gather some examples and try this simple file to begin :
module Main where

import Control.Exception
import System.Environment (getArgs)
import Database.HSQL
import Database.HSQL.mysql
I try it with ghci and it gives me the following error :
Loading package base ... linking ... done.

db2.hs:6:7: parse error on input `Database.HSQL.mysql'
Failed, modules loaded: none.
Damn. I assume something is wrong with kubuntu's haskell package, so I uninstall it all, download a binary of the latest ghc ( 6.6.1 ), install it, then download HSQL ( 1.7 ), install it ( easy with cabal ).

I try again loading my little file with ghci and I get the exact same error message.

I hope someone on IRC will be able to help me.


Someone on IRC helped me. I had to use 'import Database.HSQL.MySQL'
I feel dumb now.


kowey said...

Welcome to the Haskell-fr community!

David said...

Merci !