API Reference

Complete API documentation for NOPE-PRO types, methods, and extensions.

API Reference

Complete reference documentation for all NOPE-PRO types, methods, and extension functions. Find detailed information about parameters, return values, and usage examples for every API.

๐Ÿ“š Core Types

NOPE-PRO provides two fundamental types that form the foundation of Railway-Oriented Programming:

Result<T, E>

The primary type for handling operations that can succeed or fail.

  • Constructor methods - Success(), Failure(), Of(), SuccessIf()
  • Transformation methods - Map(), Bind(), MapError(), Ensure()
  • Side-effect methods - Tap()
  • Termination methods - Finally(), Match(), Or(), OrElse()
  • Async extensions - UniTask and Awaitable integration
  • Debugging methods - EnableDebug(), flow tracking

Maybe<T>

Safe optional value handling without null reference exceptions.

  • Constructor methods - From(), None, implicit conversions
  • Transformation methods - Map(), Where(), Select()
  • Side-effect methods - Execute(), ExecuteNoValue(), Tap()
  • Termination methods - Match(), Or(), OrElse()
  • Conversion methods - ToResult()
  • LINQ integration

๐Ÿ” Quick API Lookup

Error Handling

MethodPurposeWhen to Use
MapError()Transform errorAdd context to errors
Ensure()Add validationValidate success values
OrElse()Fallback operationTry alternative sources
Finally()Cleanup/loggingAlways execute code
TapError()Side effects on errorLog failures

Async Operations

MethodFrameworkPurpose
Bind(async func)UniTask/AwaitableChain async operations
Map(async func)UniTask/AwaitableTransform with async
Tap(async action)UniTask/AwaitableAsync side effects

Conversion Extensions

1// Maybe to Result
2maybe.ToResult("Not found")
  1. Custom extensions: Build your own Result/Maybe methods

๐Ÿ’ก Code Examples

Basic Result Usage

1// Creating Results
2var success = Result<int, string>.Success(42);
3var failure = Result<int, string>.Failure("Something went wrong");
4
5// Chaining operations
6var result = LoadData()
7    .Map(data => data.ToUpper())
8    .Bind(ProcessData)
9    .Ensure(data => data.Length > 0, "Data cannot be empty");

Maybe Operations

1// Creating Maybe values
2Maybe<string> name = GetUserName();  // Could be Some or None
3
4// Safe operations
5var length = name
6    .Map(n => n.Length)  // Only if name has value
7    .Or(0);              // Default to 0 if no name

Error Handling Patterns

1// Comprehensive error handling
2var result = RiskyOperation()
3    .MapError(ex => $"Operation failed: {ex.Message}")
4    .OrElse(() => TryAlternativeOperation())
5    .Finally(r => LogResult(r));

๐Ÿ“‹ Method Categories

Each API page includes methods organized by category:

  • ๐Ÿ—๏ธ Construction - Creating instances
  • ๐Ÿ”„ Transformation - Mapping and binding
  • โœ… Validation - Ensuring constraints
  • ๐Ÿ”€ Combination - Working with multiple values
  • ๐Ÿ‘๏ธ Inspection - Examining values
  • ๐ŸŽฏ Termination - Final operations
  • ๐Ÿ”ง Utilities - Helper methods

Need detailed information? Choose the type you're working with: