MonadicTypes.NET.Collections 0.3.0-preview.1

This is a prerelease version of MonadicTypes.NET.Collections.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package MonadicTypes.NET.Collections --version 0.3.0-preview.1
                    
NuGet\Install-Package MonadicTypes.NET.Collections -Version 0.3.0-preview.1
                    
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.Collections" Version="0.3.0-preview.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MonadicTypes.NET.Collections" Version="0.3.0-preview.1" />
                    
Directory.Packages.props
<PackageReference Include="MonadicTypes.NET.Collections" />
                    
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.Collections --version 0.3.0-preview.1
                    
#r "nuget: MonadicTypes.NET.Collections, 0.3.0-preview.1"
                    
#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.Collections@0.3.0-preview.1
                    
#: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.Collections&version=0.3.0-preview.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=MonadicTypes.NET.Collections&version=0.3.0-preview.1&prerelease
                    
Install as a Cake Tool

MonadicTypes.NET Collections

Count-known, fail-fast collection traversal for MonadicTypes.NET, without IEnumerable<T> iterators, reflection, builders, or hidden resizing.

Install

dotnet add package MonadicTypes.NET.Collections --prerelease

Traverse

using MonadicTypes;
using MonadicTypes.Collections;

Result<User[], LookupError> users = ids.TraverseToArray(LoadUser);

Result<User[], LookupError> withoutCapture = ids.TraverseToArray(
    repository,
    static (id, state) => state.Load(id));

ReadOnlySpan<UserId> contiguousIds = ids;
Result<User[], LookupError> contiguous = contiguousIds.TraverseToArray(LoadUser);

TraverseToArray accepts IReadOnlyList<T> or ReadOnlySpan<T> and invokes the selector once per item until the first failure. Empty input returns the shared empty array. Non-empty input allocates exactly one owned output array, including when a later item fails. Delegate, caller-state, and struct-callable overloads share the same branch behavior.

Sequence

ReadOnlySpan<Result<User, LookupError>> results = loaded;
Result<User[], LookupError> users = results.SequenceToArray();

SequenceToArray preserves order and the first failure. It has the same empty and one-array allocation contract as traversal.

The package does not catch selector or indexer exceptions. Exceptions propagate unchanged with their original stack; use MonadicTypes.NET.Effects at an intentional exception boundary. Uninitialized Result values throw.

Performance

The initial list NativeAOT benchmark measured delegate and caller-state traversal within 2% of an allocation-equivalent manual loop. Struct-callable traversal was 13% faster. Every row allocated the same 88 B eight-element output array and no wrapper allocation.

The subsequent span benchmark retained the same 88 B owned array and measured the struct-callable path at 19.918 ns, 47.1% faster than the same-run list struct-callable path. Measurements are host-specific regression evidence rather than universal throughput guarantees.

Apache-2.0. Developed with AI assistance.

Complete API reference

Documented public members: 10

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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.0-preview.2 142 9/12/2026
0.3.0-preview.1 46 9/12/2026
0.2.0-preview.2 99 8/30/2026
0.2.0-preview.1 80 8/17/2026