Get the latest tech news

Show HN: Sum (algebraic) types for C in one 100 line header


A mirror of https://git.sr.ht/~grego/sumtypes.h. Contribute to grego/sumtype.h development by creating an account on GitHub.

Safe, intuitive sum types with exhaustive pattern matching in a single 100 line header, pure C99. If the value being matched is of this variant, the let macro generates a binding to a pointer to a value of this type with the provided name, which you may use in the following statement. It is a 100 line single header that you can just copy into your project and even quickly understand and modify to your liking.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of types

types

Photo of Sum

Sum

Photo of line header

line header

Related news:

News photo

Swift for C++ Practitioners, Part 1: Intro and Value Types

News photo

Kiosks: Types, Uses, and Profitability

News photo

New report identifies types of cyberattacks that manipulate behavior of AI systems