The ^parameterize method allows one to parameterize a class with some given information, such as a role.
my role A[::T = Mu] { }
my class B {
method ^parameterize(Mu \base, Mu \type) {
my \what := base.^mixin(A[type]);
what.^set_name(base.^name ~ '[' ~ type.^name ~ ']');
what
}
}
dd B[Int]; # B[Int]
dd B[Int].^roles; # (A[Int],)
However, I haven't been able to find a way to make the unparameterized version of B do the unparameterized version of role A.
dd B; # B
dd B.^roles; # (), want to see (A[Mu],)
I tried to add a ^compose method, but that only gets called if the class is parameterized.
Suggestions very welcome!