line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Monad::Maybe; |
2
|
2
|
|
|
2
|
|
1278
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
59
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
57
|
|
4
|
2
|
|
|
2
|
|
1376
|
use parent qw/Data::Monad::Base::MonadZero/; |
|
2
|
|
|
|
|
652
|
|
|
2
|
|
|
|
|
13
|
|
5
|
2
|
|
|
2
|
|
77
|
use Carp (); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
43
|
|
6
|
2
|
|
|
2
|
|
10
|
use Scalar::Util qw/reftype/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
91
|
|
7
|
2
|
|
|
2
|
|
9
|
use Exporter qw/import/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
508
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw/just nothing/; |
10
|
|
|
|
|
|
|
|
11
|
13
|
|
|
13
|
1
|
400
|
sub just { bless [@_], __PACKAGE__ } |
12
|
7
|
|
|
7
|
1
|
666
|
sub nothing() { bless \(my $d = undef), __PACKAGE__ } |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub unit { |
15
|
2
|
|
|
2
|
1
|
14
|
my $class = shift; |
16
|
2
|
|
|
|
|
5
|
just @_; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub zero { |
20
|
4
|
|
|
4
|
1
|
278
|
my $class = shift; |
21
|
4
|
|
|
|
|
8
|
nothing; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub flat_map { |
25
|
15
|
|
|
15
|
1
|
1264
|
my ($self, $f) = @_; |
26
|
15
|
100
|
|
|
|
33
|
$self->is_nothing ? $self : $f->($self->value); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
37
|
|
|
37
|
1
|
229
|
sub is_nothing { reftype $_[0] ne 'ARRAY' } |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub value { |
32
|
15
|
|
|
15
|
1
|
22
|
my ($self) = @_; |
33
|
15
|
100
|
|
|
|
45
|
if ($self->is_nothing) { |
34
|
1
|
|
|
|
|
222
|
Carp::carp "nothing has no values"; |
35
|
1
|
|
|
|
|
56
|
(); |
36
|
|
|
|
|
|
|
} else { |
37
|
14
|
100
|
|
|
|
103
|
wantarray ? @$self : $self->[0]; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |