MonadicTypes.NET 0.3.0-preview.2

This is a prerelease version of MonadicTypes.NET.
dotnet add package MonadicTypes.NET --version 0.3.0-preview.2
                    
NuGet\Install-Package MonadicTypes.NET -Version 0.3.0-preview.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MonadicTypes.NET" Version="0.3.0-preview.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MonadicTypes.NET" Version="0.3.0-preview.2" />
                    
Directory.Packages.props
<PackageReference Include="MonadicTypes.NET" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MonadicTypes.NET --version 0.3.0-preview.2
                    
#r "nuget: MonadicTypes.NET, 0.3.0-preview.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MonadicTypes.NET@0.3.0-preview.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MonadicTypes.NET&version=0.3.0-preview.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=MonadicTypes.NET&version=0.3.0-preview.2&prerelease
                    
Install as a Cake Tool

MonadicTypes.NET

Allocation-conscious Result<T,E>, Option<T>, Unit, composition, and struct-callable primitives for C# 14 and .NET 10.

Use this core package when expected failure or absence should be represented in the type system without reflection, exceptions for ordinary control flow, or a dependency-injection requirement.

Requirements

  • .NET 10 or later
  • Compatible with trimming and NativeAOT
  • No runtime package dependencies

Install

dotnet add package MonadicTypes.NET --prerelease

Quick Start

using MonadicTypes;

static Result<int, string> ParsePositive(string text) =>
    int.TryParse(text, out int value) && value > 0
        ? Result<int, string>.Ok(value)
        : Result<int, string>.Fail("A positive integer is required.");

string message = ParsePositive("21")
    .Map(static value => value * 2)
    .Match(
        static value => $"Value: {value}",
        static error => $"Error: {error}");

Option<string> name = Option<string>.Some("Ada");
int length = name.Map(static value => value.Length).ValueOr(0);

Core Behavior

  • Result<T,E> is exactly Ok(T) or Fail(E); its default value is invalid.
  • Option<T> is Some(T) or None; default(Option<T>) is None.
  • Equality and hashing inspect only the active Result or Option payload.
  • Some(null) is rejected.
  • Map transforms success, Bind composes dependent results, and MapError transforms failure.
  • Result<Option<T>,E> represents a fallible lookup where absence is expected.
  • Combine, Zip, and two-through-six-input Map/Bind compose independent results; caller-state forms avoid captured projection delegates.
  • Recover, ValueOrElse, and RequireSome accept caller state when a lazy failure path needs local data without a captured delegate.
  • Option.Traverse exchanges optional input with a fallible stage.
  • Explicit nullable bridges and deconstruction support application boundaries and patterns.

Normal static callbacks and successful pipelines allocate 0 B in the accepted benchmarks. Caller-state overloads avoid closures, while struct callables are available for measured hot paths. Do not use Result or Option inside parsing or vectorized inner loops where a simpler branch or Try* contract is cheaper.

Package Add it for
MonadicTypes.NET.Errors Structured errors and validation values
MonadicTypes.NET.Async Fluent Task and ValueTask composition
MonadicTypes.NET.Effects Explicit exception boundaries
MonadicTypes.NET.Collections Count-known fail-fast traversal into arrays
MonadicTypes.NET.Linq Opt-in fluent and query-expression operators
MonadicTypes.NET.AspNetCore Typed HTTP and problem results
MonadicTypes.NET.AspNetCore.OpenApi Error-catalog response metadata and examples in generated OpenAPI documents
MonadicTypes.NET.Diagnostics Optional Activity and Meter projection
MonadicTypes.NET.Generators Compile-time struct-callable adapters
MonadicTypes.NET.Testing Framework-neutral Result and Option test helpers
MonadicTypes.NET.Analyzers Opt-in diagnostics for nested railway types and common Option misuse

Documentation

See the complete API guide, API behavior reference, and benchmark policy.

Apache-2.0. Developed with AI assistance.

Complete API reference

Documented public members: 153

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on MonadicTypes.NET:

Package Downloads
MonadicTypes.NET.Errors

Structured, immutable, allocation-conscious errors and validation values for MonadicTypes.NET.

MonadicTypes.NET.Async

ValueTask- and Task-aware railway operators for MonadicTypes.NET results.

MonadicTypes.NET.Effects

Explicit exception boundaries and side-effect operators for MonadicTypes.NET pipelines.

MonadicTypes.NET.Collections

Bounded, allocation-explicit collection traversal for MonadicTypes.NET.

MonadicTypes.NET.Linq

Opt-in C# query-expression operators for MonadicTypes.NET.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.0-preview.2 49 9/12/2026
0.3.0-preview.1 45 9/12/2026
0.2.0-preview.2 234 8/30/2026
0.2.0-preview.1 119 8/17/2026
0.1.0-preview.1 92 8/12/2026