Where can I find a list of “built-in” pprint vars?
Found it. https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/pprint.clj
However, if I try to use zpring-pprint
I get
Could not locate zprint/core__init.class, zprint/core.clj or zprint/core.cljc on classpath.
I somehow recognize having asked about this before, but can’t remember what the conclusion was. puget and fipp both work. (But give me errors when printing datomic-api results, which is why I want to try zprint)I don’t know where to report this, if it is even something that is possible to fix, but anyway, here’s a test project: https://github.com/PEZ/nrepl-pprint-datomic
I get a bit of different results depending on which pprint function I use. In this mini-project:
puget
throws in the towel with
Error printing return value at clojure.lang.Util/runtimeException (Util.java:221).
Unable to convert: class datomic.btset.BTSet to Object[]
zprint
dumps the whole database, with schemas and all, retaining reader literals.
fipp
also dumps the whole database, but “expands” (or whatever the term is) the reader literals.
clojure.core/pprint
prints the same thing as with no pretty printing. Which is: {:db-before datomic.db.Db@defa54b7, :db-after datomic.db.Db@270efa27, :tx-data [#datom[13194139534318 50 #inst "2019-10-19T12:34:49.714-00:00" 13194139534318 true] #datom[17592186045423 62 "Hello world" 13194139534318 true]], :tempids {-9223301668109598140 17592186045423}}
I don't think any are built in except clojure.pprint
There's some in cider-nrepl though
Those that I have tried are the cider-nrepl ones. Even though I had to provide the dependency on zprint in the test project.
They are defined under a special symbol iirc
If you have a dependency on zprint then I think it should work
Can you require it normally?
Yeah, no problems with zprint really. It’s a bit strange that I need to include the dependency, but no biggie.
Sideload it ;)
It’s still not the problem. 😃 The issue here is that is I use a pretty printing printer for nrepl.middleware.print/print
with results from Datomic, they print the whole database for things like :db-before datomic.db.Db@defa54b7
. Which surprises the user who probably thought that the result map should just be printed in a tad more readable way. Also, in Calva pretty printing is default, and people can have pretty huge databases.
The db is a value. So it’s important not to print it right? Since it could be huge
Yeah, always is pretty huge.
(In the case of a datomic database.)
If you just prn it you’d see the same thing?
I don’t see how this is a pretty printing issue
I can try with prn
. But, clojure.core/pprint
doesn’t print the database.
Oh i see
> I don’t see how this is a pretty printing issue It is an issue at least. Not sure how to categorize it, but if not pretty printing, things do not go crazy.
Wild guess. The db implements IAssoc or something but not a print method and the pretty printers walk it trying to be helpful
I probably need to do my pretty printing in a static way.
> and the pretty printers walk it trying to be helpful It certainly seems to be something like this, because on my work project, evaluating something like
@(d/transact conn [{:db/doc "Hello world"}])
with pretty printing enabled never finishes and the java process heat up my machine like mad.Yeah. This is pretty normal with pretty printing.
Component is another common one.