sumtype 0.3.0
Brian Schott
briancschott at gmail.com
Mon May 7 09:23:04 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
I spent several hours trying to get this working with a
non-trivial AST, and I think that it just isn't going to work
until the compiler front-end gets better about handling recursive
definitions. It fails in more-or-less the same way that my
attempts at using std.variant did, and this is not the fault of
your library.
It's too bad, because the visitor pattern is not very good when
you want to support visitors that should not accidentally modify
the tree (i.e. arguments to `visit` are `const`), and other
visitors whose job is to re-write the tree.
More information about the Digitalmars-d-announce
mailing list