line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Monad::Maybe; |
2
|
2
|
|
|
2
|
|
886
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
58
|
|
3
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
18
|
|
|
2
|
|
|
|
|
47
|
|
4
|
2
|
|
|
2
|
|
985
|
use parent qw/Data::Monad::Base::MonadZero/; |
|
2
|
|
|
|
|
567
|
|
|
2
|
|
|
|
|
8
|
|
5
|
2
|
|
|
2
|
|
68
|
use Carp (); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
109
|
|
6
|
2
|
|
|
2
|
|
12
|
use Scalar::Util qw/reftype/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
117
|
|
7
|
2
|
|
|
2
|
|
10
|
use Exporter qw/import/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
430
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw/just nothing/; |
10
|
|
|
|
|
|
|
|
11
|
13
|
|
|
13
|
1
|
391
|
sub just { bless [@_], __PACKAGE__ } |
12
|
7
|
|
|
7
|
1
|
497
|
sub nothing() { bless \(my $d = undef), __PACKAGE__ } |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub unit { |
15
|
2
|
|
|
2
|
1
|
13
|
my $class = shift; |
16
|
2
|
|
|
|
|
5
|
just @_; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub zero { |
20
|
4
|
|
|
4
|
1
|
310
|
my $class = shift; |
21
|
4
|
|
|
|
|
8
|
nothing; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub flat_map { |
25
|
15
|
|
|
15
|
1
|
1382
|
my ($self, $f) = @_; |
26
|
15
|
100
|
|
|
|
23
|
$self->is_nothing ? $self : $f->($self->value); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
37
|
|
|
37
|
1
|
175
|
sub is_nothing { reftype $_[0] ne 'ARRAY' } |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub value { |
32
|
15
|
|
|
15
|
1
|
18
|
my ($self) = @_; |
33
|
15
|
100
|
|
|
|
24
|
if ($self->is_nothing) { |
34
|
1
|
|
|
|
|
280
|
Carp::carp "nothing has no values"; |
35
|
1
|
|
|
|
|
56
|
(); |
36
|
|
|
|
|
|
|
} else { |
37
|
14
|
100
|
|
|
|
68
|
wantarray ? @$self : $self->[0]; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |