(ns metabase.lib.hierarchy
  (:refer-clojure :exclude [derive isa?]))

Keyword hierarchy for MLv2 stuff.

(defonce  hierarchy
  (atom (make-hierarchy)))

Like [[clojure.core/derive]], but affects [[hierarchy]] rather than the global hierarchy.

(defn derive
  [tag parent]
  (swap! hierarchy clojure.core/derive tag parent)
  ;; for REPL convenience so we don't dump a lot of garbage
  nil)

Like [[clojure.core/isa?]], but uses [[hierarchy]].

(defn isa?
  [tag parent]
  (clojure.core/isa? @hierarchy tag parent))