Fork me on GitHub
#nrepl
<
2019-10-19
>
pez11:10:46

Where can I find a list of “built-in” pprint vars?

pez11:10:53

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)

pez12:10:41

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

pez12:10:05

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}}

dominicm12:10:01

I don't think any are built in except clojure.pprint

dominicm12:10:09

There's some in cider-nrepl though

pez12:10:15

Those that I have tried are the cider-nrepl ones. Even though I had to provide the dependency on zprint in the test project.

dominicm13:10:11

They are defined under a special symbol iirc

dominicm13:10:36

If you have a dependency on zprint then I think it should work

dominicm13:10:46

Can you require it normally?

pez13:10:27

Yeah, no problems with zprint really. It’s a bit strange that I need to include the dependency, but no biggie.

dominicm13:10:16

Sideload it ;)

pez13:10:32

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.

dpsutton13:10:45

The db is a value. So it’s important not to print it right? Since it could be huge

pez13:10:06

Yeah, always is pretty huge.

pez13:10:19

(In the case of a datomic database.)

dpsutton13:10:19

If you just prn it you’d see the same thing?

dpsutton13:10:33

I don’t see how this is a pretty printing issue

pez13:10:24

I can try with prn. But, clojure.core/pprint doesn’t print the database.

pez13:10:34

> 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.

dpsutton13:10:51

Wild guess. The db implements IAssoc or something but not a print method and the pretty printers walk it trying to be helpful

pez13:10:48

I probably need to do my pretty printing in a static way.

pez14:10:53

> 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.

dominicm14:10:48

Yeah. This is pretty normal with pretty printing.

dominicm14:10:54

Component is another common one.