Data::Monad::Base::Monad - The base class of any monads.
package YourMonadClass; use base qw/Data::Monad::Base::Monad/; sub unit { my ($class, @v) = @_; ... } sub flat_map { my ($self, $f) = @_; ... }
Data::Monad::Base::Monad provides some useful functions for any monads.
You must implement unit() and flat_map() according to monad laws. Or you may implement flatten() and map() instead of flat_map().
This module is marked EXPERIMENTAL. API could be changed without any notice. I'll drop many useless stuffs in the future.
A natural transformation, which is known as "return" in Haskell.
You must implement this method in sub classes.
Changes the type of function from (v1, v2, ...) -> m(v0) to (m(v1), m(v2), ...) -> m(v0), and apply it to $m1, $m2, ...
Changes the type of function from (v1, v2, ...) -> v0 to (m(v1), m(v2), ...) -> m(v0), and apply it to $m1, $m2, ...
Packs monads into the new monad.
The composition of Kleisli category, which known as ">>=" in Haskell.
The morphism map of the monad, which is known as "fmap" in Haskell.
A natural transformation, which is known as "join" in Haskell.
Executes the function which wrapped by the monad.
flat_map(\&f) while \&predicate is true.
flat_map(\&f)
\&predicate
hiratara <hiratara {at} cpan.org>
Data::Monad::Base::MonadZero, Data::Monad::Base::Sugar
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.