NAME
Pluto - Functional Programming
ABSTRACT
Functional Scripting for Perl 5
SYNOPSIS
package Cosmos;
use Pluto;
call(string('hello world'), 'titlecase');
# Hello World
DESCRIPTION
This package enables functional programming for Perl 5 via indirect routine dispatching and dependency injection, operating in a way that plays nicely with third-party libraries without having to switch over to object-oriented programming.
WHY
Perl is a multi-paradigm programming language that supports functional programming, but, Perl has an intentionally limited standard library with an emphasis on providing library support via the CPAN which is overwhelmingly object-oriented. This makes developing in a functional style difficult as you'll eventually need to rely on a CPAN library that requires you to switch over to object-oriented programming.
LIBRARIES
This package uses type constraints from:
SCENARIOS
This package supports the following scenarios:
array
# given: synopsis
# e.g.
#
# 0> use Pluto
#
# 1> array [1..4]
#
# $res[0] = bless( [
# 1,
# 2,
# 3,
# 4
# ], 'Data::Object::Array' )
#
# 2> exit
array;
This package supports making the array
function available in the calling package if it doesn't exist already. This function creates a Data::Object::Array object.
bool
# given: synopsis
# e.g.
#
# 0> use Pluto
#
# 1> bool 0
#
# $res[0] = bless( do{\(my $o = 0)}, 'Data::Object::Boolean' )
#
# 2> exit
# e.g.
#
# 0> use Pluto
#
# 1> bool 1
#
# $res[0] = bless( do{\(my $o = 1)}, 'Data::Object::Boolean' )
#
# 2> exit
bool;
This package supports making the bool
function available in the calling package if it doesn't exist already. This function creates a Data::Object::Boolean object.
call
# given: synopsis
call('Test', 'ok');
This package supports making the call
function available in the calling package. This function dispatches function and method calls to a package.
chain
# given: synopsis
chain(path('/var'), ['child', 'logs'], 'absolute');
This package supports making the chain
function available in the calling package. This function chaining function and method calls.
code
# given: synopsis
# e.g.
#
# 0> use Pluto
#
# 1> code sub { time }
#
# $res[0] = bless( sub { "DUMMY" }, 'Data::Object::Code' )
#
# 2> exit
code;
This package supports making the code
function available in the calling package if it doesn't exist already. This function creates a Data::Object::Code object.
false
# given: synopsis
false;
This package supports making the false
function available in the calling package if it doesn't exist already. This function creates a Data::Object::Boolean object.
float
# given: synopsis
# e.g.
#
# 0> use Pluto
#
# 1> float 1.23
#
# $res[0] = bless( do{\(my $o = '1.23')}, 'Data::Object::Float' )
#
# 2> exit
float;
This package supports making the float
function available in the calling package if it doesn't exist already. This function creates a Data::Object::Float object.
hash
# given: synopsis
# e.g.
#
# 0> use Pluto
#
# 1> hash {1..4}
#
# $res[0] = bless( {
# '1' => 2,
# '3' => 4
# }, 'Data::Object::Hash' )
#
# 2> exit
hash;
This package supports making the hash
function available in the calling package if it doesn't exist already. This function creates a Data::Object::Hash object.
inc
# given: synopsis
inc 'Data::Dumper';
# creates a DataDumper function
DataDumper('Dumper', {1..4});
This package supports making the inc
function available in the calling package. When used, this function creates a function after the name provided which calls into the named package. Special characters are stripped from the function name.
number
# given: synopsis
# e.g.
#
# 0> use Pluto
#
# 1> number 123
#
# $res[0] = bless( do{\(my $o = 123)}, 'Data::Object::Number' )
#
# 2> exit
number;
This package supports making the number
function available in the calling package if it doesn't exist already. This function creates a Data::Object::Number object.
regexp
# given: synopsis
# e.g.
#
# 0> use Pluto
#
# 1> regexp qr/.*/
#
# $res[0] = bless( do{\(my $o = qr/.*/u)}, 'Data::Object::Regexp' )
#
# 2> exit
regexp;
This package supports making the regexp
function available in the calling package if it doesn't exist already. This function creates a Data::Object::Regexp object.
space
# given: synopsis
# e.g.
#
# 0> use Pluto
#
# 1> space 'pluto'
#
# $res[0] = bless( do{\(my $o = 'pluto')}, 'Data::Object::Space' )
#
# 2> exit
space;
This package supports making the space
function available in the calling package if it doesn't exist already. This function creates a Data::Object::Space object.
string
# given: synopsis
# e.g.
#
# 0> use Pluto
#
# 1> string 'hello'
#
# $res[0] = bless( do{\(my $o = 'hello')}, 'Data::Object::String' )
#
# 2> exit
string;
This package supports making the string
function available in the calling package if it doesn't exist already. This function creates a Data::Object::String object.
true
# given: synopsis
true;
This package supports making the true
function available in the calling package if it doesn't exist already. This function creates a Data::Object::Boolean object.
AUTHOR
Al Newkirk, awncorp@cpan.org
LICENSE
Copyright (C) 2011-2019, Al Newkirk, et al.
This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".