line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MouseX::Types::Data::Monad::Maybe; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
556
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use Mouse::Util::TypeConstraints; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
8
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
subtype 'MaybeM', |
9
|
|
|
|
|
|
|
as 'Data::Monad::Maybe', |
10
|
|
|
|
|
|
|
( |
11
|
|
|
|
|
|
|
constraint_generator => sub { |
12
|
|
|
|
|
|
|
my ($type_parameter) = @_; |
13
|
|
|
|
|
|
|
my $check = $type_parameter->_compiled_type_constraint; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
return sub { |
16
|
|
|
|
|
|
|
my ($maybe) = @_; |
17
|
|
|
|
|
|
|
return $maybe->is_nothing ? 1 : $check->($maybe->value); |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
1; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
__END__ |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=encoding utf-8 |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 NAME |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
MouseX::Types::Data::Monad::Maybe - A type constraint for Data::Monad::Maybe |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 SYNOPSIS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
use Data::Monad::Maybe qw( just nothing ); |
35
|
|
|
|
|
|
|
use MouseX::Types::Data::Monad::Maybe; |
36
|
|
|
|
|
|
|
use Smart::Args qw( args ); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub from_api { |
39
|
|
|
|
|
|
|
args my $json => 'MaybeM[HashRef]'; |
40
|
|
|
|
|
|
|
$json->flat_map(sub { |
41
|
|
|
|
|
|
|
# ... |
42
|
|
|
|
|
|
|
}); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
from_api(just +{ ok => 1 }); |
46
|
|
|
|
|
|
|
from_api(nothing); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 DESCRIPTION |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
MouseX::Types::Data::Monad::Maybe defines a type constraint for Data::Monad::Maybe. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SEE ALSO |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
L<Mouse>, L<Data::Monad::Maybe> |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 LICENSE |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Copyright (C) aereal. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
61
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 AUTHOR |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
aereal E<lt>aereal@aereal.orgE<gt> |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|