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.
Emacs continues to amaze me every single day. It’s getting near tax time and today I was summarizing various expenses in an ascii file. Why ascii and not Excel or some other spreadsheet? Well, for one they are overkill when all you want is a simple column of numbers and a sum. Secondly, my summary as an ascii file will be viewable ten years from now without me having to get the latest version of MS Office or whatever and worrying about data migration.