Josh Adams and Corey Haines — Pair-programming and Test-Driving a Game of Life Parser in Elm DailyDrip Follow Sep 29, 2016 · 2 min read

In this pairing session from DailyDrip, Josh Adams and Corey Haines work through building a parser (driven by tests) for RLE-encoded Game of Life files, using elm-combine. A tiny stack machine is introduced for handling repeats as well, though in reality it could likely have been solved without that.

The code we ended up with is available on the knewter/combine-playground repo on GitHub.

NOTE: If you like these and want more of them, the easiest way for me to do fun stuff like this in perpetuity is for you or your company to sign up for DailyDrip. We have tons of 5-minute content on topics like Elixir, Elm, Ember, and more, and we deliver them daily so you can learn continuously. </advertising>

It’s a very lengthy pairing session — 2 hours and 11 minutes. With that in mind, here’s a rough outline of various timings in the video:

00:00:13 — A rapid introduction to elm-combine. I worked with it for an hour or so before we got started, and I just kind of speed through what I’ve learned so far.

00:03:58 — We burn a few minutes figuring out what these files are even called and where they’re located and what the format’s called :) Hint: Run-Length Encoded, and the format’s described here.

00:29:25 — This is where I decided, for better or for worse, that I’d solve the ‘repeat’ instruction by making a single-instruction stack machine, though we don’t actually get to that for another 20 minutes or so.

01:19:23 — We could parse lines but here we started figuring out how to turn the list of lines into a list of another type that we could use for the rest of the program, and it took us quite a while. What’s worse, Bogdan has confirmed that we did this kind of dumb (we had an inkling). But we got it working!

01:52:24 — We integrate it into my existing game of life engine and try a couple of patterns on for size.

NOTE: I love doing these. It’s also kind of my job (best job ever) as a co-founder of DailyDrip. If you enjoy this maybe consider signing up for DailyDrip, as that’s what helps me have the time and obligation to put this stuff out there. If you don’t enjoy it, I’m sorry you have bad taste! :) :) :)

Do you have ideas for another pairing session I should do? Interested in setting one up with me? That’s what the comments are for!