Sam Symons

The Path to Haskell Intermediacy

For a while now, my mornings have been devoted to studying Haskell. It’s been an enormously rewarding experience, and I highly recommend it to anybody working in software today. These are some of the resources which helped me to understand the core concepts of the language.

(I say intermediacy because I’m not an expert in Haskell, so I can’t make any claims about that.)

Escape From the Ivory Tower

Simon Peyton Jones' talk from Yow! 2011 should be enough to convince you to learn Haskell. It goes over the history of Haskell, what it is capable of, and why functional programming is beneficial to the world.

I’d already learned a good amount about Haskell before watching this, but I would imagine that it would have had the same effect had I watched it beforehand.

Learn You a Haskell

Learn You a Haskell was my first real dive into Haskell. And, just as everybody who has read it says, it’s wonderful. It takes you from no experience with functional programming at all to being able to write a non-trivial Haskell program with ease.

Books on advanced programming languages are often depicted as hefty tomes written by guys with even heftier beards. Not so in this case; Learn You a Haskell is a pleasure. Even if you have no interest in Haskell, you owe it to yourself to read it.

Real World Haskell

Being a language shrouded in academia, Haskell has seen its fair share of dismissals as being not practical enough. Real World Haskell takes that claim and thoroughly destroys it.

Reading this after making my way through Learn You a Haskell really helped to cement some of the ideas in my brain.

Aditya Bhargava’s Blog

Aditya Bhargava wrote up some fantastic articles on tricky Haskell concepts, my favorite being Functors, Applicatives, and Monads In Pictures. These are in the same sort of style as Learn You a Haskell (read: not boring) and explain the topics succinctly.

Typeclassopedia

The Typeclassopedia is a tour of the standard type classes in Haskell, from monad to monoid.

It’s been useful to refer back to this article while experimenting with the various type classes. It may take a while to understand it all, but having done so will put you in a much better position.

What I Wish I Knew When Learning Haskell

Stephen Diehl’s coverage of many intermediate/advanced Haskell topics is very popular, and for good reason. A lot of this is above my head, but I’ve still gotten a ton of interesting information out of it.

Thoughtbot Playbook v2

The folks at Thoughtbot just released version 2 of their playbook, a guide to how they run their company, covering everything from hiring through to test driven development. The production checklist is really helpful.

Thoughtbot is one of my most respected companies when it comes to open source work. I’d love to see more groups do something like this.

GitHub Traffic Analytics

GitHub now has built-in traffic analytics. Gone are the days of having to include an ugly workaround just to see how many people are visiting your projects.

Fast Navigation using z

Working in the shell can be incredibly empowering. Thanks to the philosophy of Unix, you can get all sorts of things done with incredible speed… except navigation. For this, z is the answer.

z is a script which keeps track of the directories you have visited and lets you go back to them very quickly. If you’ve ever used autojump or fasd, you’ll know what z is about.

It’s fantastic for those frequently jumping around the filesystem. All you need to know is a part of the directory name you want to jump to. For example, if you have a project found at ~/Projects/Rails/SomeRailsApp, running z somerails will jump to the project, saving you from having to remember the path each time.

Setting Up

Because z is just a shell script, you only need to get the z.sh file and place it where your shell can find it.

  1. Get the file from the project’s repository
  2. Update your shell’s startup file (.bashrc,.zshrc, etc.) to include the location of z.sh in your $PATH. If you put z.sh in a directory like ~/.scripts/, then your $PATH will have to include $HOME/.scripts
  3. Source your shell’s startup file with source ~/.zshrc (or whatever your startup file’s name is)

In Action

Say you have a directory structure like this:

~
├── Projects
|   ├── Rails
|   |   ├── Some Project
|   └── iOS
|   |   ├── Another Project

Changing into the ~/Projects directory then checking z’s history with z -l (or just z with no arguments) should give you something like this:

common:    /Users/samsymons/Projects
4          /Users/samsymons/Projects

Then after visiting the Rails directory:

common:    /Users/samsymons/Projects
8          /Users/samsymons/Projects
8          /Users/samsymons/Projects/Rails

As you can see, z only remembers directories you have visited after its installation. It won’t put you in a directory unless you specifically go there first. Note the ranks listed to the left of the output; the higher the rank, the more likely the directory will be chosen.

cd back into your home directory, then run z rails. z will look at its history, find the first (case insensitive) match for ‘rails’, and take you straight there. If you have visited multiple different directories named ‘rails’, z will use their ranks to decide which one to pick.

How It Works

z’s magic comes from its ordering of directories by “frecency”. The more often a directory is visited, the higher in the list it will appear.

The crucial aspect, however, is that z will favor more recently visited directories — no matter how many times you visited a directory in the past, if you haven’t been there in a while, its rank will start to decay.

Directory rankings are stored in ~/.z. To reset the history, delete that file. z will recreate it when you start visiting new directories.

Try z

My productivity has gone up sharply since installing z. If you do any sort of navigation in a shell, give it a shot.

← Next Page