freyr/monadic

A PHP library for monadic operations.

0.1.0 2025-05-22 22:04 UTC

This package is auto-updated.

Last update: 2025-05-22 22:37:46 UTC


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.