Algebra With Types

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 21 09:31:37 PDT 2017


On Fri, Apr 21, 2017 at 04:16:30PM +0000, David Sanders via Digitalmars-d-learn wrote:
> I'm trying to do algebra with types ala http://chris-taylor.github.io/blog/2013/02/10/the-algebra-of-algebraic-data-types/
> 
> Below you will find my attempts at "adding" types in D. I've outlined the
> parts I'm having trouble with using block comments.
> 
> 1) How do I figure out whether a type is an instantiation of
> std.variant.Algebraic?
> 2) If the type is Algebraic, how do I capture its AllowedTypes?
[...]

static if (is(T : Algebraic!(U...), U))
{
	// U now refers to the argument to Algbraic.
}


--T


More information about the Digitalmars-d-learn mailing list