{"id":13507309,"url":"https://github.com/rob-brown/MonadEx","last_synced_at":"2025-03-30T07:32:42.857Z","repository":{"id":28030441,"uuid":"31525784","full_name":"rob-brown/MonadEx","owner":"rob-brown","description":"Upgrade your pipelines with monads.","archived":false,"fork":false,"pushed_at":"2021-10-27T23:47:51.000Z","size":41,"stargazers_count":306,"open_issues_count":1,"forks_count":13,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-10-01T21:17:59.341Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/rob-brown.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":"2015-03-02T06:05:45.000Z","updated_at":"2024-08-03T05:17:25.000Z","dependencies_parsed_at":"2022-09-04T07:31:29.453Z","dependency_job_id":null,"html_url":"https://github.com/rob-brown/MonadEx","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rob-brown%2FMonadEx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rob-brown%2FMonadEx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rob-brown%2FMonadEx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rob-brown%2FMonadEx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rob-brown","download_url":"https://codeload.github.com/rob-brown/MonadEx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222535162,"owners_count":16999232,"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-08-01T02:00:30.845Z","updated_at":"2024-11-01T06:31:40.091Z","avatar_url":"https://github.com/rob-brown.png","language":"Elixir","funding_links":[],"categories":["Algorithms and Data structures","Elixir"],"sub_categories":[],"readme":"# MonadEx\n\n## Summary\n\n`MonadEx` introduces monads into Elixir. Monads encapsulate state and control the flow of code. A monad's bind operation is similar, but more powerful, than Elixir's built-in pipelines.\n\n## Usage\n\n### Included Monads\n\n1. Maybe\n  - A simple container representing either something or nothing.\n2. Result\n  - A container representing success or failure.\n3. List\n  - Lists are naturally monads, and conform to the necessary protocols.\n4. Writer\n  - Keeps a log in addition to tracking a value. The log may be a string, array, or any other 'Monoid'.\n5. Reader\n  - Holds a shared, environment state.\n6. State\n  - Also holds a shared environment state in addition to tracking a value.\n\n### Extending Monads\n\nMonads may easily be extending by one of two ways:\n\n1. Use the provided `Monad.Behaviour`.\n  1. Call `use Monad.Behaviour` first in your monad.\n  2. Implement `return/1`.\n  3. Implement `bind/2`.\n2. Conform to the `Monad` protocol. Additionally, you should conform to the `Functor` and `Applicative` protocols.\n\n### Composing Monads\n\nMonads may be combined to make even more useful constructs. For example, you may want to use a state monad in combination with a result monad. The state monad can track a shared environment and the result monad can keep track of the success or failure state.\n\n### Other Useful Monads\n\n`MonadEx` does not contain the following monads, but they may be useful in some situations. These monads and others may be added later.\n\n1. IO\n2. Continuation\n3. Random number generation\n4. Memoization\n\n## Resources for Understanding Monads\n\n* [Functors, Applicatives, and Monads in Pictures](http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html)\n* [Three Useful Monads](http://adit.io/posts/2013-06-10-three-useful-monads.html)\n* [Functors, Applicative Functors, and Monoids](http://learnyouahaskell.com/functors-applicative-functors-and-monoids)\n* [A Fistful of Monads](http://learnyouahaskell.com/a-fistful-of-monads)\n* [A Few Monads More](http://learnyouahaskell.com/for-a-few-monads-more)\n* [Category Theory for Beginners](http://www.slideshare.net/kenbot/category-theory-for-beginners)\n* [Functional Programming Patterns](http://www.slideshare.net/ScottWlaschin/fp-patterns-buildstufflt)\n* [Haskell Docs](https://wiki.haskell.org/Monad)\n* [Wikipedia](https://en.wikipedia.org/wiki/Monad_(functional_programming))\n\n## Troubleshooting\n\nMany of the problems that arise with monads is first not understanding functors,\napplicatives, and monads. See the listed resources for learning more about\nthese concepts.\n\nAnother gotcha to watch out for is omitting parentheses. Omitting unnecessary\nparentheses is a great feature; however, just like Elixir's built-in pipelines,\nforgetting parentheses can create ambiguity and unexpected results. For example,\nthe following (contrived) code is ambiguous:\n\n    monad\n    ~\u003e\u003e transform flag\n    ~\u003e\u003e process :all\n\nIt should instead be replaced with:\n\n    monad\n    ~\u003e\u003e transform(flag)\n    ~\u003e\u003e process(:all)\n\n## Contributing\n\nCode contributions are welcomed. In order to maintain the integrity of the\nproject, all pull requests must contain documentation and unit tests. See the\nexisting tests and documentation for examples. Some easy ideas to contribute is\nto add more types of monads.\n\n## License\n\n`MonadEx` is licensed under the MIT license, which is reproduced in its entirety here:\n\n\u003eCopyright (c) 2015–2016 Robert Brown\n\u003e\n\u003ePermission is hereby granted, free of charge, to any person obtaining a copy\n\u003eof this software and associated documentation files (the \"Software\"), to deal\n\u003ein the Software without restriction, including without limitation the rights\n\u003eto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\u003ecopies of the Software, and to permit persons to whom the Software is\n\u003efurnished to do so, subject to the following conditions:\n\u003e\n\u003eThe above copyright notice and this permission notice shall be included in\n\u003eall copies or substantial portions of the Software.\n\u003e\n\u003eTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\u003eIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\u003eFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\u003eAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\u003eLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\u003eOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\u003eTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frob-brown%2FMonadEx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frob-brown%2FMonadEx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frob-brown%2FMonadEx/lists"}