{"id":15482893,"url":"https://github.com/brandonbloom/dispatch-map","last_synced_at":"2025-04-12T18:36:03.298Z","repository":{"id":5871750,"uuid":"7089113","full_name":"brandonbloom/dispatch-map","owner":"brandonbloom","description":"Persistent map with Clojure's multimethod dispatch semantics","archived":false,"fork":false,"pushed_at":"2024-06-05T05:00:04.000Z","size":21,"stargazers_count":29,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T12:51:15.398Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brandonbloom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2012-12-10T07:10:09.000Z","updated_at":"2024-06-05T05:00:08.000Z","dependencies_parsed_at":"2024-11-07T17:03:06.249Z","dependency_job_id":"48892b0c-16dd-4a2c-96cc-9dbbc1b37f92","html_url":"https://github.com/brandonbloom/dispatch-map","commit_stats":{"total_commits":25,"total_committers":2,"mean_commits":12.5,"dds":"0.040000000000000036","last_synced_commit":"030df9864860f78804488ba6727692292e5e0fbd"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandonbloom%2Fdispatch-map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandonbloom%2Fdispatch-map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandonbloom%2Fdispatch-map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandonbloom%2Fdispatch-map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brandonbloom","download_url":"https://codeload.github.com/brandonbloom/dispatch-map/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248615577,"owners_count":21133903,"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-02T05:10:16.863Z","updated_at":"2025-04-12T18:36:03.275Z","avatar_url":"https://github.com/brandonbloom.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dispatch-map\n\nA Clojure library which provides the internals of Clojure's multimethods as a persistent, immutible map implementation.\n\nAlso includes an implementation of the multimethod macros and functions in terms of a dispatch-map and an atom.\n\n## Motivation\n\nSee https://www.brandonbloom.name/blog/2012/12/10/clojures-multimethod-dispatch-as-library/\n\n\n## Example\n\n```clojure\n(require '[dispatch-map.core :refer (dispatch-map)])\n\n(derive ::rect ::shape)\n(let [m (-\u003e (dispatch-map identity\n              [::rect ::shape] :rect-shape\n              [::shape ::rect] :shape-rect)\n            (prefer [::rect ::shape] [::shape ::rect]))]\n  (println (m [::rect ::rect]))\n  (println (m [::shape ::rect]))\n  (println (m [::rect ::circle] :not-found)))\n```\n\nPrints:\n\n```\n:rect-shape\n:shape-rect\n:not-found\n```\n\n\n## IHierarchy Abstraction\n\nJava's type hierarchy gets special treatment in Clojure's native multimethods via the `isa?` function.\n\nYou can now get similarly special treatment by implementing the  `-isa` method on the `dispatch-map.hierarchy/IHierarchy` protocol.\nThis is useful if you have a hiearchy defined by some other means that you don't wish to manually reproduce by successive calls to `derive`.\n\nSee [the tests](https://github.com/brandonbloom/dispatch-map/blob/93631c/test/dispatch_map/core_test.clj#L76-86) for an example.\n\nNote that your `-isa` method must produce a result that is safe to memoize.\n\n\n## DispatchMapFn\n\nThis is how you use the custom multimethod implementation. The only compelling reason to prefer this over\nClojure's native MultiFn or a raw dispatch-map is if you need to provide a custom IHierarchy implementation.\n\n```clojure\n(ns your-ns\n  (:refer-clojure :exclude [defmulti defmethod remove-all-methods remove-method\n                            prefer-method methods get-method prefers])\n  (:use [dispatch-map.multi-fn])))\n```\n\n\n## License\n\nCopyright © 2012 Brandon Bloom\n\nDistributed under the Eclipse Public License, the same as Clojure.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrandonbloom%2Fdispatch-map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrandonbloom%2Fdispatch-map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrandonbloom%2Fdispatch-map/lists"}