Back
simple-dispatch (clj)
(source)multimethod
The pretty print dispatch function for simple data structure format.
Examples
babashka/sci
(ns sci.pprint
"Require this namespace if you want to extend pretty-printing to
records created with SCI."
{:no-doc true}
(:require
[clojure.pprint :as pprint]
[sci.impl.records]
[sci.lang]))
(defmethod pprint/simple-dispatch sci.impl.records.SciRecord [obj]
(if-let [rv (.-var ^sci.impl.records.SciRecord obj)]
(let [m (meta rv)]
(if-let [pm (:sci.impl/pprint-simple-dispatch m)]
(pm obj)
(pprint/simple-dispatch (into {} obj))))
(pprint/simple-dispatch (into {} obj))))
(defmethod pprint/simple-dispatch sci.lang.Var [obj]
(pr obj))
babashka/process
(ns babashka.process.pprint
(:require [babashka.process]
[clojure.pprint :as pprint]))
(defmethod pprint/simple-dispatch babashka.process.Process [proc]
(pprint/pprint (into {} proc)))
reborg/clojure-essential-reference
(require '[clojure.pprint :as pprint])
(pprint/pprint (keys (methods pprint/simple-dispatch))) ; <1>
;; (nil ;
;; clojure.lang.PersistentQueue
;; clojure.lang.ISeq
;; :default
;; clojure.lang.IPersistentVector
;; clojure.lang.IPersistentMap
;; clojure.lang.IDeref
;; clojure.lang.IPersistentSet
;; clojure.lang.Var)