such.imperfection

Were we perfect, we wouldn’t need to test or debug. Since we’re not, a few helpers organized around printing.

-pprint-

(-pprint- v)

Unlike regular pprint, this returns the value passed in, making it useful for cases like this:

  (-> v
      frob
      -pprint-
      tweak
      -pprint-)

value is used to produce more helpful function-names.

-prn-

(-prn- v)

Unlike regular prn, this returns the value passed in, making it useful for cases like this:

  (-> v
      frob
      -prn-
      tweak
      -prn-)

value is used to produce more helpful function-names.

-tag

(-tag value tag & args)

If tag is a string, formats tag and args and prints the results as with println. If tag is not a string, it is printed and any args are ignored. The value is returned.

Use as follows:

 (-> v
      frob
      (tag "Frob with %s" flag) (-pprint-)
      quux
      (tag :quux)
      ...)

e-pprint-

(e-pprint- & args)

Like -pprint-, but prints to *err*. Useful for keeping debug output from being captured by val-and-output.

e-prn-

(e-prn- & args)

Like -prn-, but prints to *err*. Useful for keeping debug output from being captured by val-and-output.

e-tag

(e-tag & args)

Like -tag, but prints to *err*. Useful for keeping debug output from being captured by val-and-output.

epprint

(epprint & args)

Like pprint, but prints to *err*. Useful for keeping debug output from being captured by val-and-output.

epr

(epr & args)

Like pr, but prints to *err*. Useful for keeping debug output from being captured by val-and-output.

eprint

(eprint & args)

Like print, but prints to *err*. Useful for keeping debug output from being captured by val-and-output.

eprintln

(eprintln & args)

Like println, but prints to *err*. Useful for keeping debug output from being captured by val-and-output.

eprn

(eprn & args)

Like prn, but prints to *err*. Useful for keeping debug output from being captured by val-and-output.

etag-

(etag- & args)

Like tag-, but prints to *err*. Useful for keeping debug output from being captured by val-and-output.

tag-

(tag- tag value)

Prints (as with println) the given tag, which may be any value. The value is returned.

 (->> v
      frob
      (tag "frobout") -prn-
      ...)

val-and-output

macro

(val-and-output & body)

Execute the body. Instead of just returning the resulting value, return a pair of the value and any output (as with with-out-str).