Reduce abuse

It all started, as so many things do these days, with a tweet.

And as with so many tweets, this one lacks nuance. So let me clarify.

Recognize reduce abuse

As Scott Sauyet pointed out, reduce is fundamental. He is correct, of course. There are essentially two types of reduce that bother me:

  1. Gigantic monoliths
  2. Re-implementing map, filter, and flatMap chain


The following examples are pulled form actual production codebases I have been acquanted with over the years. The variable names have been changed to obscure the origin.

Could be: xs.filter(x => === id)

That isn’t just more succinct; it is the right tool for the job.

Enum.find(x, fn {key, _} -> key == :heroku_timeout end)

Let’s talk about monoids

Monoid is an algebraic structure that consists of

Buzz de Cafe 24 August 2018