line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
8
|
|
|
8
|
|
48
|
use strict; use warnings; |
|
8
|
|
|
8
|
|
12
|
|
|
8
|
|
|
|
|
260
|
|
|
8
|
|
|
|
|
38
|
|
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
286
|
|
2
|
|
|
|
|
|
|
package Sub::Composable; |
3
|
8
|
|
|
8
|
|
6911
|
use Sub::Name; |
|
8
|
|
|
|
|
5685
|
|
|
8
|
|
|
|
|
1964
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# use Sub::Compose qw( chain ); # doesn't fucking work, due to scalar/list context shenanigans |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub compose { |
8
|
5
|
|
|
5
|
0
|
129
|
my ($l, $r, $swap) = @_; |
9
|
|
|
|
|
|
|
|
10
|
5
|
100
|
|
|
|
13
|
if ($swap) { ($l, $r) = ($r, $l); } |
|
2
|
|
|
|
|
5
|
|
11
|
|
|
|
|
|
|
my $sub = subname composition => sub { |
12
|
5
|
|
|
5
|
|
63
|
$l->($r->(@_)); |
13
|
5
|
|
|
|
|
44
|
}; |
14
|
5
|
|
|
|
|
23
|
bless $sub, __PACKAGE__; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub backcompose { |
18
|
1
|
|
|
1
|
0
|
15
|
my ($l, $r, $swap) = @_; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
4
|
compose($l, $r, !$swap); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub applyto { |
24
|
2
|
|
|
2
|
0
|
30
|
my ($self, $other, $swap)=@_; |
25
|
|
|
|
|
|
|
|
26
|
2
|
50
|
|
|
|
6
|
if ($swap) { |
27
|
|
|
|
|
|
|
# $other | $self |
28
|
2
|
|
|
|
|
8
|
$self->($other); |
29
|
|
|
|
|
|
|
} else { |
30
|
|
|
|
|
|
|
# $self | $other |
31
|
0
|
|
|
|
|
|
overload::Method($other, '|')->($other, $self, 1); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
8
|
|
|
|
|
70
|
use overload '<<' => \&compose, |
36
|
|
|
|
|
|
|
'>>' => \&backcompose, |
37
|
8
|
|
|
8
|
|
1803
|
'|' => \&applyto; |
|
8
|
|
|
|
|
1181
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |