2017 © Pedro PelĂĄez
 

library prelude

Functional library

image

sergiors/prelude

Functional library

  • Friday, March 16, 2018
  • by sergiors
  • Repository
  • 6 Watchers
  • 44 Stars
  • 71 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Prelude

Scrutinizer Code Quality Code Coverage Build Status, (*1)

Install

composer require sergiors/prelude "dev-master"

How to use

use function Prelude\cond;
use function Prelude\equals;
use function Prelude\always;

$fn = cond([
    [equals(0), always('water freezes at 0°C')],
    [equals(100), always('water boils at 100°C')],
    [always(true), function ($temp) {
        return 'nothing special happens at '.$temp.'°C';
    }]
]);

echo $fn(0); // => water freezes at 0°C
echo $fn(50); // => nothing special happens at 50°C
echo $fn(100); // => water boils at 100°C
use function Prelude\has;

$hasName = has('name');
echo $hasName(['name' => 'Jimi']); // => true
echo $hasName([]); // => false
use const Prelude\id;
use const Prelude\isEmpty;
use function Prelude\ifElse;
use function Prelude\always;

$fn = ifElse(isEmpty)
    (always(true))
    (always(false));
echo $fn([]); // => true
echo $fn(null); // => true
echo $fn(false); // => true
echo $fn('James'); // => false
use function Prelude\head;

echo head([1, 2, 3]); // => 1
use function Prelude\tail;

echo tail([1, 2, 3]); // => [2, 3]

API

Full API Documentation, (*2)

Thanks

Marcelo Camargo, (*3)

License

MIT, (*4)

The Versions

16/03 2018

dev-master

9999999-dev

Functional library

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

by Sérgio Rafael Siqueira

monad functional-programming

22/02 2018

dev-documentation

dev-documentation

Functional library

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

by Sérgio Rafael Siqueira

monad functional-programming

04/12 2017

1.0.1-alpha

1.0.1.0-alpha

Functional library

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

by Sérgio Rafael Siqueira

monad functional-programming

13/01 2017