nrepl

https://github.com/nrepl/nrepl || https://nrepl.org
pez 2019-10-19T11:45:46.038200Z

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

pez 2019-10-19T11:56:53.041300Z

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)

pez 2019-10-19T12:30:41.042200Z

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

pez 2019-10-19T12:35:05.045900Z

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

dominicm 2019-10-19T12:39:01.046600Z

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

dominicm 2019-10-19T12:39:09.046900Z

There's some in cider-nrepl though

pez 2019-10-19T12:54:15.048600Z

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

dominicm 2019-10-19T13:23:11.049Z

They are defined under a special symbol iirc

dominicm 2019-10-19T13:23:36.049800Z

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

dominicm 2019-10-19T13:23:46.050100Z

Can you require it normally?

pez 2019-10-19T13:25:27.051200Z

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

dominicm 2019-10-19T13:30:16.052Z

Sideload it ;)

pez 2019-10-19T13:47:32.055500Z

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.

dpsutton 2019-10-19T13:48:45.056500Z

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

pez 2019-10-19T13:49:06.057Z

Yeah, always is pretty huge.

pez 2019-10-19T13:49:19.057700Z

(In the case of a datomic database.)

dpsutton 2019-10-19T13:49:19.057800Z

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

dpsutton 2019-10-19T13:49:33.058400Z

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

pez 2019-10-19T13:50:24.059300Z

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

dpsutton 2019-10-19T13:51:12.060300Z

Oh i see

pez 2019-10-19T13:51:34.060700Z

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

dpsutton 2019-10-19T13:52:51.062Z

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

pez 2019-10-19T13:57:48.062400Z

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

pez 2019-10-19T14:00:53.064Z

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

dominicm 2019-10-19T14:27:48.064500Z

Yeah. This is pretty normal with pretty printing.

dominicm 2019-10-19T14:27:54.064800Z

Component is another common one.