www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - sumtype 0.7.0

reply Paul Backus <snarwin gmail.com> writes:
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
Nov 20 2018
next sibling parent jmh530 <john.michael.hall gmail.com> writes:
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.
Nov 20 2018
prev sibling next sibling parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
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
Nov 21 2018
parent Paul Backus <snarwin gmail.com> writes:
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.
Nov 21 2018
prev sibling parent Atila Neves <atila.neves gmail.com> writes:
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 ;)
Nov 22 2018