Haskell

How to install HDBC-sqlite3 on windows.

You have a problem it seems. You want to install the Haskell HDBC-sqlite3 library on Windows but you seem to be getting these error messages telling you that it cannot find the required sqlite3 library. The way that you solve this kind of problem is by simply getting your hands on the sqlite3.dll and sqlite3.h files, from here, and putting them in locations that you can then add to the cabal install command later. The ultimate install command should look really simple, something like this:

cabal install HDBC-sqlite3 
--extra-lib-dirs='C:somepathtosqlitelib' 
--extra-include-dirs='C:somepathtosqliteinclude'

Where you obviously need to set what actual paths get given to those variables.

The only other gotcha that you will need to look out for it to make sure that the sqlite3.dll is always in the path of any program that you make that depends on HDBC-sqlite3 because otherwise it will complain about not being able to find the required dll. Just so that you know, the current directory of any program is always in the current library path.

Advertisements
Haskell

Good Haskell Coding Style

So I have written enough Haskell code that style has become to be a very important topic for me. It can make the difference between actually being able to understand the code that other people have written and not understanding it at all. Therefore I have trawled the web and have found a great list of links that all discuss good Haskell coding style. I recommend that you read through them and they make for really light reading too. (BTW I have ordered them in the order that I intended them to be read)

There are also some great tools out there that may help you write better Haskell code:

My Personal Pet Peeves

For the most part the style guides that I have added above (and the tools provided) mirror my own style guide (or perhaps my guide mirrors them). However, there is one item of style that particularly annoys me on a regular basis. It is the incorrect use of the (>>=) and (=<<) operators. Take a look at these examples of monadic code:

someValue <- statement1 >>= statement2

This seems wrong to me in terms of program flow. Essentially you start in the middle with statement1, move right to statement2, and then the end result is stored, on the far left, in someValue. The flow is all over the place. However if we rewrite that properly we get this:

someValue <- statement2 =<< statement1

In this code we start on the far right and just keep on moving left step by step until the end result is stored in someValue.

That is all I have for this post but I might add more peeves to it as time goes by. If you have any personal Haskell pet peeves please feel free to leave them in the comments or if you simply want to show your support for a certain type of Haskell style then please feel free to leave that in the comments too.