Archive for May 2009

How to write IEEE doubles to a binary file in Haskell

Haskell is a great language, but it’s got a steep learning curve. Most of the Haskell examples and tutorials present trivial programs and, as when learning any new language, the best way to get your feet wet is to try to solve an everyday problem. Unfortunately, if your everyday language is imperative (which it probably is) then Haskell is going to leave you without many of the basic things you take for granted when you get things done.

In my case, I needed to run a computation involving numerical integration using IEEE double precision floating point values, and output the resulting table of values to a file for visualization. Implementing this computation in Haskell was great fun. However, when it came time to store the output I discovered that Haskell’s IO libraries are very much text-oriented. Binary IO functionality was not to be found… [Read More]