{"id":15066033,"url":"https://github.com/a7mdfre7at/masterly.nonemptylist","last_synced_at":"2026-01-07T21:06:50.845Z","repository":{"id":256997352,"uuid":"857040113","full_name":"a7mdfre7at/Masterly.NonEmptyList","owner":"a7mdfre7at","description":"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. This helps in reducing null-related bugs and ensures safe operations on collections with at least one element.","archived":false,"fork":false,"pushed_at":"2024-09-15T18:39:11.000Z","size":90,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-22T14:07:53.813Z","etag":null,"topics":["a7mdfre7at","csharp","data-structures","dotnet","dotnet-core","functional-programming","list","masterly","non-empty","non-empty-collections","scala-list-like"],"latest_commit_sha":null,"homepage":"https://github.com/a7mdfre7at/Masterly.NonEmptyList","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/a7mdfre7at.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-13T17:22:26.000Z","updated_at":"2024-09-15T18:42:22.000Z","dependencies_parsed_at":"2024-09-17T22:30:16.878Z","dependency_job_id":null,"html_url":"https://github.com/a7mdfre7at/Masterly.NonEmptyList","commit_stats":null,"previous_names":["a7mdfre7at/masterly.nonemptylist"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a7mdfre7at%2FMasterly.NonEmptyList","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a7mdfre7at%2FMasterly.NonEmptyList/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a7mdfre7at%2FMasterly.NonEmptyList/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a7mdfre7at%2FMasterly.NonEmptyList/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a7mdfre7at","download_url":"https://codeload.github.com/a7mdfre7at/Masterly.NonEmptyList/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235126749,"owners_count":18939973,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["a7mdfre7at","csharp","data-structures","dotnet","dotnet-core","functional-programming","list","masterly","non-empty","non-empty-collections","scala-list-like"],"created_at":"2024-09-25T01:00:07.526Z","updated_at":"2026-01-07T21:06:50.834Z","avatar_url":"https://github.com/a7mdfre7at.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Masterly.NonEmptyList\n\nA 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. This helps in reducing null-related bugs and ensures safe operations on collections with at least one element.\n\n\u003cimg src=\"https://raw.githubusercontent.com/a7mdfre7at/Masterly.NonEmptyList/master/repo_image.png\" width=\"200\" height=\"180\"\u003e\n\n[![Nuget](https://img.shields.io/nuget/v/Masterly.NonEmptyList?style=flat-square)](https://www.nuget.org/packages/Masterly.NonEmptyList) ![Nuget](https://img.shields.io/nuget/dt/Masterly.NonEmptyList?style=flat-square) ![GitHub last commit](https://img.shields.io/github/last-commit/a7mdfre7at/Masterly.NonEmptyList?style=flat-square) ![GitHub](https://img.shields.io/github/license/a7mdfre7at/Masterly.NonEmptyList) [![Build](https://github.com/a7mdfre7at/Masterly.NonEmptyList/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/a7mdfre7at/Masterly.NonEmptyList/actions/workflows/build.yml) [![CodeQL Analysis](https://github.com/a7mdfre7at/Masterly.NonEmptyList/actions/workflows/codeql.yml/badge.svg?branch=master)](https://github.com/a7mdfre7at/Masterly.NonEmptyList/actions/workflows/codeql.yml) [![Publish to NuGet](https://github.com/a7mdfre7at/Masterly.NonEmptyList/actions/workflows/publish.yml/badge.svg?branch=master)](https://github.com/a7mdfre7at/Masterly.NonEmptyList/actions/workflows/publish.yml)\n\n## Give a Star! :star:\n\nIf you like or are using this project please give it a star. Thanks!\n\n## Features\n\n- **Non-Empty Guarantee**: Always contains at least one element\n- **Head/Tail Access**: Convenient `Head`, `Tail`, `Init`, `First`, and `Last` properties\n- **Functional Operations**: `Map`, `FlatMap`, `Reduce`, `Fold`, `Zip`, `Partition`, and more\n- **Pattern Matching**: `Match` method and deconstruction support\n- **Async Support**: Full async extension methods for all operations\n- **Immutable Variant**: `ImmutableNonEmptyList\u003cT\u003e` for thread-safe scenarios\n- **JSON Serialization**: Built-in System.Text.Json support\n- **EF Core Integration**: Entity Framework Core support via separate package\n- **Equality Support**: Implements `IEquatable\u003cT\u003e` with `==` and `!=` operators\n- **Multi-targeting**: Supports .NET 6.0 and .NET 8.0\n\n## Installation\n\n```bash\ndotnet add package Masterly.NonEmptyList\n```\n\nOr via Package Manager Console:\n```\nInstall-Package Masterly.NonEmptyList\n```\n\n## Quick Start\n\n```csharp\nusing Masterly.NonEmptyList;\n\n// Create a NonEmptyList - guaranteed to have at least one element\nNonEmptyList\u003cint\u003e numbers = new(1, 2, 3, 4, 5);\n\nConsole.WriteLine(numbers.Head);  // 1\nConsole.WriteLine(numbers.Last);  // 5\nConsole.WriteLine(numbers.Tail);  // [2, 3, 4, 5]\n\n// Functional operations\nNonEmptyList\u003cstring\u003e strings = numbers.Map(x =\u003e x.ToString());\nint sum = numbers.Reduce((a, b) =\u003e a + b);\n\n// Pattern matching\nstring result = numbers.Match(\n    single: x =\u003e $\"Just {x}\",\n    multiple: (head, tail) =\u003e $\"Head: {head}, Count: {tail.Count + 1}\"\n);\n\n// Safe from empty collection errors\nint first = numbers.Head;  // Always safe - no exceptions!\n```\n\n## Documentation\n\nFor comprehensive documentation, see the **[Wiki](../../wiki)**.\n\n### Quick Links\n\n| Topic | Description |\n|-------|-------------|\n| [Getting Started](../../wiki/Getting-Started) | Installation and basic usage |\n| [Core Concepts](../../wiki/Core-Concepts) | Head, Tail, and properties |\n| [Creating NonEmptyList](../../wiki/Creating-NonEmptyList) | Constructors and factory methods |\n| [Functional Operations](../../wiki/Functional-Operations) | Map, FlatMap, Reduce, Fold, Zip |\n| [Pattern Matching](../../wiki/Pattern-Matching) | Match and deconstruction |\n| [Collection Operations](../../wiki/Collection-Operations) | Concat, Reverse, Sliding, Chunks |\n| [Async Operations](../../wiki/Async-Operations) | MapAsync, FilterAsync, FoldAsync |\n| [ImmutableNonEmptyList](../../wiki/ImmutableNonEmptyList) | Thread-safe immutable variant |\n| [JSON Serialization](../../wiki/JSON-Serialization) | System.Text.Json support |\n| [EF Core Integration](../../wiki/EF-Core-Integration) | Entity Framework Core support |\n\n## EF Core Integration\n\nFor Entity Framework Core support, install the separate package:\n\n```bash\ndotnet add package Masterly.NonEmptyList.EntityFrameworkCore\n```\n\n```csharp\n// Store NonEmptyList as JSON\nmodelBuilder.Entity\u003cProduct\u003e()\n    .Property(p =\u003e p.Tags)\n    .HasNonEmptyListConversion();\n\n// Configure relationships\nmodelBuilder.Entity\u003cOrder\u003e()\n    .HasNonEmptyManyWithOne(o =\u003e o.Items, i =\u003e i.Order);\n```\n\nSee the [EF Core Integration wiki page](../../wiki/EF-Core-Integration) for full documentation.\n\n## License\n\nMIT\n\n**Free Software, Hell Yeah!**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa7mdfre7at%2Fmasterly.nonemptylist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa7mdfre7at%2Fmasterly.nonemptylist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa7mdfre7at%2Fmasterly.nonemptylist/lists"}