Rules / Types, classes & roles / metamodel

Metamodel::CurriedRoleHOW Reference

Support for parameterized roles that have not been instantiated

What it is #

role because we don't have the first parameter at hand. We may also

Examples, run three ways #

Every example below comes from the official documentation, together with the output that documentation asserts. Each was then executed by Rakudo and by Raku++ when this page was built. Where the three agree, one result is shown; where they do not, all three are — because which of them is wrong is exactly the information worth having.

5 no-output

class Metamodel::CurriedRoleHOW
    does Metamodel::Naming
    does Metamodel::TypePretense
    does Metamodel::RolePunning {}

Not executed: the documentation states no expected output for this example.

class C does R[Type] { }

Not executed: the documentation states no expected output for this example.

sub foo(R[T] $x) { ... }
if $x ~~ R[T] { ... }

Not executed: the documentation states no expected output for this example.

role Zipi[::T] {
method zape { "Uses " ~ T.^name };
}
role Zipi[::T, ::Y] {
method zape { "Uses " ~ T.^name ~ " and " ~ Y.^name };
}
for Zipi[Int], Zipi[Int,Str] -> $role {
say $role.HOW;
say $role.new().zape;
}
# OUTPUT:
# Perl6::Metamodel::CurriedRoleHOW.new
# Uses Int
# Perl6::Metamodel::CurriedRoleHOW.new
# Uses Int and Str

Not executed: the documentation states no expected output for this example.

role Zape[::T] {};
say Zape[Int].HOW; #: «Perl6::Metamodel::CurriedRoleHOW.new␤»

Not executed: the documentation states no expected output for this example.