{"id":22408349,"url":"https://github.com/phmatray/monads","last_synced_at":"2025-03-27T01:44:13.281Z","repository":{"id":261818480,"uuid":"885436569","full_name":"phmatray/Monads","owner":"phmatray","description":"Read my post on LinkedIn: https://www.linkedin.com/pulse/monads-c-rigorous-exploration-practical-examples-philippe-matray--gm7qe/","archived":false,"fork":false,"pushed_at":"2024-11-08T19:56:54.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T07:27:53.212Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phmatray.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-08T15:25:57.000Z","updated_at":"2024-11-08T19:56:58.000Z","dependencies_parsed_at":"2024-11-08T16:36:12.142Z","dependency_job_id":"2a2c264c-654e-47f6-b94f-12364800e09b","html_url":"https://github.com/phmatray/Monads","commit_stats":null,"previous_names":["phmatray/monads"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phmatray%2FMonads","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phmatray%2FMonads/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phmatray%2FMonads/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phmatray%2FMonads/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phmatray","download_url":"https://codeload.github.com/phmatray/Monads/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245767274,"owners_count":20668822,"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":[],"created_at":"2024-12-05T11:17:21.425Z","updated_at":"2025-03-27T01:44:13.263Z","avatar_url":"https://github.com/phmatray.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Monads in C#\n\n## Overview\n\nWelcome to the **Monads in C#** project! 🎉 This repository provides a practical example of how monad-like patterns can be implemented in C# to enhance code quality, modularity, and side effect management. If you've heard about monads in functional programming and wondered how they could benefit your C# projects, you're in the right place.\n\n## What Are Monads?\n\nMonads are a powerful concept from functional programming that helps manage transformations and side effects in a clean and predictable way. By encapsulating values and their associated operations, monads allow for clear and composable code—making even complex workflows more maintainable. In C#, we can adapt monad-like patterns to achieve similar results.\n\n## Features\n\n- **Transformations**: Apply a series of operations to a value while keeping your code organized.\n- **Side Effect Management**: Manage logs or other side effects through each transformation without cluttering your logic.\n- **Modularity**: Break down operations into composable units that can be easily tested and reused.\n\n## Example\n\nThe code in this repository demonstrates how to implement a simple monad-like wrapper, `NumberWithLogs`, that allows you to:\n\n1. **Wrap a Value**: Start by wrapping an initial value to create a `NumberWithLogs` instance.\n2. **Apply Transformations**: Use functions like `AddOne`, `Square`, or `MultiplyByThree` to transform the value while collecting logs.\n3. **Chaining Operations**: Sequentially chain multiple transformations to achieve your desired result.\n\nHere's a brief look at the example:\n\n```csharp\nvar result = RunWithLogsMultiple(WrapWithLogs(5), AddOne, Square, MultiplyByThree);\nPrintResult(result);\n```\n\nIn this example, we start with the value `5`, add `1`, square the result, and then multiply by `3`, all while maintaining a clear log of each step.\n\n## How to Use\n\n1. **Clone the Repository**\n   ```\n   git clone https://github.com/yourusername/monads-in-csharp.git\n   ```\n2. **Open the Project**\n   Open the project in your favorite C# editor, such as Visual Studio or VS Code.\n3. **Run the Example**\n   Build and run the project to see how the transformations and logs work together.\n\n## To Go Further\n\nIf you'd like to explore more about monads and their use in functional programming, check out these resources:\n\n- [Monads in C#: A Rigorous Exploration with Practical Examples (LinkedIn)](https://www.linkedin.com/pulse/monads-c-rigorous-exploration-practical-examples-philippe-matray--gm7qe/)\n- [The Absolute Best Intro to Monads For Software Engineers (YouTube)](https://www.youtube.com/watch?v=C2w45qRc3aU)\n- [Monad (functional programming) on Wikipedia](https://en.wikipedia.org/wiki/Monad_(functional_programming))\n\n## Contributing\n\nContributions are welcome! Feel free to open issues or submit pull requests to enhance the project, add more examples, or improve documentation.\n\n## License\n\nThis project is licensed under the MIT License. See the `LICENSE` file for more details.\n\n## Contact\n\nIf you have any questions or suggestions, feel free to reach out or create an issue in the repository.\n\nHappy coding! 🚀\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphmatray%2Fmonads","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphmatray%2Fmonads","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphmatray%2Fmonads/lists"}