Bubblegum
view release on metacpan or search on metacpan
lib/Bubblegum/Object/Code.pm view on Meta::CPAN
# ABSTRACT: Common Methods for Operating on Code References
package Bubblegum::Object::Code;
use 5.10.0;
use namespace::autoclean;
use Bubblegum::Class 'with';
use Bubblegum::Constraints -isas, -types;
with 'Bubblegum::Object::Role::Defined';
with 'Bubblegum::Object::Role::Ref';
with 'Bubblegum::Object::Role::Coercive';
with 'Bubblegum::Object::Role::Output';
our @ISA = (); # non-object
our $VERSION = '0.45'; # VERSION
sub call {
my $self = CORE::shift;
my @args = @_;
return $self->(@args);
}
sub curry {
my $self = CORE::shift;
my @args = @_;
return sub { $self->(@args, @_) };
}
sub rcurry {
my $self = CORE::shift;
my @args = @_;
return sub { $self->(@_, @args) };
}
sub compose {
my $self = CORE::shift;
my $next = type_coderef CORE::shift;
my @args = @_;
return (sub { $next->($self->(@_)) })->curry(@args);
}
sub disjoin {
my $self = CORE::shift;
my $next = type_coderef CORE::shift;
return sub { $self->(@_) || $next->(@_) };
}
sub conjoin {
my $self = CORE::shift;
my $next = type_coderef CORE::shift;
return sub { $self->(@_) && $next->(@_) };
}
sub next {
goto &call;
}
sub print {
my $self = CORE::shift;
return CORE::print $self->(@_);
}
sub say {
( run in 0.733 second using v1.01-cache-2.11-cpan-0d23b851a93 )