{"id":13430536,"url":"https://github.com/la-yumba/functional-csharp-code","last_synced_at":"2026-01-14T05:54:53.438Z","repository":{"id":38956657,"uuid":"56557809","full_name":"la-yumba/functional-csharp-code","owner":"la-yumba","description":"Code samples for Functional Programming in C#","archived":false,"fork":false,"pushed_at":"2022-12-07T16:48:25.000Z","size":314,"stargazers_count":607,"open_issues_count":10,"forks_count":183,"subscribers_count":61,"default_branch":"master","last_synced_at":"2025-08-22T11:59:11.117Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/la-yumba.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-19T02:23:37.000Z","updated_at":"2025-08-04T15:13:31.000Z","dependencies_parsed_at":"2023-01-24T19:18:04.763Z","dependency_job_id":null,"html_url":"https://github.com/la-yumba/functional-csharp-code","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/la-yumba/functional-csharp-code","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/la-yumba%2Ffunctional-csharp-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/la-yumba%2Ffunctional-csharp-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/la-yumba%2Ffunctional-csharp-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/la-yumba%2Ffunctional-csharp-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/la-yumba","download_url":"https://codeload.github.com/la-yumba/functional-csharp-code/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/la-yumba%2Ffunctional-csharp-code/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28412026,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T05:26:33.345Z","status":"ssl_error","status_checked_at":"2026-01-14T05:21:57.251Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-07-31T02:00:54.974Z","updated_at":"2026-01-14T05:54:53.421Z","avatar_url":"https://github.com/la-yumba.png","language":"C#","readme":"# Functional Programming in C# #\r\n\r\nThis repo contains the code samples, exercises and solutions for the book\r\n[Functional Programming in C#](https://www.manning.com/books/functional-programming-in-c-sharp?a_aid=functional-programming-in-c-sharp\u0026a_bid=ad9af506)\r\npublished by Manning.\r\n\r\n[![Functional Programming in C#](cover.jpg)](https://www.manning.com/books/functional-programming-in-c-sharp?a_aid=functional-programming-in-c-sharp\u0026a_bid=ad9af506)\r\n\r\nThe code samples are organized in the following projects:\r\n\r\n- **Examples**: examples used throughout the book, by chapter\r\n- **Exercises**: placeholders for you to do the exercises, compile and run them;\r\n  and compare to the provided solutions\r\n- **LaYumba.Functional**: a functional library that we develop throughout the book\r\n- **LaYumba.Functional.Data**: very simple functional data structures discussed in Chapter 9\r\n- **LaYumba.Functional.Tests**: also illustrative of topics explained in the book, and\r\n  useful to better understand the constructs in the library\r\n- **Boc.Domain**: an example of using F# for domain objects\r\n\r\n**Note:** you are welcome to reference `LaYumba.Functional` from your projects\r\nvia [NuGet](https://www.nuget.org/packages/LaYumba.Functional), and submit\r\nPRs with improvements, but the main intent of this library is pedagogical.\r\nFor a more fully-fledged functional library, consider [LanguageExt](https://github.com/louthy/language-ext)\r\n\r\n## Working with the code samples\r\n\r\nThe code samples use .NET Standard 1.6 and .NET Core 2.0, and should compile and run on all major OS's\r\nvia the `dotnet` CLI.\r\n\r\n### Prerequisites\r\n\r\n- [.NET Core 2.0.3 SDK](https://www.microsoft.com/net/download/core)\r\n\r\nTo check this is available, type `dotnet --version` at the command prompt, and you should get `2.0.3` or greater\r\n\r\n### One-time setup\r\n\r\n```\r\n$ git clone git@github.com:la-yumba/functional-csharp-code.git\r\n$ cd functional-csharp-code\r\n$ dotnet restore\r\n```\r\n\r\n### Running the tests\r\n\r\nUse the `dotnet test` command, for example:\r\n\r\n```\r\n$ cd LaYumba.Functional.Tests\r\n$ dotnet test\r\n```\r\n\r\ntests in the `Exercises` and `Examples` projects can be run in the same way.\r\n\r\n### Running examples\r\n\r\nMany code samples in the book can be run, in case you'd like to debug or \"see that it works\".\r\nThe pattern is:\r\n\r\n```\r\n$ cd Examples\r\n$ dotnet run Greetings\r\n```\r\n\r\n| Section | Command\r\n|---:| ---\r\n| 7.1 | `dotnet run Greetings`\r\n\r\n## Setting up the REPL\r\n\r\nThroughout the book, I encourage readers to try things out in the [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop).\r\n\r\n- If you use Visual Studio, you can start the REPL by going to\r\n`View \u003e Other Windows \u003e C# Interactive` (short tutorial [here](https://github.com/dotnet/roslyn/wiki/C%23-Interactive-Walkthrough))\r\n- On Mono, use the `csharp` command\r\n- There are several other REPLs available, some even run in the browser\r\n\r\nYou'll often need to import `LaYumba.Functional` in the REPL. In C# Interactive,\r\nthis can be done like so:\r\n\r\n```csharp\r\n#r \"functional-csharp-code\\LaYumba.Functional\\bin\\Debug\\netstandard1.6\\LaYumba.Functional.dll\"\r\n```\r\n\r\nThe path above may not work for you, in which case use an absolute path to the dll,\r\nor type `Directory.GetCurrentDirectory()` into the REPL to see what to use as a base for a relative path.\r\n\r\nNext, add these imports:\r\n\r\n```csharp\r\nusing LaYumba.Functional;\r\nusing static LaYumba.Functional.F;\r\n```\r\n\r\nYou're now ready to experiment with functional code right in the REPL, for example:\r\n\r\n```csharp\r\n\u003e Func\u003cint, int, int\u003e plus = (a, b) =\u003e a + b;\r\n\u003e Some(plus).Apply(1).Apply(2)\r\n[Some(3)]\r\n\u003e Some(plus).Apply(1).Apply(None)\r\n[None]\r\n```\r\n\r\n## Doing the exercises\r\n\r\n- edit the code in `Exercises` as needed\r\n- edit `Exercises/Program.cs` to start the class you want\r\n- run it with:\r\n\r\n  ```\r\n  $ cd Exercises\r\n  $ dotnet run\r\n  ```\r\n- run your tests:\r\n\r\n  ```\r\n  $ cd Exercises\r\n  $ dotnet test\r\n  ```\r\n","funding_links":[],"categories":["Frameworks, Libraries and Tools","Libraries, Frameworks and Tools","框架, 库和工具","Functional Programming"],"sub_categories":["Functional Programming","响应式编程"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fla-yumba%2Ffunctional-csharp-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fla-yumba%2Ffunctional-csharp-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fla-yumba%2Ffunctional-csharp-code/lists"}