line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MouseX::Types::Data::Monad; |
2
|
1
|
|
|
1
|
|
632
|
use 5.008001; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
3
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
12
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
48
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
1; |
11
|
|
|
|
|
|
|
__END__ |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=encoding utf-8 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
MouseX::Types::Data::Monad - Mouse type constraints for Data::Monad |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use Data::Monad::Either qw( right left ); |
22
|
|
|
|
|
|
|
use Data::Monad::Maybe qw( just nothing ); |
23
|
|
|
|
|
|
|
use MouseX::Types::Data::Monad::Either; |
24
|
|
|
|
|
|
|
use MouseX::Types::Data::Monad::Maybe; |
25
|
|
|
|
|
|
|
use Smart::Args qw( args ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub maybe_value_from_api { |
28
|
|
|
|
|
|
|
args my $json => 'MaybeM[HashRef]'; |
29
|
|
|
|
|
|
|
$json->flat_map(sub { |
30
|
|
|
|
|
|
|
# ... |
31
|
|
|
|
|
|
|
}); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
maybe_value_from_api(just +{ ok => 1 }); |
35
|
|
|
|
|
|
|
maybe_value_from_api(nothing); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub value_or_error_from_api { |
38
|
|
|
|
|
|
|
args my $json => 'Either[Left[Str] | Right[Int]]'; |
39
|
|
|
|
|
|
|
$json->flat_map(sub { |
40
|
|
|
|
|
|
|
# ... |
41
|
|
|
|
|
|
|
}); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
value_or_error_from_api(right(1)); |
45
|
|
|
|
|
|
|
value_or_error_from_api(left('some error')); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 DESCRIPTION |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
MouseX::Types::Data::Monad provides L<Mouse> type constraints for Data::Monad family. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SEE ALSO |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
L<MouseX::Types::Data::Monad::Maybe> |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
L<MouseX::Types::Data::Monad::Either> |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 LICENSE |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Copyright (C) aereal. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
62
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 AUTHOR |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
aereal E<lt>aereal@aereal.orgE<gt> |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|