Recursion: Functional Programming’s GOTO (and how to get rid of it)

By Greg Pfeil

Elevator Pitch

Recursion schemes are a way to separate the logic of an operation from structure it operates on. They also have fusion laws that allow composing many traversals over a structure into one while still defining them independently. This talk shows how to take advantage of them in Haskell and Scala.

Description

What are the problems with recursion? How can they be resolved while improving both the performance and clarity of your code? In this talk, we’ll learn how to separate recursion from the semantics of our program using generalized recursion schemes. We’ll discover the benefits that come from that approach and identify some pitfalls that may seem helpful at first. We will also see how to adopt this style gradually in existing projects, gaining the benefits incrementally without disrupting code that already works. Most of the content is language agnostic (but typed), with specific examples given in Haskell and Scala.

Notes

I’ve given talks related to this one. https://github.com/sellout/recursion-scheme-talk has outlines/slides for a couple of them. The shortest was 30 minutes, and the longest (planned, withdrawn from LambdaConf 2016) was a 2-hour workshop. I’ve also given versions in either Haskell or Scala. I.e., it’s flexible and I’m open to suggestions from the program committee, if accepted.