Files
2026-03-30 21:29:45 -05:00

1.6 KiB

StevanFreeborn.Options

NuGet NuGet License: MIT

A minimalistic, AOT-compatible Option type library for functional programming in .NET.

Features

  • Functional Programming: Chain operations with Map, Bind, and Match
  • AOT Compatible: Works with Native AOT and trimming
  • Nullable Reference Types: Full support for nullable reference types
  • No External Dependencies: Lightweight with zero dependencies
  • Pattern Matching Support: Deconstruction support for modern C# pattern matching
  • Comprehensive XML Documentation: Full IntelliSense support

Installation

Install via NuGet:

dotnet add package StevanFreeborn.Options

Quick Start

using StevanFreeborn.Options;

// Create an option with a value
Option<string> some = Option<string>.Some("Hello");

// Create an empty option
Option<string> none = Option<string>.None();

// Implicit conversion from value
Option<string> implicitSome = "World";

// Use functional operations
string result = some
  .Map(s => s.ToUpper())
  .Match(
    onSome: s => $"Value: {s}",
    onNone: () => "No value"
  );

// Pattern matching
if (some is (true, var value))
{
  Console.WriteLine(value);
}

Requirements

  • .NET Standard 2.1
  • .NET 10.0+

License

MIT License - see LICENSE.md for details.