 
 #?(:clj
    (defmacro def
-     "Define a spec with an optional error message.
-
-Replaces `clojure.spec.alpha/def` but optionally takes a human-readable `error-message` (will only be used for predicates) e.g. 'should be a string'."
+     "Define a spec with an optional `error-message`.
+
+  Replaces `clojure.spec.alpha/def` but optionally takes a human-readable `error-message` (will only be used for predicates) e.g. 'should be a string'."
      ([k spec-form]
       `(s/def ~k ~spec-form))
      ([k spec-form error-message]

           (defmsg '~k ~error-message)
           (s/def ~k ~spec-form))))))

(defn explain-result [check-result]
  (when (= s/*explain-out* s/explain-printer)
    (throw (ex-info "Cannot print check results with default printer. Use 'set!' or 'binding' to use Expound printer." {})))
  (s/*explain-out* check-result))

(defn explain-result-str [check-result]
  (with-out-str (explain-result check-result)))

(defn explain-results [check-results]
  (doseq [check-result (butlast check-results)]
    (explain-result check-result)
    (print "\n\n"))
  (explain-result (last check-results)))

(defn explain-results-str [check-results]
  (with-out-str (explain-results check-results)))

(defn custom-printer
  "Returns a printer.

  Options:
   :show-valid-values? - if false, replaces valid values with \"...\"
   :value-str-fn       - function to print bad values
   :print-specs?       - if true, display \"Relevant specs\" section. Otherwise, omit that section.
   :theme               - enables color theme. Possible values: :figwheel-theme, :none"
  [opts]
  (fn [explain-data]
    (print (printer-str opts explain-data))))
