Data::Monad::Maybe - The Maybe monad.
use Data::Monad::Maybe; sub div { my ($n, $m) = @_; $m == 0 ? nothing : just($n / $m); } # answer: 1.5 print just(3, 2)->flat_map(\&div) ->map(sub { "answer: $_[0]" }) ->value, "\n"; # nothing print "nothing\n" if just(3, 0)->flat_map(\&div) ->map(sub { "answer: $_[0]" }) ->is_nothing;
Data::Monad::Maybe represents optional values.
This module is marked EXPERIMENTAL. API could be changed without any notice.
Is the constructors of this class.
Overrides methods of Data::Monad::Base::Monad.
Overrides methods of Data::Monad::Base::MonadZero.
Checks if $maybe contains any values.
$maybe
Returns a list of values which is contained by $maybe.
hiratara <hiratara {at} cpan.org>
Data::Monad::Base::Monad
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Data::Monad, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Monad
CPAN shell
perl -MCPAN -e shell install Data::Monad
For more information on module installation, please visit the detailed CPAN module installation guide.