On Wednesday, 8 August 2018 at 20:54:13 UTC, Paul Backus wrote:
SumType is a generic sum type for modern D. It is meant as an alternative to `std.variant.Algebraic`.

Features:
- Pattern matching, including support for structural matching (*)
  - Self-referential types, using `This`
  - Works with `pure`, `@safe`, `@nogc`, and `immutable` (*)
  - Zero runtime overhead compared to hand-written C
    - No heap allocation
    - Does not rely on runtime type information (`TypeInfo`) (*)

Starred features (*) are those that are missing from `Algebraic`.

Code examples are available in the documentation (linked below).

New since the last announced version, 0.3.0:
- Types with destructors and postblits are now handled correctly. - Unreachable handlers in `match` calls are now a compile-time error. - `match` handlers can now operate on the stored value by reference. - A new method, `tryMatch`, allows for non-exhaustive pattern matching.
  - Various small improvements to the documentation.

Documentation: https://pbackus.github.io/sumtype/sumtype.html
DUB: https://code.dlang.org/packages/sumtype
Github: https://github.com/pbackus/sumtype

That's a pretty cool library!
I added it to run.dlang.io, s.t. it's easy for people to play with it and share examples, e.g.

https://run.dlang.io/is/5znJXH

(It uses the version from DUB and updates itself once daily, but somehow dub still lists 0.4.1 at the moment)

Reply via email to