The hierarchy library is an opinionated Clojure library primarily designed to enhance the built-in hierarchy functions, it removes the constraints that the hierarchy relationship's parent must be a namespace-qualified symbol or keyword and or that child must be either a namespace-qualified symbol or keyword or a class.
Here's are a couple of examples.
(ns user
(:require [hierarchy.core :as h]))
;;; using with a hierarchy
(-> (make-hierarchy)
(h/derive+ :bar [:that "thing"])
(h/derive+ :foo :bar)
(isa? :foo [:that "thing"])) ;; => true
;;; using global hierarchy via `derive+` and `underive+` directly
(h/derive+ :bar [:that "thing"])
(h/derive+ :foo :bar)
(isa? :foo [:that "thing"]) ;; => true
;;; using global hierarchy with redef'd `derive` and `underive` using `bound`
(h/bound ;;; this allows more precise use where needed
(derive :bar [:that "thing"])
(derive :foo :bar)
(isa? :foo [:that "thing"])) ;; => true
;;; using global hierarchy with altered `derive` and `underive` vars using `activate!`
(h/activate!) ;;; your application can activate global bindings
(derive :bar [:that "thing"])
(derive :foo :bar)
(isa? :foo [:that "thing"]) ;; => true
(h/deactivate!) ;;; this exists mainly for testing
See the existing tests for more examples.
hierarchy is built, tested, and deployed using Clojure Tools Deps.
GNU Make is used to simplify invocation of some commands.
hierarchy releases for this project are on Clojars. Simply add the following to your project:
- For any other questions or issues about hierarchy free to browse or open a Github Issue.
See CONTRIBUTING.md
YourKit supports open source projects with innovative and intelligent tools for monitoring and profiling Java and .NET applications. YourKit is the creator of YourKit Java Profiler, YourKit .NET Profiler, and YourKit YouMonitor.
Copyright 2024 Jose Gomez
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.