Skip to content

Commit 8ef3a57

Browse files
committed
Revision and reflow, refs #2594
1 parent 7a63873 commit 8ef3a57

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed

doc/Type/HyperWhatever.pod6

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,33 @@ C<HyperWhatever> is very similar in functionality to L<Whatever|/type/Whatever>.
1010
difference lies in C<HyperWhatever> standing in for I<multiple> values, rather
1111
than a single one.
1212
13-
=head1 STANDALONE TERM
13+
=head1 Standalone term
1414
15-
Just like with L<Whatever|/type/Whatever>, if a L<HyperWhatever|/type/HyperWhatever> is used as a term on its own,
16-
no currying is done and the L<HyperWhatever|/type/HyperWhatever> object will be used as-is:
15+
Just like with L<Whatever|/type/Whatever>, if a
16+
L<HyperWhatever|/type/HyperWhatever> is used as a term on its own, no currying
17+
is done and the L<HyperWhatever|/type/HyperWhatever> object will be used as-is:
1718
1819
sub foo ($arg) { say $arg.^name }
1920
foo **; # OUTPUT: «HyperWhatever␤»
2021
21-
You can choose to interpret such a value as standing for multiple values in
22-
your own routines. In core, a L<HyperWhatever|/type/HyperWhatever> can be used with this meaning
23-
when smartmatching with L<Lists|/type/List>:
22+
You can choose to interpret such a value as standing for multiple values in your
23+
own routines. In core, a L<HyperWhatever|/type/HyperWhatever> can be used with
24+
this meaning when smartmatching with L<Lists|/type/List>:
2425
2526
say (1, 8) ~~ (1, **, 8); # OUTPUT: «True␤»
2627
say (1, 2, 4, 5, 6, 7, 8) ~~ (1, **, 8); # OUTPUT: «True␤»
2728
say (1, 2, 8, 9) ~~ (1, **, 8); # OUTPUT: «False␤»
2829
29-
Wherever a L<HyperWhatever|/type/HyperWhatever> appears in the list on the right-hand side means
30-
any number of elements can fill that space in the list being smartmatched.
30+
Wherever a L<HyperWhatever|/type/HyperWhatever> appears in the list on the
31+
right-hand side means any number of elements can fill that space in the list
32+
being smartmatched.
3133
32-
=head1 CURRYING
34+
=head1 Currying
3335
34-
When it comes to currying, the L<HyperWhatever|/type/HyperWhatever> follows the same
35-
rules as L<Whatever|/type/Whatever>. The only difference is L<HyperWhatever|/type/HyperWhatever> produces a
36-
L<Callable|/type/Callable> with a L«C<*@> slurpy|/syntax/*@» as a signature:
36+
When it comes to currying, the L<HyperWhatever|/type/HyperWhatever> follows the
37+
same rules as L<Whatever|/type/Whatever>. The only difference is
38+
L<HyperWhatever|/type/HyperWhatever> produces a L<Callable|/type/Callable> with
39+
a L«C<*@> slurpy|/syntax/*@» as a signature:
3740
3841
say (**²)(1, 2, 3, 4, 5); # OUTPUT: «(1 4 9 16 25)␤»
3942
@@ -44,8 +47,9 @@ that simply maps each element in the arguments over:
4447
my &hyper-whatever = sub (*@args) { map *², @args }
4548
say hyper-whatever(1, 2, 3, 4, 5); # OUTPUT: «(1 4 9 16 25)␤»
4649
47-
When currying, mixing L<HyperWhatever|/type/HyperWhatever> with L<Whatever|/type/Whatever> is not permitted.
50+
When currying, mixing L<HyperWhatever|/type/HyperWhatever> with
51+
L<Whatever|/type/Whatever> is not permitted.
4852
4953
=end pod
5054

51-
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6
55+
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

doc/Type/WhateverCode.pod6

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
77
class WhateverCode is Code { }
88
9-
C<WhateverCode> objects are the result of L<Whatever|/type/Whatever>-currying. See the
10-
L<Whatever|/type/Whatever> documentation for details.
9+
C<WhateverCode> objects are the result of L<Whatever|/type/Whatever>-currying.
10+
See the L<Whatever|/type/Whatever> documentation for details.
1111
1212
When you wish to control how a method or function interprets any
1313
I<Whatever stars>, you may use multi dispatch with C<Whatever> and
@@ -38,9 +38,10 @@ C<WhateverCode> parameters to do so, as in the following example:
3838
say get-val($c, *); # OUTPUT: «2␤»
3939
say get-val($c, *-1); # OUTPUT: «1␤»
4040
41-
The C<WhateverCode> C<does> L<Callable|/type/Callable> role, so it's possible to introspect
42-
the type of C<Callable> it contains. Continuing the previous
43-
example, we can add a multi that handles a C<WhateverCode> with two arguments:
41+
The C<WhateverCode> C<does> the L<Callable|/type/Callable> role, so it should be
42+
possible to introspect the type of C<Callable> it contains; for instance,
43+
continuing the previous example, we can add a multi that handles a
44+
C<WhateverCode> with two arguments via checking the signature:
4445
4546
=begin code :skip-test<compile time error>
4647
# Define what to do with two * in an expression
@@ -61,8 +62,8 @@ say get-val($c, @a[*-1]) # 2, because the star belongs to the Array class
6162
This can make the ownership of I<Whatever stars> become confusing rather
6263
quickly, so be careful not to overdo it.
6364
64-
You may instead type-constrain using L<Callable|/type/Callable> type in order to accept
65-
any C<Callable>, including C<WhateverCode>:
65+
You may instead type-constrain using L<Callable|/type/Callable> type in order to
66+
accept any C<Callable>, including C<WhateverCode>:
6667
6768
sub run-with-rand (Callable $code) { $code(rand) };
6869
run-with-rand *.say; # OUTPUT: «0.773672071688484␤»
@@ -76,4 +77,4 @@ to type:
7677
7778
=end pod
7879

79-
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6
80+
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)