All Projects → php-slang → php-slang

php-slang / php-slang

Licence: other
The place where PHP meets Functional Programming

Programming Languages

PHP
23972 projects - #3 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to php-slang

fpEs
Functional Programming for EcmaScript(Javascript)
Stars: ✭ 40 (-62.62%)
Mutual labels:  fp, monad, optional
Kotlin Result
A multiplatform Result monad for modelling success or failure operations.
Stars: ✭ 369 (+244.86%)
Mutual labels:  fp, monad
ts-belt
🔧 Fast, modern, and practical utility library for FP in TypeScript.
Stars: ✭ 439 (+310.28%)
Mutual labels:  fp, monad
Plasma
Plasma Programming Language
Stars: ✭ 133 (+24.3%)
Mutual labels:  parallel-computing, parallelism
Monio
Async-capable IO monad for JS
Stars: ✭ 311 (+190.65%)
Mutual labels:  fp, monad
Fun Task
Abstraction for managing asynchronous code in JS
Stars: ✭ 363 (+239.25%)
Mutual labels:  fp, monad
Hamsters.js
100% Vanilla Javascript Multithreading & Parallel Execution Library
Stars: ✭ 517 (+383.18%)
Mutual labels:  parallel-computing, parallelism
typescript-monads
📚Write safer TypeScript using Maybe, List, Result, and Either monads.
Stars: ✭ 94 (-12.15%)
Mutual labels:  immutability, either-monad
Design-Patterns
Project for learning and discuss about design patterns
Stars: ✭ 16 (-85.05%)
Mutual labels:  fp, monad
fnts
λ Minimal Functional Programming Utilities for TypeScript & JavaScript
Stars: ✭ 75 (-29.91%)
Mutual labels:  fp, monad
UnderstandingLanguageExt
This is a tutorial that aims to demonstrate the practical fundamentals behind using LanguageExt in a fashion though step-by-step tutorials which introduce and then build up on concepts.
Stars: ✭ 73 (-31.78%)
Mutual labels:  immutability, monad
Prelude Ts
Functional programming, immutable collections and FP constructs for typescript and javascript
Stars: ✭ 315 (+194.39%)
Mutual labels:  fp, immutability
Eslint Plugin Functional
ESLint rules to disable mutation and promote fp in JavaScript and TypeScript.
Stars: ✭ 282 (+163.55%)
Mutual labels:  fp, immutability
java-multithread
Códigos feitos para o curso de Multithreading com Java, no canal RinaldoDev do YouTube.
Stars: ✭ 24 (-77.57%)
Mutual labels:  parallel-computing, parallelism
hkts
Functional programming tools: option, either, task, state, optics, etc.
Stars: ✭ 20 (-81.31%)
Mutual labels:  fp, monad
Bow
🏹 Bow is a cross-platform library for Typed Functional Programming in Swift
Stars: ✭ 538 (+402.8%)
Mutual labels:  fp, monad
Awesome Machine Learning In Compilers
Must read research papers and links to tools and datasets that are related to using machine learning for compilers and systems optimisation
Stars: ✭ 168 (+57.01%)
Mutual labels:  parallel-computing, parallelism
function-composition-cheatsheet
Composition of Functions
Stars: ✭ 24 (-77.57%)
Mutual labels:  fp, monad
apropos
Fast strong typed 'Either' data structure for typescript and flow
Stars: ✭ 20 (-81.31%)
Mutual labels:  fp, monad
ludwig
A lattice Boltzmann code for complex fluids
Stars: ✭ 35 (-67.29%)
Mutual labels:  parallel-computing

PhpSlang

Packagist PHP from Packagist Build Status Scrutinizer Code Quality Code Coverage Build Status Packagist

PhpSlang

PhpSlang will help you to write purely functional code with PHP.

PhpSlang is a PHP library aiming to fill the gaps between PHP and classical functional languages. It provides constructs optimizing your work and letting you develop with a purely functional style.

More info

Official page

Documentation

Twitter

Roadmap

Features

Example code

With a PhpSlang your code is going to look like that:

public function nonTrivialExampleFn(ParallelListCollection $mysteriousInput): float {
  return $mysteriousInput
    ->filter(function ($elem) {
      return $elem > 10;
    })
    ->partition(
      function ($elem) {
        return $elem <=> 20;
      },
      new Set([-1, 0, 1])
    )
    ->map(function (ListCollection $bucket) {
      return $bucket->max()->getOrElse(0.0);
    })
    ->avg()
    ->getOrElse(0.0);
}

Or that:

public function actionUpdateBook(string $bookId, Request $request): Response {
  return $this
    ->bookUpdaterService
    ->updateBook($bookId, $this->bookRequestTransformer->toInput($request), $this->getUser())
    ->left(function(BookUpdateError $error) {
      return Match::val($error)->of(
        new TypeOf(BookNotFound::class, new Response(null, Response::HTTP_NOT_FOUND)),
        new TypeOf(InvalidInput::class, new Response(null, Response::HTTP_BAD_REQUEST)),
        new TypeOf(NotAuthorized::class, new Response(null, Response::HTTP_UNAUTHORIZED))
      );
    })
    ->right(function(BookInfo $bookInfo) {
      return new Response($this->bookInfoTransformer->toJson($bookInfo), Response::HTTP_OK);
    })
    ->get();
}

Want to see more examples? See documentation.

Contribution

TL;DR;

Just feel free to post your pull requests on GitHub.

Contribution how to

  1. Fork this repository

  2. Clone your fork

git clone [email protected]:php-slang/php-slang.git
  1. Install dependencies
composer install --dev
  1. Write some code

  2. Verify if it's fine

./ci/verify.sh
  1. Push your pull request!

The MIT License (MIT)

Copyright (c) 2018 Witold Adamus

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].