MonadicTypes.NET
0.2.0-preview.2
See the version list below for details.
dotnet add package MonadicTypes.NET --version 0.2.0-preview.2
NuGet\Install-Package MonadicTypes.NET -Version 0.2.0-preview.2
<PackageReference Include="MonadicTypes.NET" Version="0.2.0-preview.2" />
<PackageVersion Include="MonadicTypes.NET" Version="0.2.0-preview.2" />
<PackageReference Include="MonadicTypes.NET" />
paket add MonadicTypes.NET --version 0.2.0-preview.2
#r "nuget: MonadicTypes.NET, 0.2.0-preview.2"
#:package MonadicTypes.NET@0.2.0-preview.2
#addin nuget:?package=MonadicTypes.NET&version=0.2.0-preview.2&prerelease
#tool nuget:?package=MonadicTypes.NET&version=0.2.0-preview.2&prerelease
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 exactlyOk(T)orFail(E); its default value is invalid.Option<T>isSome(T)orNone;default(Option<T>)isNone.- Equality and hashing inspect only the active Result or Option payload.
Some(null)is rejected.Maptransforms success,Bindcomposes dependent results, andMapErrortransforms failure.Result<Option<T>,E>represents a fallible lookup where absence is expected.Combine,Zip, and two-through-six-inputMap/Bindcompose independent results; caller-state forms avoid captured projection delegates.Option.Traverseexchanges 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.
Related Packages
| 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.Diagnostics |
Optional Activity and Meter projection |
MonadicTypes.NET.Generators |
Compile-time struct-callable adapters |
Documentation
See the complete API guide, API behavior reference, and benchmark policy.
Apache-2.0. Developed with AI assistance.
Documented public members: 141
| Product | Versions 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. |
-
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 |