This is ... wild. Usually these things explode in size when compiled, require an external preprocessor, and/or heavily lean on system calls. This does none of those things.
Neat. I wrote a similar header only library a long time ago just for sum types, so it's a little more limited but works for C89 or later IIRC:<p><a href="https://github.com/naasking/libsum" rel="nofollow">https://github.com/naasking/libsum</a>
Unfortunately none of the examples contain malloc, whilst I'm curious as to whether the pattern matching works with heap allocated object. The binary tree example only has statically defined tree, which blows up into lots of code in assembly.
So in this case the connection to algebraic data types is that they provide static type checking for unions <i>as well as</i> structs in C along with type introspection which is novel.<p>The linked article explaining the whys and wherefores of ADTs (<a href="https://codewords.recurse.com/issues/three/algebra-and-calculus-of-algebraic-data-types" rel="nofollow">https://codewords.recurse.com/issues/three/algebra-and-calcu...</a>) has hit the front page of HN twice now!
I wonder whether this interacts cleanly with Cello, GTK+, or other "object-oriented" C libraries. It certainly is a nice presentation, if a little baroque.