Skip to content

Commit a96b459

Browse files
committed
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
1 parent e911e2e commit a96b459

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

doc/Type/Metamodel/CurriedRoleHOW.pod6

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,36 @@ instantiation of it. This meta-object represents those "partial types"
2929
as both a way to curry on your way to a full specialization, but also
3030
as a way to do type-checking or punning.
3131
32-
You can use C<new_type> as in most of the Metamodel namespace, to create new
33-
types:
32+
This class will show up in parametrized roles. For instance:
3433
35-
my $a = Metamodel::CurriedRoleHOW.new_type("zipi");
34+
=begin code
35+
role Zipi[::T] {
36+
method zape { "Uses " ~ T.^name };
37+
}
38+
role Zipi[::T, ::Y] {
39+
method zape { "Uses " ~ T.^name ~ " and " ~ Y.^name };
40+
}
41+
for Zipi[Int], Zipi[Int,Str] -> $role {
42+
say $role.HOW;
43+
say $role.new().zape;
44+
}
45+
# OUTPUT:
46+
# Perl6::Metamodel::CurriedRoleHOW.new
47+
# Uses Int
48+
# Perl6::Metamodel::CurriedRoleHOW.new
49+
# Uses Int and Str
50+
=end code
3651
37-
I<Note>: As most of the Metamodel classes, this class is here mainly for
38-
illustration purposes and it's not intended for the final user.
52+
Since there are several variants of C<Zipi>, providing a parameter I<curries>
53+
it, but it's still up to the compiler to find out the actual realization taking
54+
into account the C<ParametricRoleGroup>, so these (partially instantiated) roles
55+
show up as C<Metamodel::CurriedRoleHOW> as shown in the example; even if there's
56+
a single parameter an instantiated role will also be of the same type:
57+
58+
role Zape[::T] {};
59+
say Zape[Int].HOW; #: «Perl6::Metamodel::CurriedRoleHOW.new␤»
60+
61+
I<Note>: As most of the C<Metamodel> classes, this class is here mainly for
62+
illustration purposes and it's not intended for the final user to instantiate.
3963
4064
=end pod

0 commit comments

Comments
 (0)