clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
dpsutton 2021-03-13T04:46:42.080900Z

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

2021-03-13T05:01:53.082Z

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

dpsutton 2021-03-13T05:02:39.083900Z

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

2021-03-13T05:02:42.084Z

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

2021-03-13T05:03:14.084900Z

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

dpsutton 2021-03-13T05:03:46.085500Z

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

dpsutton 2021-03-13T05:07:13.086200Z

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)" 

dpsutton 2021-03-13T05:08:56.087300Z

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

dpsutton 2021-03-13T05:09:34.087800Z

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

dpsutton 2021-03-13T05:23:04.088100Z

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)))

seancorfield 2021-03-13T05:27:32.088800Z

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

dpsutton 2021-03-13T05:29:17.089400Z

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

seancorfield 2021-03-13T05:32:18.090700Z

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.szabo 2021-03-14T22:05:48.111600Z

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 😄

william 2021-03-13T13:14:48.093400Z

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?

borkdude 2021-03-14T10:33:21.097200Z

@meditans This tools is based on clj-kondo's output: https://github.com/benedekfazekas/morpheus

william 2021-03-14T12:02:06.097800Z

thanks @borkdude!

vemv 2021-03-13T15:28:11.093700Z

you may want to ask in #lsp

1🙌
Joe 2021-03-13T15:30:51.093900Z

How about

(last (sort-by #(apply max %) [[1 5 3] [4 10 35 9] [2 7 19]]))