Skip to content

Instantly share code, notes, and snippets.

@RickMoynihan
Last active January 4, 2017 09:55
Show Gist options
  • Save RickMoynihan/0a1ce7ef9b96ff3df2e07607dc8f00a1 to your computer and use it in GitHub Desktop.
Save RickMoynihan/0a1ce7ef9b96ff3df2e07607dc8f00a1 to your computer and use it in GitHub Desktop.
(def h (atom (make-hierarchy)))
(defmulti foo identity :hierarchy h)
(defmethod foo :foo [_] :foo)
(defmethod foo :bar [_] :bar)
(swap! h derive :foo-child :foo)
(swap! h derive :bar-child :bar)
;; h => #atom[{:parents {:foo-child #{:foo}, :bar-child #{:bar}}, :ancestors {:foo-child #{:foo}, :bar-child #{:bar}}, :descendants {:foo #{:foo-child}, :bar #{:bar-child}}} 0x6221100a]
(comment
(foo :foo-child) ;; => :foo
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment