Thread overview
sumtype 0.7.0
Nov 21, 2018
Paul Backus
Nov 21, 2018
jmh530
Nov 22, 2018
H. S. Teoh
Nov 22, 2018
Paul Backus
Nov 22, 2018
Atila Neves
November 21, 2018
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.5.3:
  - SumType is now 100% @safe!
  - `match` now considers all overloads of functions passed as handlers.
  - Several bugs affecting const and immutable SumTypes have been fixed.
  - Comparison of SumTypes with the `==` operator now correctly forwards
    to the contained type's `==` operator.
  - A couple of confusing error messages have been improved.
  - Test builds on Travis CI now use both LDC and DMD.

Many thanks to Atila Neves for his contributions to this release. In particular, the changes to `match` and the `==` operator are the result of his efforts. It's been a pleasure working with him, and I hope to have more opportunities to do so.

Links:
  - Documentation: https://pbackus.github.io/sumtype/sumtype.html
  - DUB: https://sumtype.dub.pm
  - Github: https://github.com/pbackus/sumtype

November 21, 2018
On Wednesday, 21 November 2018 at 00:38:25 UTC, Paul Backus wrote:
> SumType is a generic sum type for modern D. It is meant as an alternative to `std.variant.Algebraic`.
>
> [snip]

Keep up the good work.


November 21, 2018
On Wed, Nov 21, 2018 at 12:38:25AM +0000, Paul Backus via Digitalmars-d-announce 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`.
[...]

Took a quick look at this.  Wow!  Excellent job!  Very nicely-designed API, much better than std.variant.* IMO.

Any way this could be expanded to arbitrary types like Variant? Or is that not possible without reverting to TypeInfo dependency?


T

-- 
Why have vacation when you can work?? -- EC
November 22, 2018
On Thursday, 22 November 2018 at 00:02:18 UTC, H. S. Teoh wrote:
> Any way this could be expanded to arbitrary types like Variant? Or is that not possible without reverting to TypeInfo dependency?
>
>
> T

Not possible, unfortunately--for that and other reasons.
November 22, 2018
On Wednesday, 21 November 2018 at 00:38:25 UTC, Paul Backus wrote:
> SumType is a generic sum type for modern D. It is meant as an alternative to `std.variant.Algebraic`.
>
> [...]

Thanks for the kind words! My pleasure, SumType has been what I've been wanting in D for a while. Expect more annoyances from me in the near future ;)