Last time I talked about how algebraic abstractions like “monoid” and “semigroup” didn’t seem to be pulling their weight, despite love from functional programmers. That focused on a practical issue: do these abstractions aid or harm comprehension? Do they make programming easier or harder? (Of course, there’s not a simple answer to this question.)
This time, though, I want to talk about something more exploratory: do we have the right tools to talk about these abstractions? This post is therefore going to be much longer and contain a lot more rambling.
Back in July I got myself into a discussion on Twitter about whether some of the more algebraic concepts in functional programming were net-useful, after reading Brandon Williams’ (great) articles on how they can be applied in Swift. Brandon Kase suggested I watch his talk “Beyond Types in Swift” from this year’s Functional Swift conference.
Given a macro that expands to an arbitrary list of headers, include every header in the list, in order.
#define HEADERS "stdio.h", "stdlib.h", "assert.h"
// stdio.h, stdlib.h, and assert.h are now included and available.
Progress So Far
The C preprocessor is a powerful tool, but not a particularly versatile one. Rather, it does a few specific things, and people have taken advantage of its workings to compose those capabilities to accomplish their tasks. And sometimes, to do something ridiculous and overengineered…like this.