{"id":15010456,"url":"https://github.com/pablobcb/clj-with","last_synced_at":"2025-09-05T13:46:02.363Z","repository":{"id":91493361,"uuid":"133900557","full_name":"pablobcb/clj-with","owner":"pablobcb","description":"Macro inspired by Elixir's `with` statement","archived":false,"fork":false,"pushed_at":"2019-05-13T16:39:28.000Z","size":22,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T20:37:12.268Z","etag":null,"topics":["clj","clojure","pattern-matching","with"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pablobcb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2018-05-18T03:55:56.000Z","updated_at":"2023-08-28T18:04:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"49dbf357-b518-4830-a486-142b8c2077bc","html_url":"https://github.com/pablobcb/clj-with","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/pablobcb%2Fclj-with","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pablobcb%2Fclj-with/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pablobcb%2Fclj-with/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pablobcb%2Fclj-with/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pablobcb","download_url":"https://codeload.github.com/pablobcb/clj-with/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248088193,"owners_count":21045664,"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":["clj","clojure","pattern-matching","with"],"created_at":"2024-09-24T19:34:22.155Z","updated_at":"2025-04-09T18:33:59.358Z","avatar_url":"https://github.com/pablobcb.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# clj-with\nMacro inspired by Elixir's `with` statement\n\n[![Clojars Project](https://img.shields.io/clojars/v/clj-with.svg)](https://clojars.org/clj-with)\n\nMacro\n\n\n  Chain pattern matching clauses, using `clojure.core.match/match`.  Takes a vector of\n  bindings to match, a body, and optionally an `:otherwise` keyword followed by list\n  of clauses to match in case of failure. \n  Pattern matches each bind and if all\n  clauses match, the body is executed returning its result. Otherwise the chain\n  is aborted and the non-matched value is matched against the optional :else\n  clauses, if provided. Raises `java.lang.IllegalArgumentException` if none\n  of the clauses match, just as `clojure.core.match/match`.  \n  \n  \n  Example:\n```clojure\n(defn f1 [] [:ok 10 20])\n(defn f2 [k] [:ok (inc k)])\n(defn produce-error [] [:error :match-error])\n\n(with [[:ok x y] (f1)\n       [:ok z] (f2 (+ x y))]\n  (do (println \"all clauses have matched :)\")\n      (* z 2))\n      \n  :otherwise \n  [:error err] err\n  \n  :else :no-match)\n;=\u003e 62\n\n(with [[:ok x y] (f1)\n       [:ok z] (produce-error)]\n  (* z 2)\n  \n  :otherwise\n  [:error err] err)\n;=\u003e :match-error\n```\nFor more use cases peek at the `test` folder\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpablobcb%2Fclj-with","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpablobcb%2Fclj-with","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpablobcb%2Fclj-with/lists"}