TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Poica – Algebraic data types and type introspection for pure C

116 pointsby Hirrolotalmost 5 years ago

6 comments

dlesliealmost 5 years ago
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.
评论 #23573280 未加载
naaskingalmost 5 years ago
Neat. I wrote a similar header only library a long time ago just for sum types, so it&#x27;s a little more limited but works for C89 or later IIRC:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;naasking&#x2F;libsum" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;naasking&#x2F;libsum</a>
syockitalmost 5 years ago
Unfortunately none of the examples contain malloc, whilst I&#x27;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.
igraviousalmost 5 years ago
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:&#x2F;&#x2F;codewords.recurse.com&#x2F;issues&#x2F;three&#x2F;algebra-and-calculus-of-algebraic-data-types" rel="nofollow">https:&#x2F;&#x2F;codewords.recurse.com&#x2F;issues&#x2F;three&#x2F;algebra-and-calcu...</a>) has hit the front page of HN twice now!
Kednicmaalmost 5 years ago
I wonder whether this interacts cleanly with Cello, GTK+, or other &quot;object-oriented&quot; C libraries. It certainly is a nice presentation, if a little baroque.
keeganpoppenalmost 5 years ago
wow that actually looks pretty clean