What problem does it solve?
It removes ambiguity and null-reference risk by making optional values explicit and providing consistent ways to create, transform, and consume them without manual if/else branching.
Core Features & Use Cases
- Explicit optionality with pattern-friendly access: Uses
Maybe<T> with a hasValue discriminant and consumption via match/switch to cleanly handle Some vs None.
- Fluent transformation pipeline: Supports
map, bind (flatMap), filter, flatten, and side-effect hooks like tap/tapNone for readable “railway” flows.
- Conditional and fallback composition: Provides
mapIf/bindIf plus or/orElse and extraction methods like getOrDefault/getOrElse/getOrThrow to implement robust defaulting and error surfacing.
- Async-safe optional pipelines: Offers
mapAsync, bindAsync, filterAsync, tapAsync, matchAsync, and orAsync so optional logic stays correct across async boundaries.
- Collection helpers for option search: Includes
tryFirst, tryLast, tryFind, choose, and asMaybe to safely select and unwrap values from arrays of data.
Quick Start
Use the tsentials-maybe skill to convert a nullable field into Maybe and then map it into a safe display string using Maybe.match.