Support for parameterized roles that have not been instantiated
does Metamodel::Namingdoes Metamodel::TypePretensedoes Metamodel::RolePunning
Sometimes, we see references to roles that provide parameters but do not fully resolve them. For example, in:
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] )if ~~ 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:
[::T][::T, ::Y]for Zipi[Int], Zipi[Int,Str] -># 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:
[::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.