4 May 2020
Well, it's been a rainy week under lockdown. Plenty of time to put time into projects.
[Haskell] Over the last few weeks I've been realising a programming ambition I've had for several years — to get to grips with functional programming on an intuitive level. I've worked with Clojure in a previous job working with mobile keyboards. Before that, I worked with the related paradigm of logic programming for several years using Prolog for various projects in academia and industry, but it's time to dig deeper into functional programming.
Specifically, I'm learning Haskell. I have had a copy of Learn You A Haskell For Great Good for a few years now, but I'm actually just working through the Haskell Wikibook. I'm currently diving a bit deeper into monoids, having completed the Beginner's Track of the book and heading into the Advanced Track. People also seem to recommend School of Haskell, but I haven't looked at it much yet.
I'll come back to Learn You A Haskell this week to try to see the core concepts from another perspective, and when Haskell Programming from First Principles is produced in dead tree form, I'll get that, read through it, and scribble all over it, I expect. And then there's always Structure and Interpretation of Computer Programs to intend to read one day.
There are and have been quite a few community events and meetups. There was always BrisFunctional, which I never ended up going to (though I went to Bristol Clojurians), and I missed this year's Hackathon too. I did used to go to London Haskell meetups when I lived there. I'd enjoy them, getting the gist and appreciating most of the ideas. However, I really always wanted to understand Haskell and functional programming on more than a superficial level. So here I am.
At the moment I use Haskell for Mac (which has its own tutorial) for playing around with code. I installed the Hasklig code font which applies ligatures to make the code look really attractive and readable. FiraCode's readme file demonstrates this well for a bunch of languages. Another example of this sort of font is Monoid. I haven't tried that one out yet.
Depending on my mood, I seem to alternate between (a) writing out code (particularly type class definitions) from web tutorials and breaking down what it means, and (b) just jumping onto the computer and trying out whatever confirms the intuitions I'm trying to build, either in the IDE playground, the GHCi prompt or even an in-browser tutorial environment like TryHaskell. If I have the afternoon free, I'll think of a script I've hacked up in Perl or something, and try to re-implement it in Haskell in three hours or so. The time usually flies.
It's too early to report any substantial coding progress, but for these notes, I'll list some resources which are helping me along the way.
- Hoogle is a search engine for the Haskell libraries, allowing you to search for a function by name or type signature. If you can imagine what a function should do, you can check whether it exists in the standard definitions or common libraries, rather than writing your own version.
- The #haskell IRC channel. Right now I just lurk there as
rawles, writing something very occasionally if I happen to know the answer. It's very active and it's good for asking questions, or just to hang out and take it in and see what other people are asking.
- The puzzle game Cube Composer is inspired by functional programming methods. You have to compose a series of transformations to get some cubes into the right pattern.
- The Haskell Wiki has lots of pages here and there that are really useful, for example Common Misunderstandings and Why Haskell Matters. The latter cites John Hughes' 1990 functional programming manifesto Why Functional Programming Matters. The wiki has its own list of learning resources.
- I keep coming back to Stephen Diehl's What I Wish I Knew When Learning Haskell and clicking the sidebar on whatever topic I'm trying to get my head around.
- Dan sent me a curl-friendly Haskell cheat-sheet.
- I can see from my study so far that understanding the type classes in depth, and running over examples on paper and in the IDE, is an important disclipine in learning to be a Haskeller. Typeclassopedia catalogues the type classes, giving examples and helping to form intuitions. I've also been clicking around Hackage, the community's package respository. Packages like numeric-prelude suggest that Haskell is a good programmatic base from which to explore mathematical, and in particular algebraic, structures. This really interests me, and I'll expand on why in a later update when I get to that point. At least, the idea of computing with mathematical abstractions is very appealing.
- A nice talk to contextualise Haskell's development: Simon Peyton-Jones speaking about Haskell's evolution and origins in an annual lecture of the Churchill CompSci talks.
- There are of course blogs and podcasts. Planet Haskell is an aggregate feed of blogs on the topic. The Monad.Reader was a magazine which ran until 2015 and it's worth looking through its back issues. the Haskell Weekly News seems to be current though. I've been listening to a few episodes of the apparently inactive The Haskell Cast on my walks. Even though some of the topics are again a bit above my skill level right now, there's something illuminating in each episode.