Fork me on GitHub
#clojure
<
2021-03-13
>
dpsutton04:03:42

how do socket repl's and REBL interact? I expected i could clj -M:rebl and then nc localhost 50505 and see results in the rebl UI from the netcat session. However, only things entered in the original process with clj -M:rebl appear there

hiredman05:03:53

Rebl must need a special repl to capture results for the gui

dpsutton05:03:39

yeah. was expecting to see something about it in the documentation. I know sean uses it with a socket repl so i'm surprised to see it seems to need a bit more configuration

hiredman05:03:42

The socket repl is actually a generic framework for launching processes on sockets, which is configurabls

hiredman05:03:14

So you may be able to launch the socket repl with whatever custom repl rebl needs

dpsutton05:03:46

yeah was wondering if there was a premade "accept" function in cognitect.rebl made for this but not seeing anything

dpsutton05:03:13

ah, it seems sean hijacks things on

wrap_in_rebl_submit = (code) ->
  "(let [value " + code + "] " +
  "  (try" +
  "    ((requiring-resolve 'cognitect.rebl/submit) '" + code + " value)" +
  "    (catch Throwable _))" +
  "  (try" +
  "    ((requiring-resolve 'my.repl/reveal) value)" +
  "    (catch Throwable _))" +
  "  value)" 

dpsutton05:03:56

yeah i've got it working with nrepl and ricky moynihan's middleware. I am a bit surprised that nrepl seems to have a better story for it than socket repls

dpsutton05:03:34

i expected to setup socket-repl with rebl and use inf-clojure and have the first class experience.

dpsutton05:03:04

i guess a sub repl works

(clojure.main/repl
                :read
                (fn [request-prompt request-exit]
                  (let [x (clojure.main/repl-read request-prompt request-exit)]
                    (if (= x :repl/quit)
                      request-exit
                      x)))
                :eval
                (fn [form]
                  (let [result (eval form)]
                               (cognitect.rebl/submit form result)
                               result)))

seancorfield05:03:32

@dpsutton For REBL, I have https://github.com/seancorfield/socket-rebl -- a variant of that would work for tap> and hence Reveal.

dpsutton05:03:17

aha. i was thinking there might be something like that. thanks

seancorfield05:03:18

Note: if you use a client like Chlorine, Clover, or unrepl/unravel with that library it "doesn't work" because those clients all spin up a second socket REPL and use that for the actual evaluation 😐 but it works great for "dumb" clients.

mauricio.szabo22:03:30

As a side note: it doesn't work for now 😄. I'm studying other ways to interpret results from the REPL, and I'm trying to document my ideas here: https://github.com/mauricioszabo/atom-chlorine/discussions/241

mauricio.szabo22:03:48

Sure enough, if I can make this work for Chlorine, it'll work for Clover too. I was trying to figure out why someone would want to use the "Inferior REPL mode", but now I have an example 😄

Carlo13:03:48

tool question: what do you use to explore the call graph of your functions? clojure-lsp has a feature that lets you see all the functions that call your function in a tree (they call it incoming call hierararchy. The other direction, the outgoing call hierarchy, doesn't seem to be implemented (why?). Do you use another kind of tool to explore your codebase?

vemv15:03:11

you may want to ask in #lsp

🙌 3