{"id":20135834,"url":"https://github.com/hcarty/with_return","last_synced_at":"2025-09-21T05:32:25.678Z","repository":{"id":141496207,"uuid":"114051980","full_name":"hcarty/with_return","owner":"hcarty","description":"Early returns in OCaml including syntax sugar","archived":false,"fork":false,"pushed_at":"2018-03-22T17:27:47.000Z","size":5,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T22:23:04.152Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/hcarty.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2017-12-13T00:00:19.000Z","updated_at":"2023-08-14T21:44:38.000Z","dependencies_parsed_at":"2023-07-03T15:31:40.644Z","dependency_job_id":null,"html_url":"https://github.com/hcarty/with_return","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hcarty/with_return","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcarty%2Fwith_return","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcarty%2Fwith_return/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcarty%2Fwith_return/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcarty%2Fwith_return/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hcarty","download_url":"https://codeload.github.com/hcarty/with_return/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcarty%2Fwith_return/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276195633,"owners_count":25601152,"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-09-21T02:00:07.055Z","response_time":72,"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":[],"created_at":"2024-11-13T21:16:41.318Z","updated_at":"2025-09-21T05:32:25.669Z","avatar_url":"https://github.com/hcarty.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"# with\\_return - Early return inside expressions\n\n`with_return` is a tiny library and matching OCaml syntax extension\nimplementing an early return mechanism using exceptions.\n\nThanks to octachron for the initial code living in the `With_return` module.\n\n## Using ppx\\_return\n\nThe bundled ppx syntax extension makes using this functionality syntactically\nlighter.\n\n```ocaml\nlet add_one_if_negative x =\n  (* The name return is used by default *)\n  [%with_return];\n  if x \u003e= 0 then return (Error \"not negative\");\n  Ok (x + 1)\n```\n\nThe name of the value used to return early can be customized if `return` would shadow local names.\n\n```ocaml\nlet add_one_if_negative x =\n   (* Now use ret instead of return *)\n   let myret = [%with_return] in\n   if x \u003e= 0 then myret (Error \"not negative\");\n   Ok (x + 1)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhcarty%2Fwith_return","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhcarty%2Fwith_return","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhcarty%2Fwith_return/lists"}