{"id":30429811,"url":"https://github.com/sdaves/simplemonads","last_synced_at":"2025-08-22T17:36:54.947Z","repository":{"id":57467569,"uuid":"303831046","full_name":"sdaves/simplemonads","owner":"sdaves","description":"Easy to use monads (containers), with pattern matching, that improve the quality of your python code. Use Just to end checking for None, Success to end unhandled exceptions, Future for async, and Reader for dependencies.","archived":false,"fork":false,"pushed_at":"2020-10-28T07:48:16.000Z","size":874,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-23T04:43:33.206Z","etag":null,"topics":["dependency-injection","fp","functional-programming","futures","monads","python","reader","unhandled-exceptions"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sdaves.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":"2020-10-13T21:18:01.000Z","updated_at":"2021-03-21T22:59:40.000Z","dependencies_parsed_at":"2022-09-17T16:12:20.500Z","dependency_job_id":null,"html_url":"https://github.com/sdaves/simplemonads","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/sdaves/simplemonads","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdaves%2Fsimplemonads","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdaves%2Fsimplemonads/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdaves%2Fsimplemonads/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdaves%2Fsimplemonads/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sdaves","download_url":"https://codeload.github.com/sdaves/simplemonads/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdaves%2Fsimplemonads/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271673564,"owners_count":24800717,"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","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"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":["dependency-injection","fp","functional-programming","futures","monads","python","reader","unhandled-exceptions"],"created_at":"2025-08-22T17:36:53.699Z","updated_at":"2025-08-22T17:36:54.937Z","avatar_url":"https://github.com/sdaves.png","language":"HTML","readme":"# [simplemonads](https://sdaves.github.io/simplemonads/)\n\nLet's make monads easy, fun, and productive.\n\n## Platform support\n\nJust `pip install simplemonads` and you're done. You can also download [this single file](https://sdaves.github.io/simplemonads/tests/simplemonads.py) into your project and use it as you wish without dependencies. Works across all platforms, so CPython \u003e= 3.5 (Windows, Linux, Mac, Android, iOS), in a [single standalone html](https://sdaves.github.io/simplemonads/tests/test_brython_standalone.html) file, multiple files in the browser with [dynamic loading](https://sdaves.github.io/simplemonads/tests/index.html), and [even on microcontrollers with micropython](https://micropython.org).\n\n## Docs\n\n[Read the docs here.](https://sdaves.github.io/simplemonads/docs/)\n\n## Example GUI using monads: `Success`, `Failure`, `Just`, `Reader`, and `Printer`\n\n![Screenshot of test_reader.py](https://sdaves.github.io/simplemonads/docs/test_reader.png)\n\n```python\nimport simplemonads as sm\n\ntry:\n\n    class Deps(sm.Protocol):\n        \"Dependencies for your application\"\n\n        def popup(self, msg: str) -\u003e None:\n            \"Display a popup with the specified message.\"\n\n\nexcept:\n    pass\n\n\n@sm.run\nclass TestReader:\n    @classmethod\n    def make(cls, create: \"sm.Callable[[],sm.Any]\") -\u003e \"sm.Callable[[],Deps]\":\n        gui = create()\n\n        class GuiDeps:\n            def popup(self, x: str):\n                gui.Popup(x)\n\n        return GuiDeps\n\n    @classmethod\n    def app(cls, divide_by_zero: bool = False) -\u003e sm.Reader:\n        data = sm.Success(sm.Just(7))\n        double = lambda x: x + (lambda y: y * 2)\n        triple = lambda x: x + (lambda y: y * 3)\n        result = data + triple + double\n\n        if divide_by_zero:\n            result += lambda x: x + (lambda x: x / 0)\n\n        def effect(deps: \"Deps\") -\u003e \"sm.Monad\":\n            msg = \"Answer to the Universe: \"\n            err = \"Whoops, an error happened: \"\n            result | {\n                sm.Success: lambda x: x\n                | {sm.Just: lambda val: deps.popup(msg + str(val))},\n                sm.Failure: lambda x: deps.popup(err + x),\n            }\n            return result\n\n        return sm.Reader(effect)\n\n    @classmethod\n    def main(cls):\n        gui = sm.Success() + (lambda x: __import__(\"PySimpleGUI\")) | {\n            sm.Success: lambda x: x,\n            sm.Failure: lambda x: sm.Printer(),\n        }\n\n        return cls.app() + cls.make(lambda: gui)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdaves%2Fsimplemonads","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsdaves%2Fsimplemonads","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdaves%2Fsimplemonads/lists"}