spasm.sumtype

A sum type for modern D.

SumType is an alternative to std.variant.Algebraic that features:

  • Improved pattern-matching.
  • Full attribute correctness (pure, @safe, @nogc, and nothrow are inferred whenever possible).
  • A type-safe and memory-safe API compatible with DIP 1000 (scope).
  • No dependency on runtime type information (TypeInfo).

Public Imports

std.variant
public import std.variant : This;

This placeholder, for use in self-referential types.

Members

Enums

isSumType
eponymoustemplate isSumType(T)

True if T is an instance of SumType, otherwise false.

Functions

main
int main()
Undocumented in source. Be warned that the author may not have intended to support it.

Structs

SumType
struct SumType(TypeArgs...)
Undocumented in source.

Templates

FlattenSumTypes
template FlattenSumTypes(Types...)

A tagged union that can hold a single value from any of a specified set of types.

match
template match(handlers...)

Calls a type-appropriate function with the value held in a SumType.

Variables

canMatch
enum bool canMatch(alias handler, T);

True if handler is a potential match for T, otherwise false.

Meta

License

MIT

Authors

Paul Backus, Atila Neves