Last active
March 28, 2018 19:00
-
-
Save cgrand/2ccdc33e7b5ebf49e8a6d50d222b973f to your computer and use it in GitHub Desktop.
What if a REPL out was a stream of EDN forms?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; some sample interaction with a clojure socket repl whose output stream consists only of valid edn forms. | |
;; the edn stream is not meant for the end user but for the client UI. | |
;; it demoes several features: | |
;; • prompt, out, err, eval and exceptions are demultiplexed; unstructred ones (err & out) are just text but the others give data. | |
;; • elided content (because data too deep or wide) is replaced by a tagged literal (which optionally contains the expr to evaluate to get more items) | |
;; this last point makes possible navigation | |
;; lines are prefixed by > or < to tell what is sent to the repl (>) and what is received from it (<) | |
< [:prompt {:ns richrepl.core, :*warn-on-reflection* nil}] | |
> (+ 1 2) | |
< [:eval 3] | |
< [:prompt {:ns richrepl.core, :*warn-on-reflection* nil}] | |
> (println "hello") | |
< [:out "hello\n"] | |
< [:eval nil] | |
< [:prompt {:ns richrepl.core, :*warn-on-reflection* nil}] | |
> (range) | |
< [:eval (0 1 2 3 4 5 6 7 8 9 #ednrepl/... {:get (ednrepl/get :G__8407)})] | |
< [:prompt {:ns richrepl.core, :*warn-on-reflection* nil}] | |
> (ednrepl/get :G__8407) | |
< [:eval (10 11 12 13 14 15 16 17 18 19 #ednrepl/... {:get (ednrepl/get :G__8426)})] | |
< [:prompt {:ns richrepl.core, :*warn-on-reflection* nil}] | |
> (nil) | |
< [:exception #error {:cause "Can't call nil, form: (nil)", :via [{#ednrepl/... {:get (ednrepl/get :G__8402)} #ednrepl/pad} {#ednrepl/... {:get (ednrepl/get :G__8403)} #ednrepl/pad}], :trace [[clojure.lang.Compiler analyzeSeq "Compiler.java" 6860] [clojure.lang.Compiler analyze "Compiler.java" 6669] [clojure.lang.Compiler analyze "Compiler.java" 6625] [clojure.lang.Compiler$BodyExpr$Parser parse "Compiler.java" 6001] [clojure.lang.Compiler$FnMethod parse "Compiler.java" 5380] [clojure.lang.Compiler$FnExpr parse "Compiler.java" 3972] [clojure.lang.Compiler analyzeSeq "Compiler.java" 6866] [clojure.lang.Compiler analyze "Compiler.java" 6669] [clojure.lang.Compiler eval "Compiler.java" 6924] [clojure.lang.Compiler eval "Compiler.java" 6890] #ednrepl/... {:get (ednrepl/get :G__8404)}]}] | |
< [:prompt {:ns richrepl.core, :*warn-on-reflection* nil}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment