Saturday, December 24, 2011

Haskell and Linux Parallel Port I/O

I've been working for a day or so on a Haskell program to perform generic I/O on parallel ports under Linux. As I'm still very new to Haskell I needed a real world problem to solve. This problem was one that is very straightforward in C so I took the plunge and started.

You can grab the code at gitorious.

I/O is not Haskell's strong suite from a newbie's perspective. It's not difficult however. All Haskell programs live in the IO monad. This has some good consequences. You then have access to the do notation which looks terribly imperative to me. That's okay as I know how to write this in C and the do notation makes it easy to follow that road until functional solutions appear.

Thoughts on Haskell So Far...
Using the language is a blast! It's syntax is very terse and the expressiveness is immense. You can write haskell programs on a sheet of paper with a marker and have your friends run them in the living room without a computer... Maybe that's just me(bonus he type checking too). Haskell is a HUGE language with a very extensive library. Part of the fun of Haskell is in the learning and you can stay pretty busy just learning the fundamentals. The good news is that as you learn the fundamentals you can quickly begin taking advantage of the libraries to make programs that do very complicated things with just a few type declarations and a handful of generic functions.

Just to show off the flexibility of Haskell, if you use GHC you can compile your programs to native byte code, llvm byte code, run them interactively or use them like shell scripts using the runhaskell tool.

No comments: