{"id":16532263,"url":"https://github.com/shahabganji/funx","last_synced_at":"2026-06-08T00:31:47.453Z","repository":{"id":117026522,"uuid":"184643130","full_name":"shahabganji/Funx","owner":"shahabganji","description":"A robust and useful library to use functional programming in C#","archived":false,"fork":false,"pushed_at":"2024-01-28T19:11:08.000Z","size":166,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-31T16:48:21.417Z","etag":null,"topics":["csharp","functional","functional-programming","funx","maybe-monad","option","railway-oriented-programming"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shahabganji.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-05-02T19:55:42.000Z","updated_at":"2025-12-30T15:08:29.000Z","dependencies_parsed_at":"2023-12-05T11:26:42.315Z","dependency_job_id":"d86dab2f-c210-40a2-82b4-cb7785cd9743","html_url":"https://github.com/shahabganji/Funx","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/shahabganji/Funx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahabganji%2FFunx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahabganji%2FFunx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahabganji%2FFunx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahabganji%2FFunx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shahabganji","download_url":"https://codeload.github.com/shahabganji/Funx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahabganji%2FFunx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34043822,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-07T02:00:07.652Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["csharp","functional","functional-programming","funx","maybe-monad","option","railway-oriented-programming"],"created_at":"2024-10-11T18:12:08.346Z","updated_at":"2026-06-08T00:31:47.436Z","avatar_url":"https://github.com/shahabganji.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n## Funx\n\n[![Build status](https://ci.appveyor.com/api/projects/status/qk1e8ph62hektvg4?svg=true)](https://ci.appveyor.com/project/shahabganji/funx) [![codecov](https://codecov.io/gh/dotnet-toolbelt/Funx/branch/master/graph/badge.svg)](https://codecov.io/gh/dotnet-toolbelt/Funx)\n\n\nThis is an functional library for C# developers, all the features are implemented based on what [Enrico](https://github.com/la-yumba) taught in his [Functional Programming in C#](https://www.amazon.com/Functional-Programming-write-better-code/dp/1617293954). I tried to learn them and write one for myself.\n\n\n### Introduction\n\nFunx provides robust and well-tested core basic structs for functional programming in C#, Option and Either. Option represents a possibility of lack of value.\n\n### Installation\n\nEasily install it via [Nuget](https://www.nuget.org/packages/Funx/).\n\n```\nInstall-Package Funx\n\ndotnet add package Funx\n```\n\n\n### Usage\n\n### Option\n\n```csharp\nusing Funx;\n// using static Funx.Helpers; // in some scenarios it may provide better syntax \u0026\u0026 readability\n\nvar none = Option\u003cstring\u003e.None; // or Option\u003cstring\u003e none = None;\nvar author = Option\u003cstring\u003e.Some(\"Enrico\");\n\nvar value = author.Match(() =\u003e \"No Name\", v =\u003e v);\nWriteLine(value); // Enrico\n\nvalue = none.Match(() =\u003e \"No Name\", v =\u003e v);\nWriteLine(value); //  No Name\n```\n\nI would rather to use it in a different way, since all native types can be implicitly cast to Option\u003cT\u003e\n\n```csharp\nusing Funx;\nusing static Funx.Factories;\n\nOption\u003cstring\u003e none = None;\nOption\u003cstring\u003e author = \"Enrico\";\n\nvar value = author.Match(() =\u003e \"No Name\", v =\u003e v);\nWriteLine(value); // Enrico\n\nvalue = none.Match(() =\u003e \"No Name\", v =\u003e v);\nWriteLine(value); //  No Name\n```\n\n\nShould you require more functionality and methods, import `Funx.Extensions` namespace and you'll get a bunch of handy extension method.\n\n```csharp\nusing Funx;\nusing Funx.Extensions;\n\nvar student = new Author { Name = \"Jane\", Age = 17 };\n\nvar isTeenager = student.Where( s =\u003e s.Age \u003c 20 \u0026\u0026 s.Age \u003e 13 );\n\n// ***** OR *********\n\nvar isTeenager = from s in student\n                 where s.Age \u003e 13 \u0026\u0026 s.Age \u003c 20\n                 select s;\n```\n\nIf you want to induce side effects use `ForEach` method, the provided function will be called if a value exists:\n\n```csharp\nOption\u003cint\u003e option = 11;\n\noption.ForEach(WriteLine);\n```\n\nTo map Option\u003cT\u003e to another option use `Map`, and `Bind` functions, the `Map` accepts a function which returns `TR`, and `Bind` accepts a function which returns `Option\u003cTR\u003e`, if we pass the latter function to `Map` will end up with nested Options, like `\u003cOption\u003cOption\u003cTR\u003e\u003e\u003e`, which might not be what we expect:\n\n\n```csharp\nusing Funx.Extensions;\nusing static Funx.Factories;\n\nvar str = Some(\"value\");\n\nstring ToUpper(string v) =\u003e v.ToUpper();\n\nvar upperCase = str.Map(ToUpper); // upperCase is an Option\u003cstring\u003e too.\n\n```\n\n```csharp\nusing Funx;\nusing Funx.Extensions;\nusing static Funx.Factories;\n\nvar str = Some(\"value\");\n\nstring ToUpper(string v) =\u003e v.ToUpper();\n\nOption\u003cstring\u003e IsValid(string v)\n{\n    if (v.StartsWith(\"v\"))\n        return v; // all types can implicitly cast to Option\u003cT\u003e, so simply return them.\n\n    return None;\n}\n\nvar upperCase = str.Bind(IsValid).Map(ToUpper); // here upperCase is Option\u003cstring\u003e, but if we've used Map function it would be Option\u003cOption\u003cstring\u003e\u003e\n\nupperCase.ForEach(WriteLine);\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahabganji%2Ffunx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshahabganji%2Ffunx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahabganji%2Ffunx/lists"}