MonadicTypes.NET.Collections
0.2.0-preview.2
See the version list below for details.
dotnet add package MonadicTypes.NET.Collections --version 0.2.0-preview.2
NuGet\Install-Package MonadicTypes.NET.Collections -Version 0.2.0-preview.2
<PackageReference Include="MonadicTypes.NET.Collections" Version="0.2.0-preview.2" />
<PackageVersion Include="MonadicTypes.NET.Collections" Version="0.2.0-preview.2" />
<PackageReference Include="MonadicTypes.NET.Collections" />
paket add MonadicTypes.NET.Collections --version 0.2.0-preview.2
#r "nuget: MonadicTypes.NET.Collections, 0.2.0-preview.2"
#:package MonadicTypes.NET.Collections@0.2.0-preview.2
#addin nuget:?package=MonadicTypes.NET.Collections&version=0.2.0-preview.2&prerelease
#tool nuget:?package=MonadicTypes.NET.Collections&version=0.2.0-preview.2&prerelease
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.
Documented public members: 8
| 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
- MonadicTypes.NET (>= 0.2.0-preview.2)
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 |