cline/monad

There is no license information available for the latest version (1.0.0) of this package.

1.0.0 2025-10-04 06:24 UTC

This package is auto-updated.

Last update: 2025-10-04 12:47:24 UTC


README

Rust-aligned Option, Result, and Either types providing expressive, type-safe error handling and ergonomic controller helpers for Laravel applications.

Installation

composer require cline/monad

Documentation

  • Option Guide - Complete guide with real-world examples for null-safe operations
  • Result Guide - Comprehensive error handling patterns with Ok/Err semantics
  • Either Guide - Advanced Left/Right branching for complex scenarios

Highlights

  • Option: Null-safety with fromNullable(), Laravel firstOption() macros, controller unwrapOrAbort() helpers
  • Result: Ok/Err semantics with full combinators and interop with Option
  • Either: Left/Right branching for complex multi-path scenarios
  • Full Rust-aligned API naming for unwrapping and chaining operations

Quick Reference

Option API

Create: fromNullable() fromValue() ensure() fromReturn() | Query: isSome() isNone() contains() | Unwrap: unwrap() unwrapOr() unwrapOrAbort() | Transform: map() andThen() filter() | Match: match(someFn, noneFn)

Result API

Create: Ok($v) Err($e) | Query: isOk() isErr() ok() err() | Unwrap: unwrap() unwrapOr() expect() | Transform: map() mapErr() andThen() | Match: match(okFn, errFn)

Either API

Create: left($v) right($v) | Query: isLeft() isRight() left() right() | Unwrap: unwrapLeft() unwrapRight() | Transform: mapLeft() mapRight() bimap() | Match: match(leftFn, rightFn)

See individual cookbook guides for comprehensive API documentation.

License

This package is open-sourced software licensed under the MIT license.

Credits