Orx.Fun.Option 1.2.1

.NET 6.0
dotnet add package Orx.Fun.Option --version 1.2.1
NuGet\Install-Package Orx.Fun.Option -Version 1.2.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="Orx.Fun.Option" Version="1.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Orx.Fun.Option --version 1.2.1
#r "nuget: Orx.Fun.Option, 1.2.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 Orx.Fun.Option as a Cake Addin
#addin nuget:?package=Orx.Fun.Option&version=1.2.1

// Install Orx.Fun.Option as a Cake Tool
#tool nuget:?package=Orx.Fun.Option&version=1.2.1


An option type for C# aiming to be explicit while concise.

Complete auto-generated documentation can be found here: sandcastle-documentation.


  1. Optional (maybe) values are necessary.
    • Explicit optional arguments
    • Explicit optional returns
    • Continuations without overwhelming null/none checks
    • ...
  2. Built-in nullables do not seem to satisfy the requirements.

Explicit Optional Arguments

static void Solve(Instance instance, Opt<SolverParameters> parameters = default)
	// solve with the parameters if provided;
	// with default parameters otherwise.

// caller knows that it is okay not to provide parameters
Solve(instance, None<SolverParameters>());

// or solve with parameters
SolverParameters pars = new()
	TimeLimit = 60,
Solve(instance, Some(pars));

Explicit Optional Returns

An easy example to demonstrate this is the linq method First:

var numbers = new int[] { 1, 3, 5, 7 };
int firstEven = numbers.First(x => x % 2 == 0); // throws!!!

First method actually does not (cannot always) return an int. FirstOrDefault certainly does not fix the issue. On the other hand, solution is easy with optionals:

var numbers = new int[] { 1, 3, 5, 7 };
Opt<int> firstEven = numbers.FirstOrNone(x => x % 2 == 0);


The following dummy example illustrates the use of Map and FlatMap to enable continuations.

/// Returns Some of the user if there exists one with the given id; None otherwise
static Opt<User> GetUserById(int id)
	// ...

// task to achieve:
// 1. get the first even number
// 2. halve it
// 3. get the user with the number as id, if exists
// 4. return the users's name

var numbers = new int[] { 1, 3, 5, 7 };
Opt<string> name = numbers.FirstOrNone(x => x % 2 == 0)
    .Map(x => x / 2)
    .Map(user => user.Name);

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Orx.Fun.Option:

Package Downloads

A simple result type for C#, not minding the error type, instead aiming to be explicit, concise and fluent.


A mathematical modeling library that enables building, documenting and solving concise, simple and reusable models.


Unified functional collections for C# allowing access by index.


A function composition library for C#, heavily experimental right now, would be more practical if C# gets generic operator overloading.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.1 223 7/27/2023
1.2.0 113 7/27/2023
1.1.0 116 7/26/2023
1.0.0 211 5/5/2023