So I’m writing a Haskell book!

I’ve been sitting on this for a while, so I’m very excited to announce that Don Stewart, John Goerzen and I are collaborating on an upcoming book for O’Reilly, the working title of which is “Real-World Haskell”. Better yet, O’Reilly has agreed to publish the title under a Creative Commons license! You can find more details, and follow our progress, over at the web site we’ve set up.

23 May 2007 · 1 min · Bryan O'Sullivan

GHC 6.6.1 for Fedora

With Jens Petersen’s blessing, I’ve packaged GHC 6.6.1 for Fedora Extras. If you use FC6, it’s available via yum as of a few days ago. It will be a part of Fedora 7 as soon as that comes out, too. The upgrade to 6.6.1 necessitated a bump of the release number of the Fedora Gtk2Hs package, too. There are no changes in the new release; it’s just built against the newer compiler release.

15 May 2007 · 1 min · Bryan O'Sullivan

Norvig’s spell checker and idiomatic Haskell

A few weeks ago, I spent a little time porting Peter Norvig’s Python code from his article How to Write a Spelling Corrector to Haskell. It’s a concise vehicle for a few Haskelly topics that don’t get much airing in front of a general audience: what idiomatic Haskell looks like, and the dreaded space leak. Bear in mind as you read this that I’m porting Norvig’s algorithm, not implementing the approach that would be best suited to Haskell (dynamic programming). And I’m trying to do so idiomatically, so that the resulting code looks like decent Haskell. This isn’t an attempt to “golf” the code for either performance or terseness. Neither am I trying to show that either language is better than the other. Whew, enough with the disclaimers. ...

14 May 2007 · 12 min · Bryan O'Sullivan

FileManip, an expressive Haskell library for manipulating files

I just released version 0.1 of FileManip, a Haskell library I put together to make it easier to futz about with files in the filesystem. There are a few different components to the package. The Find module lets you search the filesystem for files, after the manner of the Unix find program. It provides a nice embedded language for building filters and controlling recursion, so you can write readable expressions like this: ...

2 May 2007 · 2 min · Bryan O'Sullivan

Efficiently computing a factorial using binary splitting

I don’t intend for this blog to become a dumping ground for code snippets, but sometimes the temptation is too strong. Here’s a simple but fast function for computing a factorial, using the binary splitting algorithm from this page. factorial :: Integral a => a -> a factorial n = split n 0 where split a b = let d = a - b in if d < 0 then 0 else case d of 0 -> 1 1 -> a 2 -> a * (a - 1) 3 -> a * (a - 1) * (a - 2) _ -> let m = (a + b) `div` 2 in split a m * split m b

24 April 2007 · 1 min · Bryan O'Sullivan

Must-see Haskell talks at OSCON ’07

Simon Peyton Jones will be giving two Haskell-related talks at OSCON in July! As far as I know, this will be the first time that Haskell gets an airing at a general-interest conference. Simon is a fantastic speaker, so if you were going to OSCON anyway, you absolutely should not miss his talks. One of Simon’s talks is to be a three-hour Haskell tutorial. It’s explicitly not aimed at “pointy-headed academics”, so if you like to get practical things done quickly and safely, this should be just the job. ...

16 April 2007 · 1 min · Bryan O'Sullivan

Haskell.org and Google’s Summer of Code

This year, the Haskell.org community has had nine projects funded by Google, out of 64 student applications. We had mentoring capacity for over 20 projects, so the final number was decided by Google, not by our ability to deal with them. Congratulations to those who were accepted! And to those who were not, take heart; the competition was tight. Most of this year’s successful applications are centered around library and infrastructure improvements, so I’m hopeful that we’ll see quite a lot of generally useful code come out at the end of this summer. ...

12 April 2007 · 2 min · Bryan O'Sullivan

How to dual-boot Windows and Fedora, by hand, for the insane

I recently bought a Thinkpad X60 that came with Windows preinstalled. I never actually use Windows, but it’s convenient to have around for the occasional BIOS update. My Linux distribution of choice has long been Fedora. Unfortunately, unlike other modern Linux distros, Fedora doesn’t provide a simple graphical means to shrink an NTFS partition in its installer. Since the X60 doesn’t have an optical drive, and I don’t have any USB storage like a memory stick or CD-ROM drive, I couldn’t easily boot into something like Knoppix. If I’d had such gear available, I could easily have shrunk the Windows partition using qtparted. So here are my notes on how to get dual-booting working, by hand, in a bare-bones environment. ...

12 April 2007 · 7 min · Bryan O'Sullivan

Who says there’s nothing to numerology?

From diffbavis on #haskell: sum (map ord “al gore”) 666

2 March 2007 · 1 min · Bryan O'Sullivan

A Haskell regular expression tutorial

Someone showed up on #haskell yesterday, asking how to use regular expressions. This isn’t a completely straightforward question to answer. While Haskell’s regexp libraries provide the same functionality you’ll find in Perl, Python, and Java, they provide a rich and fairly abstract interface that can be daunting to newcomers. So let’s fix that, and strip away the abstractions to show how we might actually use regexps in practice. I’m assuming that you’re already familiar with regexps from using them in some other language, and simply want to find your feet in Haskell. The standard library that implements regexps is Text.Regex.Posix. As the name suggests, this wraps the system’s native POSIX extended regexp library. ...

27 February 2007 · 6 min · Bryan O'Sullivan