unrepl

discussing specification of an edn-based repl and its implementations.
cgrand 2017-03-31T07:57:04.183267Z

@pesterhazy on :exception I’d like to indicate in which phase the exception occured (`read`, eval, print and wtf)

cgrand 2017-03-31T07:58:01.195834Z

I think the payload of :exception is going to be a map :phase and :ex

cgrand 2017-03-31T07:58:29.201589Z

Does it seem ok to you (as the 1st consumer)

pesterhazy 2017-03-31T07:58:49.205731Z

I can't see how it could hurt

pesterhazy 2017-03-31T08:00:24.227667Z

what would it be useful for though?

cgrand 2017-03-31T08:02:17.253908Z

quickly communicating to the user if she gets an exception because of: • syntax error • application code • other (print & wtf)

pesterhazy 2017-03-31T08:03:10.265452Z

the print one is interesting 🙂

pesterhazy 2017-03-31T08:03:53.274442Z

one question, can I rely on the fact that each message is newline delimited?

pesterhazy 2017-03-31T08:04:13.278684Z

obviously simplifies reading from the stream

cgrand 2017-03-31T08:05:07.290543Z

Hum to me it was an impl detail, how does it simplify reading?

pesterhazy 2017-03-31T08:06:02.302010Z

I get a callback for each chunk of data, but a message might be larger than buffer-size

pesterhazy 2017-03-31T08:06:45.311217Z

so I need to try to read and see if it doesn't throw an exception to see if the message was complete

pesterhazy 2017-03-31T08:07:07.315647Z

unless I'm missing something

pesterhazy 2017-03-31T08:08:17.330388Z

I do think newline-delimited EDN is a good format anyway (similar to newline-delimited JSON)

pesterhazy 2017-03-31T08:09:47.349239Z

JSON doesn't allow a literal newline in string, not sure about EDN

pesterhazy 2017-03-31T08:11:42.374071Z

as far as I can see the EDN spec doesn't say

pesterhazy 2017-03-31T08:13:07.392035Z

>>> Strings are enclosed in "double quotes". May span multiple lines.

pesterhazy 2017-03-31T08:13:15.393605Z

annoying 🙂

cgrand 2017-03-31T08:13:30.396994Z

EDN is very ambiguous on strings: newline may be escaped but are not required to and, officially, most control chars are not escapable (and appears as is)

pesterhazy 2017-03-31T08:14:00.403070Z

can't you use octal codes?

cgrand 2017-03-31T08:14:30.409797Z

only for char lits, not for strings (according to the spec + 1 issue answered by Rich)

pesterhazy 2017-03-31T08:14:51.414239Z

ah. weird!

pesterhazy 2017-03-31T08:15:40.424835Z

a more unambiguous specification for EDN would be useful

cgrand 2017-03-31T08:15:47.426432Z

and edn/read being forked of clojure reader is very liberal and not validating at all

cgrand 2017-03-31T08:17:01.442580Z

the reader used in CLJS is tools.reader?

pesterhazy 2017-03-31T08:17:03.443196Z

that complicates things of course, because complete-form? for EDN needs to actually read the string, I think

pesterhazy 2017-03-31T08:17:12.444891Z

cljs.reader

cgrand 2017-03-31T08:21:50.506774Z

Accumulate chunks until read succeeds (or fail for a reason other than EOF) is currently your best approach.

pesterhazy 2017-03-31T08:22:06.510343Z

yeah, will do that

pesterhazy 2017-03-31T08:25:02.549919Z

which unfortunately involves catching an exception and regex'ing the Exception text 😞

cgrand 2017-03-31T08:26:03.563298Z

If PushbackReader/read-char could be extended to return a special value to signify temporary end then the reader could return a continuation

cgrand 2017-03-31T08:27:11.578627Z

so you would get from read (with the appropriate options), either an exception, a value or a continuation (a function expecting more input)

pesterhazy 2017-03-31T11:04:29.713819Z

New version now correctly implements reading from an EDN stream

pesterhazy 2017-03-31T11:04:46.717581Z

It's almost usable now!

pesterhazy 2017-03-31T11:12:30.807507Z

Things I want to implement next: https://github.com/pesterhazy/unravel/blob/master/TODO.md

cgrand 2017-03-31T11:46:32.200641Z

@pesterhazy interrupt & bg work (with 2 connections)

cgrand 2017-03-31T12:24:49.689160Z

@pesterhazy how do you intent to make elisions expand in a CLI repl client?

pesterhazy 2017-03-31T12:56:43.153608Z

I was thinking of adding a client command like \cont

pesterhazy 2017-03-31T12:57:22.163803Z

Not sure...

cgrand 2017-03-31T13:01:02.228239Z

what if you have several elisions? you would expand them all? \moar

cgrand 2017-03-31T13:01:32.237848Z

like (repeat (range)) 🙂

cgrand 2017-03-31T13:04:30.290021Z

> (repeat (range))
< [:started-eval {:actions {:interrupt (unrepl.repl/interrupt! :session238 1), :background (unrepl.repl/background! :session238 1)}} 1]
&lt; [:eval ((0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__242)}) (0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__243)}) (0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__244)}) (0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__245)}) (0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__246)}) (0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__247)}) (0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__248)}) (0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__249)}) (0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__250)}) (0 1 2 3 4 5 6 7 8 9 <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__251)}) <#C4C63FWP5|unrepl>/... {:get (unrepl.repl/fetch :G__241)}) 1]

pesterhazy 2017-03-31T13:33:39.824634Z

good point... not sure how to handle this

pesterhazy 2017-03-31T13:35:00.851780Z

come to think of it, a nice interface for this would be to start an ad hoc webserver from unravel and open a browser with [+] expandable elisions

cgrand 2017-03-31T13:36:35.883519Z

once you are in the browser, throw a textarea in

pesterhazy 2017-03-31T13:37:37.904207Z

to replace the terminal prompt?

cgrand 2017-03-31T13:37:50.908455Z

yup

pesterhazy 2017-03-31T13:37:59.911388Z

so many possibilities...

cgrand 2017-03-31T13:38:06.913563Z

so little time

pesterhazy 2017-03-31T13:38:24.919660Z

one simple thing I though of was a unravel special \pprint

pesterhazy 2017-03-31T13:38:35.923144Z

to pprint the last result

cgrand 2017-03-31T13:40:28.961664Z

why not always pprint?

pesterhazy 2017-03-31T13:41:23.980359Z

I sometimes prefer pp over pprint

pesterhazy 2017-03-31T13:41:35.984688Z

it really depends on the information shown

pesterhazy 2017-03-31T13:41:44.987670Z

also cloure.pprint/print-table is also a nice display format

cgrand 2017-03-31T13:44:57.053729Z

what I meant is that since with unrepl you get data (and not almost readable representation), the client can pprint at will — in a GUI it could be expanded, collapsed, partialy displayed as a table etc.

pesterhazy 2017-03-31T13:47:18.102439Z

right that's what I meant as well

pesterhazy 2017-03-31T13:47:24.104596Z

you can even make it interactive

pesterhazy 2017-03-31T13:58:08.333247Z

I have to admit, working with node (lumo) is actually quite a lot of fun

dominicm 2017-03-31T14:05:00.495214Z

@pesterhazy is your client built on lumo?

pesterhazy 2017-03-31T15:10:37.047472Z

@dominicm yeah

dominicm 2017-03-31T15:10:52.053134Z

nice 😎

richiardiandrea 2017-03-31T17:28:36.094014Z

@pesterhazy awesome stuff

richiardiandrea 2017-03-31T17:29:09.105407Z

the only thing I am missing from the lumo experience is good rock solid completion, I am tempted to create a bounty

pesterhazy 2017-03-31T17:30:03.124669Z

both tab completion and cljs support are on the todo list for unrepl

richiardiandrea 2017-03-31T17:33:07.191214Z

@pesterhazy Just an impl detail..I would advise against tab completion only. In inf-clojure for instance it is very nice that I can call (lumo.repl/get-completions) to get them.

pesterhazy 2017-03-31T17:43:27.405500Z

you mean it should be possible to directly call the fn determining possible completions?

richiardiandrea 2017-03-31T17:46:59.479344Z

@pesterhazy yes, inf-clojure already does that https://github.com/clojure-emacs/inf-clojure/blob/master/inf-clojure.el#L669

richiardiandrea 2017-03-31T17:47:20.486447Z

also, emacs can read json, but inf-clojure does not implement that at the moment

richiardiandrea 2017-03-31T17:47:56.499365Z

that is why I actually call (doall (map str (lumo.repl/get-completions \"%s\"))) for lumo

pesterhazy 2017-03-31T18:37:36.568049Z

Unravel now shows docs for the symbol under the cursor when you type Control-O

dominicm 2017-03-31T18:47:35.775011Z

Woah, nice

pesterhazy 2017-03-31T18:48:13.787736Z

If you have a minute, give it a try and let me know if it works for you

richiardiandrea 2017-03-31T19:00:04.037481Z

@pesterhazy sooooo, you convinced me to be your alpha tester...is the client connecting to an nrepl?

richiardiandrea 2017-03-31T19:00:31.047641Z

oh sorry never mind...read the doc ! 🙂

cgrand 2017-03-31T20:01:05.214550Z

well completion is touchy because there’s no agreement on the algorithm, but in the end given the new “multiple connections” model it will just resolve to a fn call.

cfleming 2017-03-31T23:49:30.189060Z

WRT exception phase, isn’t that potentially confusing when an exception is thrown during printing a lazy sequence? That will probably have happened in code that the user thinks of as :eval.