Semigroups and profunctors

  • And and Or (Booleans)
  • Not (Booleans)
  • Or (Maybe)
  • And (Maybe)
  • Ternary conditional

Tom Harding wrote a series of blog posts about the JavaScript Fantasy Land specification; in his posts, he demonstrates a number of functional programming concepts using JavaScript and libraries that support functional concepts. One of his posts focuses on semigroups.

We thought it was a good demonstration of why semigroups are useful, but we noticed that the example is good for understanding profunctors(/profunctors) as well, and we ended up writing a simplified Haskell version of his example for a course Julie taught. This article will provide a more literal translation of his original example, explain the Haskell side by side with the JavaScript, explain semigroups, and serve as an introduction to profunctors.

Sign up for access to the full page, plus the complete archive and all the latest content.