freyr / monadic
A PHP library for monadic operations.
0.1.0
2025-05-22 22:04 UTC
Requires
- php: ^8.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^12.0
- symplify/easy-coding-standard: ^12.3
README
Freyr Monadic is a PHP library designed to provide monadic types, specifically Option
and Result
, to facilitate functional programming paradigms in PHP.
This library aims to enhance code reliability and readability by offering a structured approach to handling optional values and results of computations.
Features
- Option Monad: Represents optional values, allowing for safe chaining and transformation of computations.
- Result Monad: Encapsulates successful or failed computations, providing a clear and concise way to handle errors.
Installation
To install this library, use Composer:
composer require freyr/monadic
Usage
use Freyr\Monadic\Option; use Freyr\Monadic\Result; // Example usage of Option and Result monads
Educational Purpose
This library was created for educational purposes to demonstrate the implementation and use of monadic types in PHP. It is intended to help developers understand and apply functional programming concepts in their PHP projects.
License
This project is licensed under the MIT License — see the LICENSE file for details.