So I’ve done about two weeks of real work in Haskell. Here are some observations.
- I got used to typed programming pretty fast. For the first week the compiler beat me about the ears every time I reloaded. Now I cringe in anticipation and am slightly surprised when my code type checks with no problems. I made a few small adjustments to my working habits, but nothing major.
- The REPL is more primitive than the Lisp and Python REPLs I’ve used. You have to load a whole file at a time, and the whole state of your program resets. This is a “best practise” for REPLs according to the PLT, but one that is mildly inconvenient. Ad-hoc reloading only bit me about once a month, and the consequences were never that bad.
- Convenient currying and composition are the number-one contributor to brevity. This is probably because I haven’t fully shifted from my Scheme/Python mindset. But Scheme and Python programs do look a little muddier than they used to because of all their nested function calls. I haven’t quite developed the (apparent) Haskellish aversion to parentheses or they might look a *lot* muddier.
- Speaking of ($) (used to avoid parentheses), I still don’t know if I like all the funky operators in Haskell. It’s no C++, where a + could mean anything*. But there is a lot of @@#$*@!! going on. I’ve defined a couple of operators on my own and I still don’t know if it was a good idea. My excuse is that the paper whose code I was implementing overloaded (-) in its math notation, but of course you can’t do that in Haskell. So I decided to call it (\\\) because it removes certain information from a list, like the built-in (\\). It’s a cool paper [PDF], though, even with its overloaded (-).
- I still haven’t figured out debugging. My solution so far has been to promote the expression where I *think* the bug is to a standalone function and feed it input that I think it should be getting. I need to learn how to trace functions or something. But…all those people who claim that their program is usually bug-free when they finally get it past the Haskell compiler? I’m not saying they’re lying, just that they’re former C programmers**.
- The compiler error messages would be 10 times easier on newbies if the compiler could reliably identify cases where a function is given the wrong number of arguments. Because of currying, I guess, it is never quite certain and so the message is on the third line with the disclaimer “Probable Cause: wrong number of arguments".
- OR
Haskell needs to grow a magical refactorer like the Popular Languages have. One that works with Emacs, and one that detects when I add an argument to a function. There is one called Hare at version 0.4, but it has a big disclaimer in the README that scared me off after my lukewarm (at best) experience with Bicycle Repair Man for Emacs.
- Text processing works pretty well. I’m not quite as facile as I am with Python yet since I haven’t learned all the text manipulation functions. Manipulation of data at the REPL isn’t quite as nice because there are no dictionary literals, so getting other code to spit out strings containing readable dictionaries is just a tad more complicated.
*Or worse: Everything. Whoa.
**OK, they’re lying. Well, actually, allow me to waffle a bit. Programs that get past the compiler are bug-freer. But not bug-free.