Through the Looking Glass
This week, I hit a milestone in learning Haskell: for the first time, I was able to solve a problem without having to think about how to go about it, but rather by looking up the relevant library functions.
This is a huge step for me: it marks the transition point from “struggling with the language” to being productive. Granted, the problem was trivial (take the contents of standard input and prepend each line with the current timestamp) and ended up being all of four or five lines of code that could have been cut down, even. I’m willing to accept that my code now will not be perfect. That being said, I didn’t stumble through syntax or how to work with the IO monad, and even was able to use
>>= in the same pipeline naturally.
I think this is the third or fourth try to learn the language. I’m still at a basic level (I think I have a decent handle on monads, but still a bit sketchy on functors and applicative by virtue of not having done much with them yet), but I’m increasingly finding it a useful tool for organising, clarifying, and structuring my thoughts. I find that the static typing helps me to frame the problem in a manner that’s remniscient of dimensional analysis, building pipelines to transform data as I write the program. I’m finding the increased rigour in my projects somewhat refreshing.
What’s different about this attempt at learning? The first time, I don’t remember what I was using. The second time was a combination of LYAH and Real World Haskell. I think I stopped somewhere around the monad chapter, but I don’t remember why. Looking at my programming notebook, it looks like I got stuck writing a Lisp in Haskell and started some embedded projects at the same time. This time, I’ve been doing CIS 194 and Write Yourself a Scheme in 48 hours. I’ve been pretty good at doing the exercises, but when I stall on an exercise for more than I day, I move on (and mark the exercise to do later). Also, using Hakyll has helped with practically using the language.