Welcome! Please see the About page for a little more info on how this works.

+7 votes
in REPL by

I have been nrepl based for a long time and that didn't play nicely with creating "sub repls" with clojure.main/repl. I'm using socket repls now and really enjoying that sub repls are usable again for me. I'm mostly just doing a simple call

(clojure.main/repl
 :prompt (fn [] (printf "%s=> " (peek (str/split (str *ns*) #"\."))))
 :read server/repl-read)

What else are people doing with sub repls? Creating history files of evaluation? Throwing forms into a db? Really interested to know.

5 Answers

+1 vote
by

This is some incomplete code for connecting to a clojure.main/repl over http(ala nrepl's drawbridge).

wrap-repl is a ring handler. http-repl is then called in a normal clojure.main/repl and connects it to the remote repl.

I believe the communication parts of the code are all there, the missing bits are around securing repl access via signing requests.

https://gist.github.com/hiredman/86aeb916b478d9e57cbce8e0e678babd

+1 vote
by

A small example of customization:

https://insideclojure.org/2020/02/11/custom-repl/

0 votes
by

I use it with a fork of NightCode called nightclub to provide an embedded repl + mini IDE + file editor + project manager for an application I deploy. Users basically get a clojure environment + live scripting of the application as well as a GUI that echoes commands to the REPL for sort of an interactive learning experience (kind of like the VBA editor in Excel). I have benefited from this in restricted environments where all I was allowed was an uberjar; with this setup I get a nice little clojure dev environment / scripting / debug setup in addition to the application.

0 votes
by

I use it to use fipp as my default printer, which is noticeably faster than clojure's default print/pprint

(clojure.main/repl
  :caught (fn [e] (fipp.repl/pst e))
  :print  (fn [x] (fipp.edn/pprint x)))
0 votes
ago by

Doesn't seem to be implemented on top of clojure.main/repl specifically, but Datawalk is a pretty cool example of what you can do with a sub-REPL.

...