unrepl

discussing specification of an edn-based repl and its implementations.
richiardiandrea 2017-06-14T19:25:03.166974Z

soooo...maybe it is a bit off topic here, but I am going to put it out

richiardiandrea 2017-06-14T19:26:32.197181Z

as @anmonteiro knows I am trying to detect the repl type in inf-clojure. There more general problem is advertise your own type. I need to do the same for a plain clj repl, a plain cljs repl, a @thheller shadow clj repl, a @thheller shadow cljs repl, @mfikes planck, ...

😳 1
richiardiandrea 2017-06-14T19:27:11.210134Z

so I was wondering if it is a good idea to agree on a common way

richiardiandrea 2017-06-14T19:28:22.233841Z

a function call was my proposal but it seems it is not the best for repl devs

richiardiandrea 2017-06-14T19:28:51.243290Z

I am open to any proposal, the only restriction is that I will need to send text and receive text

thheller 2017-06-14T19:28:55.244602Z

[zilence@zpro ~/code/shadow-cljs/target]$ rlwrap nc localhost 8201
shadow-cljs - REPL - see (help), :repl/quit to exit
[104:0]~shadow.user=> (shadow/node-repl)
[104:1]~cljs.user=>

thheller 2017-06-14T19:29:16.251543Z

as a bit of context maybe … shadow-cljs now provides a socket-repl that you can “upgrade” to CLJS

richiardiandrea 2017-06-14T19:29:24.254383Z

either parsing the terminal output or the string returned on the websocket

thheller 2017-06-14T19:29:43.260709Z

inf-clojure needs to detect if its currently CLJ or CLJS somehow

thheller 2017-06-14T19:30:59.287025Z

I have a detection mechanism that works out of band

richiardiandrea 2017-06-14T19:31:17.293203Z

now actually I see your case is the simplest @thheller because I have a function there so from that moment on I could just switch. If shadow/node-repl returned the repl type I can just use that

thheller 2017-06-14T19:31:38.300080Z

actually the clue is the prompt

thheller 2017-06-14T19:32:03.307929Z

run (shadow.repl/level 104 1) or whatever the numbers shown are

thheller 2017-06-14T19:32:12.310887Z

in another connection

thheller 2017-06-14T19:32:34.318337Z

thats where the proper API comes it

thheller 2017-06-14T19:33:07.329117Z

say curl <http://localhost:8200/repl-api/104/1> or so which would tell everything you want about that REPL 😛

thheller 2017-06-14T19:33:19.333814Z

but you’d need to parse the prompt

richiardiandrea 2017-06-14T19:33:21.334290Z

yeah I see that I could do that, but I would like to have a way that does not consider prompts because prompts in inf-clojure have weird regexes associated with them and comint kind of excludes them from the output if matching the regex

thheller 2017-06-14T19:33:43.341461Z

can’t you just parse whatever comes over the socket?

thheller 2017-06-14T19:33:49.343521Z

I have no idea how emacs does things

richiardiandrea 2017-06-14T19:34:21.354075Z

this would be good:

[2:0]~shadow.user=&gt; (shadow/node-repl)
"shadow-cljs"
[2:1]~cljs.user=&gt;

thheller 2017-06-14T19:34:22.354518Z

it must be able to do something similar no?

thheller 2017-06-14T19:34:54.365384Z

why is that easier than parsing the prompt?

richiardiandrea 2017-06-14T19:34:58.366744Z

emacs is a weird beast and I am trying to define the minimal amount of changes to do in there

richiardiandrea 2017-06-14T19:35:10.370987Z

see above, the prompt might be parsed out

thheller 2017-06-14T19:35:36.379775Z

hmm ok just tell me what line to add and I’ll do that 😉

richiardiandrea 2017-06-14T19:35:43.381847Z

still need to double check that, but it feels complicated given my inf-clojure knowledge 😄

thheller 2017-06-14T19:36:06.389376Z

but the prompt would be shadow-cljs anyways .. need something that all tools support

richiardiandrea 2017-06-14T19:36:11.390842Z

my goal would be for repl devs to agree on a way to return that info

richiardiandrea 2017-06-14T19:36:38.400170Z

so let's wait for others as well ok?

richiardiandrea 2017-06-14T19:37:07.409595Z

for a bit of background: https://github.com/anmonteiro/lumo/issues/174

richiardiandrea 2017-06-14T19:37:58.426169Z

Actually https://github.com/anmonteiro/lumo/issues/111

thheller 2017-06-14T19:38:59.446423Z

I don’t want to start another rant about this subject

thheller 2017-06-14T19:39:12.450634Z

but tooling stuff should not go over the same REPL connection as the actual REPL 😛

✅ 1
thheller 2017-06-14T19:39:18.452898Z

its just painful to parse

cgrand 2017-06-14T21:22:10.486768Z

maybe it’s a far fetched analogy but User-Agent didn’t work that well..

thheller 2017-06-14T21:24:45.531418Z

@cgrand didn’t you implement an edn reader that can work in node?

thheller 2017-06-14T21:25:04.536952Z

ie. not stream based?

cgrand 2017-06-14T21:27:41.582618Z

(cond
  (not= (/ 1 2) 0.5) :clj
  (find-ns ‘lumo.repl) :lumo
  :else nil)

cgrand 2017-06-14T21:32:44.668835Z

@thheller yes I did but I don’t get what you mean by “not stream based”

thheller 2017-06-14T21:33:43.685375Z

something I can call like (reader/next reader-state chunk-of-text) and get [next-state forms] or so

thheller 2017-06-14T21:34:15.694009Z

CLJ reader always blocks on read

thheller 2017-06-14T21:34:20.695639Z

how do you do that in CLJS?

cgrand 2017-06-14T21:37:48.752429Z

Callbacks, what else? ;-)

thheller 2017-06-14T21:38:33.764327Z

hmm dammit

thheller 2017-06-14T21:38:52.769379Z

means you need to own whatever stream you read from right?

thheller 2017-06-14T21:39:50.784924Z

is that usable somewhere?

thheller 2017-06-14T21:40:26.794648Z

need a quick way to read EDN in a streaming fashion

thheller 2017-06-14T21:41:37.813915Z

(cljs.reader/read-string "{:foo") fails with EOF …

thheller 2017-06-14T21:42:11.822693Z

need something that I can do partial read and continue when I have more data to feed it

cgrand 2017-06-14T21:44:18.856058Z

Can't give details now but here is the reader (search for edn-read https://github.com/cgrand/cljs-js-repl/blob/master/src/net/cgrand/cljs/js/repl/async_reader.cljs

thheller 2017-06-14T21:44:47.863607Z

ah thx … I’ll see it that works for what I want

thheller 2017-06-14T21:46:15.887120Z

damn … io/*in* thats you binding thingo right?

cgrand 2017-06-14T21:46:57.897859Z

Which bridges between a node socket and my stream abstraction.

thheller 2017-06-14T21:47:31.906547Z

hmm ok .. I’ll test it

cgrand 2017-06-14T21:57:18.053828Z

Report any issues you have with it.

thheller 2017-06-14T21:58:28.070862Z

my main issue is the bindings but I’m too tired for this anyways

thheller 2017-06-14T21:58:35.072662Z

will test in the next few days

richiardiandrea 2017-06-14T22:02:07.127836Z

cgrand: oh this is the best idea so far! way easier 🙂

richiardiandrea 2017-06-14T22:03:02.140442Z

maaaan sometimes it so simple thanks @cgrand!

cgrand 2017-06-14T22:16:55.328533Z

@thheller edn-read can accept the input stream as an explicit argument. So calling code can use it without explicit usage of dynamic binding stuff.

cgrand 2017-06-14T22:21:55.391641Z

I believe that adding a (not find-ns) :cljs-clj should work