aMAZE yourself with Haskell
So, as you’ve probably figured out by now, I’ve been learning Haskell. My first actual program now behind me, I thought I’d step up and talk a bit about my thoughts on Haskell so far.
- Monads still really boggle me. They are my biggest stumbling block so far, and as far as I’m concerned, they are the biggest wart on the face of Haskell. Yah, sure, I understand the idea—you can use Monads to represent a sequence of actions without violating “functional programming”, but it still feels very, very awkward. I definitely have more reading (and practice) to do on this topic.
- I love how you can define multiple versions of a function and use pattern matching so that the runtime system will choose the correct version based on the value of the parameters. Really slick.
- I’m still trying to get a practical feel for when to use
let
and when to usewhere
. - Using a strongly typed language feels kind of awkward after so long with Ruby, but that’s not a reflection on Haskell. I must admit that Haskell’s type system is pretty neat.
- The whole thing with classes and instances is pretty slick, too, though I’m still trying to wrap my brain around it.
- It feels like you have to pay much closer attention to what you are doing, to avoid cluttering your namespace. Modules help, but once you import them, you’re still stuck with everything in the same namespace. I’ve got to be missing something.
- I really miss objects! Trying to program something that uses random number generation is a real pain in Haskell, because you have to pass the generator around from function to function. Give me stateful objects anyday, over a purely functional language…but I’m sure that’s mostly my inexperience talking.
Anyway, I’m still working my way through it. It is definitely unlike almost any language I’ve ever learned, although I definitely prefer it over Scheme. I still doubt I’ll convert from Ruby to Haskell, but it’s a new way of thinking about problems, and that is always valuable.
For the curious, here is my first Haskell program. it is a naive random maze generator, which is something I can code in my sleep in a procedural language, but which really stretched me when trying to implement it in Haskell. You Haskell experts out there, please feel free to give me advice on how to make this little program better! (But be gentle…)
Reader Comments
3 Nov 2005
3 Nov 2005
4 Nov 2005
4 Nov 2005
4 Nov 2005
5 Nov 2005
5 Nov 2005
5 Nov 2005
7 Nov 2005
7 Nov 2005
8 Nov 2005
9 Nov 2005
9 Nov 2005
8 Sep 2006
As for Ocaml, it’s fast, but not so user friendly IMHO. The toplevel is poor unless you later find it should be used with ledit or emacs. Ocaml doesn’t provide productive syntax sugar or built-in functions as many as Haskell does, such as list comprehension. I don’t understand why. Yet F# (Ocaml dialect for .Net) seems a promising road with cleaner syntax and other sugar, though it’s still in early stage of development.
1 Dec 2006