tag ~master

Add "tagged value" to D for an effective use of std.variant.Algebraic.


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

tag

Introdubtion

Add "tagged value" to D for an effective use of std.variant.Algebraic.

Example

import tag;
import std.variant : Algebraic, visit;

/// optional type definition
alias Option(T) = Algebraic!(
  Tag!("Some", T),
  Tag!"None"
);

void main() {
  Option!int option;
  
  option = tag!"Some"(1);
  f(option).writeln; // 2
  
  option = tag!"None";
  f(option).writeln; // -1
}

int f(Option!int opt) {
  /// pattern mathing
  return opt.visit!(
    (Tag!("Some", int) a) => a + 1,
    (Tag!"None" a) => -1;
  );
}

Document

Authors:
  • tosuke
Dependencies:
none
Versions:
1.0.0 2017-Jul-31
~master 2017-Jul-31
Show all 2 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 12 downloads total

Score:
0.7
Short URL:
tag.dub.pm