role Metamodel::CurriedRoleHOW

Support for parameterized roles that have not been instantiated
    class Metamodel::CurriedRoleHOW
        does Metamodel::Naming
        does Metamodel::TypePretense
        does Metamodel::RolePunning {}

Warning: this class is part of the Rakudo implementation, and is not a part of the language specification.

Sometimes, we see references to roles that provide parameters but do not fully resolve them. For example, in:

class C does R[Type] { }

We need to represent R[T], but we cannot yet fully specialize the role because we don't have the first parameter at hand. We may also run into the issue where we have things like:

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

Where we clearly want to talk about a partial parameterization of a role and actually want to do so in a way distinct from a particular instantiation of it. This metaobject represents those "partial types" as both a way to curry on your way to a full specialization, but also as a way to do type-checking or punning.

This class will show up in parameterized roles. For instance:

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

Since there are several variants of Zipi, providing a parameter curries it, but it's still up to the compiler to find out the actual realization taking into account the ParametricRoleGroup, so these (partially instantiated) roles show up as Metamodel::CurriedRoleHOW as shown in the example; even if there's a single parameter an instantiated role will also be of the same type:

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

Note: As most of the Metamodel classes, this class is here mainly for illustration purposes and it's not intended for the final user to instantiate.

See Also

class Metamodel::ClassHOW

Metaobject representing a Raku class.

role Metamodel::ConcreteRoleHOW

Provides an implementation of a concrete instance of a role

class Metamodel::DefiniteHOW

Metaobject for type definiteness

class Metamodel::EnumHOW

Metaobject representing a Raku enum.

class Metamodel::PackageHOW

Metaobject representing a Raku package.

class Metamodel::Primitives

Metaobject that supports low-level type operations

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.