osfameron > Sub-Curried-0.02 > Sub::Curried

Download:
Sub-Curried-0.02.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 0.02   Source   Latest Release: Sub-Curried-0.11

NAME ^

Sub::Curried - Currying of subroutines via a new 'curry' declarator

SYNOPSIS ^

 curry add_n_to ($n, $val) {
    return $n+$val;
 };

 my $add_10_to = add_n_to( 10 );

 say $add_n_to->(4);  # 14

 # but you can also
 say add_n_to(10,4);  # also 14

 # or more traditionally
 say add_n_to(10)->(4);

DESCRIPTION ^

Currying and Partial Application come from the heady world of functional programming, but are actually useful techniques. Partial Application is used to progressively specialise a subroutine, by pre-binding some of the arguments.

Partial application is the generic term, that also encompasses the concept of plugging in "holes" in arguments at arbitrary positions. Currying is (I think) more specifically the application of arguments progressively from left to right until you have enough of them.

BUGS ^

Note that Devel::Declare currently requires a trailing semicolon ";" after the curry declaration.

SEE ALSO ^

Devel::Debug provides the magic (yes, there's a teeny bit of code generation involved, but it's not a global filter, rather a localised parsing hack).

There are several modules on CPAN that already do currying or partial evaluation:

AUTHOR and LICENSE ^

 (c)2008 osfameron@cpan.org

This module is distributed under the same terms and conditions as Perl itself.

Please submit bugs to RT or shout at me on IRC (osfameron on #london.pm on irc.perl.org)