Hirrolot@hirrolotFinally implemented sum types in pure C99, after a year of experimentation: datatype( BinaryTree, (Leaf, int), (Node, struct BinaryTree *, int, struct BinaryTree *) );11:28 AM · Feb 6, 2021·Twitter Web App2 Likes
Hirrolot@hirrolot·Feb 6, 2021Replying to @hirrolotint sum(const BinaryTree *tree) { match(*tree) { of(Leaf, x) { return *x; } of(Node, lhs, x, rhs) { return sum(*lhs) + *x + sum(*rhs); } } }11
Artem Sarmini@Artem_Sarmini·Feb 6, 2021Replying to @hirrolotTake a look at http://carbon.now.sh for nicely colored and formatted code snippets