
Show HN: Poica – Algebraic data types and type introspection for pure C - Hirrolot
https://github.com/Hirrolot/poica
======
dleslie
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.

~~~
Riverheart
Doesn't this require an external preprocessor? The Boost Preprocessor

~~~
rjeli
No, boost/preprocessor is a library that offers metaprogramming primitives for
the standard C/C++ preprocessor

------
naasking
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:

[https://github.com/naasking/libsum](https://github.com/naasking/libsum)

------
syockit
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.

------
igravious
So in this case the connection to algebraic data types is that they provide
static type checking for unions _as well as_ structs in C along with type
introspection which is novel.

The linked article explaining the whys and wherefores of ADTs
([https://codewords.recurse.com/issues/three/algebra-and-
calcu...](https://codewords.recurse.com/issues/three/algebra-and-calculus-of-
algebraic-data-types)) has hit the front page of HN twice now!

------
Kednicma
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.

------
keeganpoppen
wow that actually looks pretty clean

