Update: Source code is available on github. I’ve put the first release of hsparklines up on Hackage. It’s a sparklines library implemented in Haskell. I know there are a number of web service based solutions that one could use for this, but for those who’ve used web services, you know that there are some things you want to keep local. If you haven’t played with sparklines yet, you should. They’re minigraphs inspired by Edward Tufte to present a large amount of contextual information in a minimum of space.
I was working with using Haskell on the command line recently and it occurred to me that it might be interesting to demo it and walk through some error handling scenarios at the same time. Like Perl, Python and Ruby you can invoke ghc on the command line to run programs on the fly. Yes, Haskell makes for a good scripting language. Let’s say we have a column of numbers that we want to add up.
The current set of database driver libraries in Haskell are written by some very talented people, but even then, the libraries sometimes have some rough edges that make them difficult to use for the average web app developer. In fact the frustration level can be high enough that some have given up trying to work with them. Recently I was working with John Goerzen’s HDBC library (1.1.4). I don’t remember having any problems installing it or the additional library I grabbed from darcs to run with Sqlite3.
After my last post about working with HUnit for doing unit testing in Haskell, dons suggested that I look at QuickCheck as an alternative that enables higher level testing. QuickCheck is an easy to use framework that requires you to write a specification of your code by defining invariant properties. It then generates random, sample data to verify that the properties hold. This higher level view of testing is a good match with Haskell, since the functional nature makes unit testing far less important than with other languages.
If you’re familiar with JUnit and Test::Unit then HUnit is the Haskell equivalent for unit testing. As I started to work with it I found it syntactically different than the others, which was something I expected since Haskell is such a different language than Java or Ruby. But what I hadn’t expected, was that it might be lacking in some way compared to the others. Haskell, being a functional programming language, dispenses with the need for declaring a top level class that inherits from the framework and writing test methods that start with “test” in their name.