![]() |
VOOZH | about |
dotnet add package StoneKit.Core.Structs.Maybe --version 2024.1.1.391401
NuGet\Install-Package StoneKit.Core.Structs.Maybe -Version 2024.1.1.391401
<PackageReference Include="StoneKit.Core.Structs.Maybe" Version="2024.1.1.391401" />
<PackageVersion Include="StoneKit.Core.Structs.Maybe" Version="2024.1.1.391401" />Directory.Packages.props
<PackageReference Include="StoneKit.Core.Structs.Maybe" />Project file
paket add StoneKit.Core.Structs.Maybe --version 2024.1.1.391401
#r "nuget: StoneKit.Core.Structs.Maybe, 2024.1.1.391401"
#:package StoneKit.Core.Structs.Maybe@2024.1.1.391401
#addin nuget:?package=StoneKit.Core.Structs.Maybe&version=2024.1.1.391401Install as a Cake Addin
#tool nuget:?package=StoneKit.Core.Structs.Maybe&version=2024.1.1.391401Install as a Cake Tool
The Maybe monad is a generic struct designed to represent optional values in C# following the Option Monad design pattern. It allows you to work with values that might be absent, helping to write more expressive and concise code.
This library includes extension methods for additional operations and functionalities which makes it unique by keeping the struct size as small as possible.
It has small memory footprints and performs much faster that other available implementations.
For a comprehensive understanding of the Maybe Monad, you can refer to the Pluralsight tech blog and Wikipedia on Monad (functional programming).
You can install by using NuGet:
PM> Install-Package StoneKit.Core.Strcuts.Maybe
var maybeWithValue = new Maybe<int>(42);
var maybeEmpty = Maybe<int>.Empty;
var toMaybe = 10.ToMaybe();
var maybe = Maybe<int>.Empty
.Or(10)
.Where(x => x > 5)
.Perform(x=> Console.WriteLine($"{x} is greater than 5."))
.Match(
value => value < 50,
value => Console.WriteLine($"{value} is smaller than 50.")
)
.Where(x=> x >100)
.PerformOnEmpty(() => Console.WriteLine("Performing action on empty Maybe"))
.Or(100)
.Finally(x=> Console.WriteLine("I'm done!"));
PerformPerforms an action on the value if the Maybe monad has a value.
PerformOnEmptyPerforms an action when the Maybe monad is empty.
FinallyPerforms an action on the value regardless of whether the Maybe monad has a value.
OrReturns the original Maybe monad if it has a value; otherwise, returns a new Maybe monad with the specified default value.
MapMaps the Maybe monad from one type to another using a provided function.
MapOnEmptyMaps the Maybe monad to another type when it is empty, using a provided function.
SelectManySelects and projects the value of the Maybe monad using provided functions.
WhereFilters the Maybe monad based on a predicate.
ToMaybeConverts an object to a Maybe monad.
ToTypeConverts an object to a Maybe monad of a specific type.
If you find any issues or have suggestions for improvements, feel free to open an or create a .
This Maybe Monad library is licensed under the .
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 2 NuGet packages that depend on StoneKit.Core.Structs.Maybe:
| Package | Downloads |
|---|---|
|
StoneKit.Core.Reflection
A reflection utility containing handy extension methods and a utility for emitting IL (Intermediate Language) code using the ILGenerator. |
|
|
StoneKit.TransverseMapper
Transverse - Fastest and quickest object mapper for dotnet |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2024.1.1.391401 | 273 | 10/5/2024 |
| 2024.1.1.305385 | 284 | 8/5/2024 |
| 2024.1.1.268769 | 236 | 7/9/2024 |
| 2024.1.1.261674 | 227 | 7/4/2024 |
| 2024.1.1.261665 | 217 | 7/4/2024 |
| 2024.1.1.261630 | 213 | 7/4/2024 |
| 2024.1.1.260673 | 280 | 7/3/2024 |
| 2024.1.1.260489 | 247 | 7/3/2024 |
| 2024.1.1.260485 | 223 | 7/3/2024 |
| 1.24.703.180756 | 532 | 7/3/2024 |
| 1.24.703.164604 | 511 | 7/3/2024 |
| 1.24.703.121207 | 1,022 | 7/3/2024 |
| 1.24.626.192706 | 240 | 6/26/2024 |
| 1.24.612.859 | 227 | 6/11/2024 |
| 1.24.611.233127 | 247 | 6/11/2024 |
| 1.24.611.232750 | 227 | 6/11/2024 |
| 1.24.603.121931 | 188 | 6/3/2024 |
| 1.24.317.170729 | 248 | 3/17/2024 |
| 1.24.317.170542 | 236 | 3/17/2024 |
| 1.24.317.164648 | 241 | 3/17/2024 |