{"id":17159142,"url":"https://github.com/scull7/bs-result","last_synced_at":"2025-04-13T13:42:24.803Z","repository":{"id":56046459,"uuid":"130012090","full_name":"scull7/bs-result","owner":"scull7","description":"A Result type implementation for ReasonML","archived":false,"fork":false,"pushed_at":"2020-11-29T02:15:39.000Z","size":656,"stargazers_count":4,"open_issues_count":3,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T14:45:37.261Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://scull7.github.io/bs-result/","language":"OCaml","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/scull7.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":"2018-04-18T06:06:44.000Z","updated_at":"2020-04-23T01:16:35.000Z","dependencies_parsed_at":"2022-08-15T12:10:20.680Z","dependency_job_id":null,"html_url":"https://github.com/scull7/bs-result","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scull7%2Fbs-result","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scull7%2Fbs-result/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scull7%2Fbs-result/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scull7%2Fbs-result/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scull7","download_url":"https://codeload.github.com/scull7/bs-result/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248724490,"owners_count":21151557,"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-10-14T22:13:27.662Z","updated_at":"2025-04-13T13:42:24.781Z","avatar_url":"https://github.com/scull7.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://www.travis-ci.org/scull7/bs-result.svg?branch=master)](https://www.travis-ci.org/scull7/bs-result)\n[![Coverage Status](https://coveralls.io/repos/github/scull7/bs-result/badge.svg?branch=master)](https://coveralls.io/github/scull7/bs-result?branch=master)\n\n# bs-result\nMonadic interface for [Belt.Result][belt-result]\n\nThis implementation is inspired by [JavaScript Fantasy Land][fantasy-land]\nand closely follows the [Funfix.org Either][funfix-either] implementation.\n\n## Installation\n1. Install the `bs-result` package.\n```sh\nyarn add bs-result\n```\n2. Add `bs-result` to your `bsconfig.json`\n```json\n{\n  \"dependencies\": [\n    \"bs-result\"\n  ]\n}\n```\n\n### Usage\n\n### Basic\n```reason\nlet r =\n  Result.return(20)\n  |\u003e Result.map(x =\u003e x + 20)\n  |\u003e Result.flatMap(x =\u003e Result.return(x + 2))\n  |\u003e Result.getOrElse(-1);\nJs.log2(\"Result: \", r);\n```\n\n### Integrations\n\n#### [Belt.Result][belt-result]\n```reason\nlet r =\n  Belt.Result.Ok(x =\u003e x + 10)\n  |\u003e Result.ap(Result.return(20))\n  |\u003e Belt.Result.map(_, x =\u003e x + 10)\n  |\u003e Result.flatMap(x =\u003e Belt.Result.Ok(x + 2))\n  |\u003e Belt.Result.getWithDefault(_, -1);\nJs.log2(\"Result: \", r);\n```\n\n#### [Js.Promise][js-promise]\n```reason\n  Js.Promise.resolve(20)\n  |\u003e Js.Promise.then_(x =\u003e Result.Promise.return(x))\n  |\u003e Result.Promise.flatMap(x =\u003e Result.return(x + 10))\n  |\u003e Result.Promise.map(x =\u003e x + 10)\n  |\u003e Result.Promise.andThen(x =\u003e\n       x + 2 |\u003e Result.return |\u003e Js.Promise.resolve\n     )\n  |\u003e Result.Promise.unsafeResolve\n  |\u003e Js.Promise.then_(result =\u003e {\n       Js.log2(\"Result: \", result);\n       Js.Promise.resolve();\n     })\n```\n\n### [Full API Docs](api/Result.html)\n\n## TODO\n* [ ] Integration with [reason-future].\n* [ ] Comonad implementation - functions are mis-named.\n\n\n[funfix-core]: https://funfix.org/api/core/classes/either.html\n[funfix-either]: https://funfix.org/api/core/classes/either.html\n[sanctuaryjs-either]: https://sanctuary.js.org/#either-type\n[fluture]: https://github.com/fluture-js/Fluture\n[elm-task]: http://package.elm-lang.org/packages/elm-lang/core/latest/Task\n[fantasy-land]: https://github.com/fantasyland/fantasy-land\n[belt-result]: https://bucklescript.github.io/bucklescript/api/Belt.Result.html\n[js-promise]: https://bucklescript.github.io/bucklescript/api/Js.Promise.html\n[reason-future]: https://github.com/rationaljs/future\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscull7%2Fbs-result","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscull7%2Fbs-result","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscull7%2Fbs-result/lists"}