sumtype 0.3.0
Per Nordlöw
per.nordlow at gmail.com
Mon May 7 06:24:48 UTC 2018
On Sunday, 6 May 2018 at 19:18:02 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 in this release:
> - The list of types allowed in a sum type is now public
> - Implicit qualifier conversions are now allowed in pattern
> matching
> - Better code examples in the documentation
>
> This library is a work in progress. If you have a use case
> you'd like to see supported, or an API you'd like to see
> implemented, please get in touch!
>
> Documentation: https://pbackus.github.io/sumtype/sumtype.html
> DUB: https://code.dlang.org/packages/sumtype
> Github: https://github.com/pbackus/sumtype
Nice.
I've written something similar in LightAlgebraic at
https://github.com/nordlow/phobos-next/blob/master/src/vary.d#L30
which is also significantly faster than `std.typecons.Algebraic`.
Has the same features as SumType except for
- Self-referential types, using `This` and
- pattern matching
Note that the `memoryPacked` flag being `true` hasn't been
thoroughly tested.
Your're free to copy an ideas or features in `LightAlgebraic`
into `SumType`.
More information about the Digitalmars-d-announce
mailing list