{"id":14966000,"url":"https://github.com/rawleyfowler/monad-result","last_synced_at":"2025-10-25T13:30:54.315Z","repository":{"id":132530742,"uuid":"583953570","full_name":"rawleyfowler/Monad-Result","owner":"rawleyfowler","description":"Result monad for Raku","archived":false,"fork":false,"pushed_at":"2024-01-06T19:58:21.000Z","size":24,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T07:11:49.711Z","etag":null,"topics":["functional-programming","monad","raku"],"latest_commit_sha":null,"homepage":"","language":"Raku","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"artistic-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rawleyfowler.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-31T16:08:14.000Z","updated_at":"2024-10-10T17:12:02.000Z","dependencies_parsed_at":"2024-09-14T01:22:10.527Z","dependency_job_id":"52131724-b6f9-4583-ba68-e6819b4dd674","html_url":"https://github.com/rawleyfowler/Monad-Result","commit_stats":{"total_commits":16,"total_committers":2,"mean_commits":8.0,"dds":0.375,"last_synced_commit":"11f37f4044fd56d97db3e5af6a8dc8c8a4b10dc5"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rawleyfowler%2FMonad-Result","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rawleyfowler%2FMonad-Result/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rawleyfowler%2FMonad-Result/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rawleyfowler%2FMonad-Result/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rawleyfowler","download_url":"https://codeload.github.com/rawleyfowler/Monad-Result/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238147563,"owners_count":19424284,"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":["functional-programming","monad","raku"],"created_at":"2024-09-24T13:35:40.463Z","updated_at":"2025-10-25T13:30:54.006Z","avatar_url":"https://github.com/rawleyfowler.png","language":"Raku","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Monad-Result\n\n[![SparrowCI](https://ci.sparrowhub.io/project/gh-rawleyfowler-Monad-Result/badge?)](https://ci.sparrowhub.io)\n\nAn implementation of the result monad from OCaml. This allows the developer to completely avoid exceptions.\nNote the result type is not generic, and cannot be statically typed. I think this makes it more flexible overall, \ncompared to OCaml's result monad. (Gradual typing ftw)!\n\n## How to use (default)\n```raku\nuse Monad::Result;\n\nsub my-error-causing-function($value --\u003e Monad::Result) {\n  return Monad::Result.error('Bad value!') if $value eq 'bad';\n  Monad::Result.ok('Value was good!');\n}\n\n# Bind operator: \u003e\u003e=:\nmy-error-causing-function('bad') \u003e\u003e=: -\u003e $value {\n  say $value; # Is not called because this is not bindable (it is an error!)\n  return Monad::Result.ok($value);\n};\n\nmy-error-causing-function('abc') \u003e\u003e=: -\u003e $value {\n  say $value; # Is said because this is bindable, it is OK!\n  return Monad::Result.ok($value);\n};\n\n# Map operator: \u003e\u003e=?\n# Since this call results in OK, we can map it!\nmy $result = (my-error-causing-function('abc') \u003e\u003e=? -\u003e $value {\n  $value ~ ' HELLO WORLD';\n}); # Results Ok('abc HELLO WORLD');\n\nsay $result.is-ok; # True\n# NOTE UNWRAP IS DANGEROUS (In this case we know it's okay though!)\nsay $result.unwrap; # 'abc HELLO WORLD';\n```\n\n## How to use (subs)\n\nSubs exist as a separate import, because they interfere with a lot of common packages.\n\n```raku\nuse Monad::Result :subs;\n\nsub my-error-causing-function($value --\u003e Monad::Result) {\n  return error('Bad value!') if $value eq 'bad';\n  ok('Value was good!');\n}\n\n# Bind operator: \u003e\u003e=:\nmy-error-causing-function('bad') \u003e\u003e=: -\u003e $value {\n  say $value; # Is not called because this is not bindable (it is an error!)\n  return ok($value);\n};\n\nmy-error-causing-function('abc') \u003e\u003e=: -\u003e $value {\n  say $value; # Is said because this is bindable, it is OK!\n  return ok($value);\n};\n\n# Map operator: \u003e\u003e=?\n# Since this call results in OK, we can map it!\nmy $result = (my-error-causing-function('abc') \u003e\u003e=? -\u003e $value {\n  $value ~ ' HELLO WORLD';\n}); # Results Ok('abc HELLO WORLD');\n\nsay $result.is-ok; # True\n# NOTE UNWRAP IS DANGEROUS!\nsay $result.unwrap; # 'abc HELLO WORLD';\n```\n\n## How to install\n```bash\nzef install Monad-Result\n```\n\n## LICENSE\nMonad::Result is provided under the Artistic-2.0 license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frawleyfowler%2Fmonad-result","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frawleyfowler%2Fmonad-result","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frawleyfowler%2Fmonad-result/lists"}