Fork me on GitHub
#unrepl
<
2017-06-14
>
richiardiandrea19:06:03

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

richiardiandrea19:06:32

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

richiardiandrea19:06:11

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

richiardiandrea19:06:22

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

richiardiandrea19:06:51

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

thheller19:06:55

[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=>

thheller19:06:16

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

richiardiandrea19:06:24

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

thheller19:06:43

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

thheller19:06:59

I have a detection mechanism that works out of band

richiardiandrea19:06:17

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

thheller19:06:38

actually the clue is the prompt

thheller19:06:03

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

thheller19:06:12

in another connection

thheller19:06:34

thats where the proper API comes it

thheller19:06:07

say curl or so which would tell everything you want about that REPL 😛

thheller19:06:19

but you’d need to parse the prompt

richiardiandrea19:06:21

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

thheller19:06:43

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

thheller19:06:49

I have no idea how emacs does things

richiardiandrea19:06:21

this would be good:

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

thheller19:06:22

it must be able to do something similar no?

thheller19:06:54

why is that easier than parsing the prompt?

richiardiandrea19:06:58

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

richiardiandrea19:06:10

see above, the prompt might be parsed out

thheller19:06:36

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

richiardiandrea19:06:43

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

thheller19:06:06

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

richiardiandrea19:06:11

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

richiardiandrea19:06:38

so let's wait for others as well ok?

thheller19:06:59

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

thheller19:06:12

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

thheller19:06:18

its just painful to parse

cgrand21:06:10

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

thheller21:06:45

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

thheller21:06:04

ie. not stream based?

cgrand21:06:41

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

richiardiandrea22:06:07

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

cgrand22:06:55

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

cgrand21:06:44

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

thheller21:06:43

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

thheller21:06:15

CLJ reader always blocks on read

thheller21:06:20

how do you do that in CLJS?

cgrand21:06:48

Callbacks, what else? ;-)

thheller21:06:52

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

thheller21:06:50

is that usable somewhere?

thheller21:06:26

need a quick way to read EDN in a streaming fashion

thheller21:06:37

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

thheller21:06:11

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

thheller21:06:47

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

thheller21:06:15

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

cgrand21:06:57

Which bridges between a node socket and my stream abstraction.

thheller21:06:31

hmm ok .. I’ll test it

cgrand21:06:18

Report any issues you have with it.

thheller21:06:28

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

thheller21:06:35

will test in the next few days

richiardiandrea22:06:02

maaaan sometimes it so simple thanks @cgrand!

cgrand22:06:55

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