Bitblob (hash wrapper) & Minivariant (tagged union) dub packages

Paul Backus snarwin at gmail.com
Tue Jan 22 18:09:16 UTC 2019


On Tuesday, 22 January 2019 at 10:26:33 UTC, Mathias Lang wrote:
> ## Minivariant
>
> https://github.com/Geod24/minivariant
>
> Minivariant is a "works for me" replacement of `std.variant : 
> Algebraic`.
>
> [...]
>
> I looked into fixing it, but given Variant's design (which 
> relies heavily on `TypeInfo`) it would have been a wild goose 
> chase. And I know I'm not the only one that needed his own 
> tagged union (see e.g. 
> https://github.com/s-ludwig/taggedalgebraic). It also has a 
> `visit` method similar to std.variant, although not with 
> delegates, as there is currently no way to merge delegates into 
> an overload set, so you have to use an existing overload set 
> (see the examples).

I've also been through this exact process. The resulting package 
is on dub as `sumtype` [1]. In addition to solving the problem 
you noticed with `immutable`, it also works with @safe, @nogc, 
pure, and nothrow, and supports both delegates and overload sets 
with its `match` method (the equivalent of `visit`).

[1] http://sumtype.dub.pm/


More information about the Digitalmars-d-announce mailing list