nrepl

https://github.com/nrepl/nrepl || https://nrepl.org
pez 2019-11-09T13:10:44.020100Z

Is there a reason why zprint dependencies are not provided directly with cider-nrepl as they are with puget and fipp?

dominicm 2019-11-09T20:01:12.021100Z

Puget and fipp are grandfathered in. They'd be removed if it wouldn't break the backwards compatibility. The goal is to make cider lighter.

pez 2019-11-09T20:11:53.021700Z

Oki. Not sending the PR then. 😎

pez 2019-11-09T22:41:09.025200Z

I am having problems giving zprint this option map over nREPL: {:record {:to-string? true}}, because I don’t seem to be able to bencode booleans to anything else but 0/1, and zprint checks that it is a boolean… Is it possible to send a boolean proper over bencode? Or is there some other way I can achieve this? Feels like a problem I should have encountered before, but I haven’t…

shen 2019-11-10T19:37:47.029200Z

I wonder if we should read-string the value?

shen 2019-11-10T19:39:39.029500Z

It feels quite limiting to only be able to use what can survive the bencode conversion to and fro

shen 2019-11-10T19:43:23.029700Z

Googling ":nrepl.middleware.print/options" doesn't yield that many results, so I'm guessing this doesn't get used much other than to pass {:right-margin 70} or similar around

pez 2019-11-11T10:20:50.037100Z

Yeah, it is a bit surprising that it took me so long to run in to this limitation. A bit hard to see how it could be fixed though...

shen 2019-11-11T12:24:39.037300Z

I think if we allowed that to be passed as a (edn) string (v.s. bencode map), that could be better?

shen 2019-11-11T12:25:16.037500Z

that would require a (non-breaking) change to nrepl though

pez 2019-11-11T12:27:51.037700Z

Could be made opt in, though?

shen 2019-11-11T12:29:35.037900Z

yes definitely

shen 2019-11-11T12:30:20.038100Z

(if-not (string? opt) opt (read-string opt)) in the right place

pez 2019-11-11T12:31:07.038300Z

I was more thinking in some config of the transport.

shen 2019-11-11T12:32:45.038500Z

guess we could even allow boolean in the bencode transport. Would just need to think about how to encode it

shen 2019-11-11T12:39:22.038700Z

(I don't think it's part of the bencode spec)

pez 2019-11-11T12:40:33.038900Z

It isn't. But, yeah, doesn't need to be. haha.

pez 2019-11-11T12:42:16.039100Z

b0e/`b1e`, or bfe/`bte`, maybe.

pez 2019-11-11T12:44:04.039300Z

Would be nice to be able to transfer nil as well.

shen 2019-11-11T13:09:51.039500Z

I just had a look around at how various other bencode implementations dealt with this. Nothing jumped out as an especially good options

shen 2019-11-11T13:16:30.039700Z

something different:

shen 2019-11-11T13:16:48.039900Z

what are you trying to use as the print-fn for zprint?

shen 2019-11-11T13:16:59.040100Z

zprint.core/zprint doesn't have the right signature

shen 2019-11-11T13:17:12.040300Z

it needs to be [value writer options]

shen 2019-11-11T13:20:19.040500Z

not actually sure what has that signature, other than the built in fn's

shen 2019-11-11T13:25:08.040800Z

(i.e. to use zprint, you might need to provide a wrapper fn anyways

pez 2019-11-11T13:38:40.041300Z

I'm using cider.nrepl.pprint/zprint-pprint, and providing the options via nrepl.middleware.print/options.

shen 2019-11-11T13:44:55.041500Z

ah-ha

shen 2019-11-11T13:45:21.041700Z

then think it might be better to patch https://github.com/clojure-emacs/cider-nrepl/blob/7cdbe4d32b4893ab1d856b92cc802f96bb31f1f5/src/cider/nrepl/pprint.clj#L86 to coerce :to-string? to boolean

shen 2019-11-11T13:47:13.042Z

(if (get-in options [:record :to-string?]) (update-in options [:record :to-string?] boolean) options)

shen 2019-11-11T13:47:59.042200Z

cider-nrepl releases way more frequently than nrepl itself

pez 2019-11-11T13:49:47.042500Z

Kim Kinnear is going to relax the spec to allow for 1 as representing not false. So this particular option will be covered that way.