role Metamodel::CurriedRoleHOW

Table of Contents

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

classCdoesR[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:

subfoo(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 meta-object 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:

roleZipi[::T] {

methodzape{"Uses "~T.^name};

}

roleZipi[::T, ::Y] {

methodzape{"Uses "~T.^name~" and "~Y.^name};

}

forZipi[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:

roleZape[::T] {};

sayZape[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.