I'm trying to create a basic List type using Algebraic, but the compiler keeps complaining about recursive aliasing.

import std.variant;

struct Cons(T, U: List)
{
        public static opCall(T t, U u)
        {
        }
}

//Error
alias List = Algebraic!(typeof(null), Cons!(int, This));

void main()
{
        List l = Cons(1, Cons(2, Cons(3, null)));
}

I tried changing Cons like so:


struct Cons(T, U)
{
    //...
}

Then I get:
Error: struct f809.Cons cannot deduce function from argument types
!()(int, typeof(null)), candidates are: f809.Cons(T, U)

Error: struct std.variant.This unknown size
Error: struct std.variant.This unknown size
Error: variable f809.Cons!(int, This).Cons.opCall.u no definition of struct This

I'm not sure what else I could try. Does anyone have any advice on using this?

Reply via email to