While in the hospital, in the state of delirium, I suddenly realized that the ability to add numbers in parallel depends on the fact that addition is associative. (So, putting it simply, STL is the result of a bacterial infection.) In other words, I realized that a parallel reduction algorithm is associated with a semigroup structure type. That is the fundamental point: algorithms are defined on algebraic structures. It took me another couple of years to realize that you have to extend the notion of structure by adding complexity requirements to regular axioms. And than it took 15 years to make it work. (I am still not sure that I have been successful in getting the point across to anybody outside the small circle of my friends.) I believe that iterator theories are as central to Computer Science as theories of rings or Banach spaces are central to Mathematics. Every time I would look at an algorithm I would try to find a structure on which it is defined. So what I wanted to do was to describe algorithms generically. That’s what I like to do. I can spend a month working on a well known algorithm trying to find its generic representation. So far, I have been singularly unsuccessful in explaining to people that this is an important activity. But, somehow, the result of the activity - STL - became quite successful.
— Alexander Stepanov, in an interview on the origin and design of the C++ STL. This is a deeply profound way to approach programming and algorithm design, and is also at the heart of what the Haskell community has been doing for some time now. Seriously, if you’ve wondered why the Haskell library is riddled with Arrow, Category, Monoid, etc., it is to support exactly this mode of thought. A function declares exactly the type of data it requires, in terms of its necessary operations, and operates on any data matching that requirement. Incidently, this article combined with a lab discussion earlier in the week sparked the revelation that a lot of C++ template design patterns are an impenetrable implementation of type classes.