dotMaybe 0.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package dotMaybe --version 0.0.1                
NuGet\Install-Package dotMaybe -Version 0.0.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="dotMaybe" Version="0.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add dotMaybe --version 0.0.1                
#r "nuget: dotMaybe, 0.0.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.
// Install dotMaybe as a Cake Addin
#addin nuget:?package=dotMaybe&version=0.0.1

// Install dotMaybe as a Cake Tool
#tool nuget:?package=dotMaybe&version=0.0.1                

dotMaybe - The Maybe Monad for .NET

.net workflow

dotMaybe is a lightweight, intuitive implementation of the Maybe monad for .NET. It simplifies working with optional values, eliminating null reference exceptions and promoting a more functional, declarative programming style.

Give it a star ⭐ !

If you find this project valuable, please consider giving it a star! Your support helps others discover this work and encourages further development.

How to use

Creation

Maybe<string> someMaybe = Some.With("Hello, World!");
Maybe<string> noneMaybe = None.OfType<string>();

Retrieving value

int someValue = someMaybe.Match(none: () => -1, some: v => v.Length); // 13
int noneValue = noneMaybe.Match(none: () => -1, some: v => v.Length); // -1

Chaining operations

someMaybe
    .Map(v => v.Length) // Maybe<int> of 13
    .Bind(v => v > 20 ? Some.With(v) : None.OfType<int>()); // Maybe<int> of None

noneMaybe
    .Map(v => v.Length) // Maybe<int> of None
    .Bind(v => v > 20 ? Some.With(v) : None.OfType<int>()); // Maybe<int> of None

Query syntax

// Execute function if all maybes contain value
Maybe<int> finalSomeMaybe =
    from v1 in someMaybe
    from v2 in Some.With("Hello, World!")
    from v3 in Some.With("Hello, World!")
    let v4 = "Hello, World!"
    select v1.Length + v2.Length + v3.Length + v4.Length; // Maybe<int> of 52

// Returns None when any Maybe don't contain value
Result<int> finalNoneMaybe =
    from v1 in noneMaybe
    from v2 in Some.With("Hello, World!")
    from v3 in None.OfType<string>()
    let v4 = "Hello, World!"
    select v1.Length + v2.Length + v3.Length + v4.Length; // Maybe<int> of none

Contribution

If you would like to contribute to this project, check out CONTRIBUTING file.

License

This project is licensed under the terms of the MIT license.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

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
1.0.0 113 8/3/2024
0.3.0 48 7/28/2024
0.2.0 60 7/26/2024
0.1.0 63 7/23/2024
0.0.1 74 7/21/2024