Power of object-oriented programming with the elegance of functional programming. Increase the robustness with reduced amount of code.
At the moment, in the experimental phase.
Due to the lack of generic types, Munus achieves genericity with the help of Psalm template
annotation.
Munus examples:
/** @var Stream<int> $stream */
$stream = Stream::range(1, 10)->map(function(int $int): int {return $int * 5});
/** @var Option<Success> $option */
$option = Option::of(domainOperation());
/** @return Either<Failure,Success> */
function domainOperation(): Either {}
/** @var TryTo<Result> $result */
$result = TryTo::run(function(){throw new \DomainException('use ddd');});
$result->getOrElse(new Result())
The goal is to help achieve: Psalm was able to infer types for 100% of the codebase
Values:
- TryTo
- Either
- Option
- Lazy
Collections:
- Set
- Stream (implemented as lazy linked list)
- GenericList (implemented as immutable linked list)
- Iterator
- Pattern matching
- Property checking
- Try with recover
- Immutable Data Structures
- Tuples
This library is inspired by vavr.io
Munus is released under the MIT Licence. See the bundled LICENSE file for details.