Skip to content
Ahmad Al-freihat edited this page Jan 1, 2026 · 2 revisions

Masterly.NonEmptyList

A simple and lightweight implementation of a non-empty list in C#, inspired by Scala's List, that ensures a collection always has at least one item.

Nuget Nuget

Features

  • Non-Empty Guarantee: Always contains at least one element
  • Head/Tail Access: Convenient Head, Tail, Init, First, and Last properties
  • Functional Operations: Map, FlatMap, Reduce, Fold, Zip, Partition, and more
  • Pattern Matching: Match method and deconstruction support
  • Async Support: Full async extension methods for all operations
  • Immutable Variant: ImmutableNonEmptyList<T> for thread-safe scenarios
  • JSON Serialization: Built-in System.Text.Json support
  • EF Core Integration: Entity Framework Core support via separate package
  • Equality Support: Implements IEquatable<T> with == and != operators
  • Multi-targeting: Supports .NET 6.0 and .NET 8.0

Documentation

Getting Started

Creating Lists

Functional Programming

Collection Operations

Validation & Safety

Async Support

Variants

Serialization & Integration

Reference

Clone this wiki locally