Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Got it right this time
Curried roles are simply roles that have been provided with a
parameter, but before they have been fully instantiated by punning or
being mixed in a class. [Synopse](https://design.perl6.org/S14.html),
for once, was useful.

Refs #1306
  • Loading branch information
JJ committed Apr 13, 2019
1 parent e911e2e commit a96b459
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions doc/Type/Metamodel/CurriedRoleHOW.pod6
Expand Up @@ -29,12 +29,36 @@ 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.
You can use C<new_type> as in most of the Metamodel namespace, to create new
types:
This class will show up in parametrized roles. For instance:
my $a = Metamodel::CurriedRoleHOW.new_type("zipi");
=begin code
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
=end code
I<Note>: As most of the Metamodel classes, this class is here mainly for
illustration purposes and it's not intended for the final user.
Since there are several variants of C<Zipi>, providing a parameter I<curries>
it, but it's still up to the compiler to find out the actual realization taking
into account the C<ParametricRoleGroup>, so these (partially instantiated) roles
show up as C<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␤»
I<Note>: As most of the C<Metamodel> classes, this class is here mainly for
illustration purposes and it's not intended for the final user to instantiate.
=end pod

0 comments on commit a96b459

Please sign in to comment.