NAME
Data::Monad::Base::MonadZero - The base class of monads which have the zero.
SYNOPSIS
package YourMonadClass;
use base qw/Data::Monad::Base::MonadZero/;
sub unit {
my ($class, @v) = @_;
...
}
sub flat_map {
my ($self, $f) = @_;
...
}
sub zero {
my $class = shift;
...
}
DESCRIPTION
Data::Monad::Base::MonadZero has the zero element which will not be changed by any monadic operations.
You must implement zero() according to some of monadplus laws.
METHODS
- $m = YourMonad->zero;
-
Represents the zero value.
- $m2 = $m1->filter(sub { ... });
-
Filters values by predicates. If the predicate returns false, filter will use the zero value.
AUTHOR
hiratara <hiratara {at} cpan.org>
SEE ALSO
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.