unrepl

discussing specification of an edn-based repl and its implementations.
volrath 2017-11-24T12:45:39.000037Z

@cgrand did you notice the elision for letters seems a bit weird? shows the first 10, then the rest

volrath 2017-11-24T12:46:02.000397Z

doesn't stop at 20... not sure why, maybe because I'm modifying the print limits in the documentation

cgrand 2017-11-24T12:46:08.000066Z

There are several unicode glyphs if you want a smaller button

volrath 2017-11-24T12:46:41.000060Z

but i examine unrepl.print/print-length and it's 80.. maybe is the same bug we were discussing on github

cgrand 2017-11-24T12:47:44.000249Z

do use aux for elision resolution? what are print-limits settings on it?

volrath 2017-11-24T12:47:59.000156Z

I suppose I'm messing with *coll-length*

volrath 2017-11-24T12:48:05.000239Z

yes I do

volrath 2017-11-24T12:49:07.000040Z

I restart them after getting the doc to whatever bak# was, I haven't checked if it's done correctly though... I'll take a look later...

volrath 2017-11-24T12:49:20.000104Z

but why does it elide after the first 10?

volrath 2017-11-24T12:49:50.000058Z

I tried it, but it's too small! difficult to click 😕

cgrand 2017-11-24T13:11:15.000191Z

> but why does it elide after the first 10? Do you mean why it doesn’t elide after the first 10

volrath 2017-11-24T13:41:35.000141Z

actually I meant: why does it elide the first 10? If the print-limits were in fact left in MAX_VALUE, shouldn't it return the whole 26 letters at once?

volrath 2017-11-24T13:42:15.000232Z

I haven't looked too much into elision implementation, so I don't..

cgrand 2017-11-24T13:42:30.000189Z

initial elision occur on user while elision of the resolved elision occurs on aux

volrath 2017-11-24T13:43:20.000174Z

ah..

volrath 2017-11-24T13:43:46.000191Z

should I use user for resolving elisions then?

cgrand 2017-11-24T13:44:01.000079Z

then you would mess with *1 *2 etc.

cgrand 2017-11-24T13:44:34.000115Z

and user wouldn’t able to browse past result whilst something is evaling

volrath 2017-11-24T13:44:40.000240Z

yes that's what I thought, but then how can I keep them synced?

volrath 2017-11-24T13:45:29.000355Z

If we want print-length at, say, 25.. the first result will always be elided at 10, right?

cgrand 2017-11-24T13:46:38.000412Z

depends on which conn you issue print-limits

baptiste-from-paris 2017-11-24T13:47:23.000188Z

if you guys have some time for some basic stuff I would very grateful I got how socket-connector work and why you use make-strip I am struggling to understant the safe-read-string part 😞

volrath 2017-11-24T13:48:20.000228Z

yes, but it's kinda the same problem as resolving elisions on user, setting print-limits in user would also mess *1 *2 *3...

volrath 2017-11-24T13:48:40.000382Z

but I guess it's not a big deal for now

pesterhazy 2017-11-24T13:49:31.000168Z

@baptiste-from-paris can you point to a line in the code?

baptiste-from-paris 2017-11-24T13:50:09.000236Z

unravel.network ns line 47 => (when-let [[v rst] (ul/safe-read-string (.toString buf))]

cgrand 2017-11-24T13:51:00.000120Z

@volrath, wait I’ve an ace into my sleeve! unrepl/do!

pesterhazy 2017-11-24T13:51:33.000265Z

read-string throws an exception if it cannot read the string, perhaps because it has unbalanced parens

pesterhazy 2017-11-24T13:52:14.000265Z

hm or maybe it doesn't, wait...

pesterhazy 2017-11-24T13:52:58.000103Z

maybe that used to be the case (hence the name) but currently "safe" is not a good name for the function 🙂

pesterhazy 2017-11-24T13:53:25.000127Z

it basically reads the next form, returns that PLUS the rest of the string

pesterhazy 2017-11-24T13:54:25.000208Z

it's used because it's a stream of EDN values

baptiste-from-paris 2017-11-24T13:54:26.000303Z

it might be newbish to ask that but what this binding is actually doing ?

(binding [reader/*default-data-reader-fn* tagged-literal
            reader/*data-readers* ut/tag-map]
    (let [r (reader-types/string-push-back-reader s)]
      [(reader/read r)
       (uu/unblank (clojure.string/trim (read-chars r)))]))

baptiste-from-paris 2017-11-24T13:54:29.000021Z

binding *

pesterhazy 2017-11-24T13:54:44.000131Z

this is a sort of implicit parameter for the reader

volrath 2017-11-24T13:54:46.000182Z

I don't follow 😳

volrath 2017-11-24T13:55:00.000178Z

how would you use it?

pesterhazy 2017-11-24T13:55:12.000017Z

it makes sure that tagged literals are returned as defrecords

pesterhazy 2017-11-24T13:55:36.000161Z

binding sets up a dynamic variable context (think of it as setting the variable, then restoring it at the end of the block)

baptiste-from-paris 2017-11-24T13:57:28.000231Z

thanks ! it makes sure that tagged literals are returned as defrecords => that’s what I was looking for

pesterhazy 2017-11-24T13:58:08.000213Z

there's also special handling for elisions and vars (these are printed in a special way)

cgrand 2017-11-24T13:58:13.000189Z

@volrath there’s definitely something fishy

cgrand 2017-11-24T13:59:05.000014Z

now I realize that set-file-line-col doesn’t quite work

cgrand 2017-11-24T13:59:25.000341Z

well it works but only from user maybe it’s ok

baptiste-from-paris 2017-11-24T14:00:11.000351Z

thanks @pesterhazy

pesterhazy 2017-11-24T14:00:27.000526Z

sure thing! feel free to ask question about the code btw

baptiste-from-paris 2017-11-24T14:00:57.000395Z

thanks !

cgrand 2017-11-24T14:09:54.000305Z

@volrath emitting commands on user is baaaaad (first rule of unrepl), unrepl/do is thus an abomination,

volrath 2017-11-24T14:10:27.000081Z

haha noted 😐

cgrand 2017-11-24T14:11:01.000181Z

the problem is that we are trying to modify dynamic bindings of one connection from another one

volrath 2017-11-24T14:12:10.000270Z

right.. don't they all share a common state? tbh I have very little insight of the deep ends of unrepl, but I've noticed that If I open two user connections to the same socket repl, they share state

volrath 2017-11-24T14:12:42.000222Z

i.e. If i require a namespace in conn1, I can use it in conn2 without requiring it

volrath 2017-11-24T14:13:17.000457Z

plus, everything that I define in conn1, I can use in conn2

cgrand 2017-11-24T14:14:09.000399Z

yes they are not isolated clojure instances

volrath 2017-11-24T14:14:11.000060Z

now, I'm guessing that's mostly because in this scenario, both conns are on user.. but couldn't we just create a aux/tooling namespace that unrepl knows to check for common variables

cgrand 2017-11-24T14:14:16.000284Z

(boot pods)

cgrand 2017-11-24T14:20:53.000093Z

@pesterhazy in Chez how do you transition to viewing the whole form when you see only the first?

pesterhazy 2017-11-24T14:21:15.000068Z

^L

pesterhazy 2017-11-24T14:21:38.000193Z

it's really quite natural - that's readline's default binding for "redraw the current line"

pesterhazy 2017-11-24T14:22:17.000071Z

also, using the down key you can cycle through the lines (not sure how useful that feature is)

cgrand 2017-11-24T14:22:19.000195Z

I’m not sure all potential users are so readline experts

pesterhazy 2017-11-24T14:22:47.000037Z

Alt-up and Alt-down navigates history on a strict first-line-only basis

pesterhazy 2017-11-24T14:23:18.000185Z

are you on macos? it's pretty easy to install brew install --HEAD michaelballantyne/homebrew-chez/chez-scheme

pesterhazy 2017-11-24T14:23:28.000330Z

(I think you need quartz too for some reason)

pesterhazy 2017-11-24T14:24:03.000039Z

not all users are readline nerds, but many command line powerusers are - and we're trying to reach those

pesterhazy 2017-11-24T14:32:46.000141Z

Question: right now unravel starts in the unrepl.replG__20 ns - should we make sure the repl starts in user?

pesterhazy 2017-11-24T14:32:56.000223Z

Or is it better to isolate each session?

cgrand 2017-11-24T14:33:43.000057Z

unrepl.replG__20is wrong and fixed in recent blobs (eg in multiline it starts on user)

baptiste-from-paris 2017-11-24T14:33:57.000095Z

so @pesterhazy, to be clear, the safe-read-string transforms input text from unrepl into it’s cljs form which where you can process it by following the unrepl protocol right ?

pesterhazy 2017-11-24T14:34:19.000155Z

@baptiste-from-paris yeah it reads a form

baptiste-from-paris 2017-11-24T14:34:44.000047Z

an unrepl spec one ?

cgrand 2017-11-24T14:34:46.000162Z

maybe we can rename user to get-your-own-ns

pesterhazy 2017-11-24T14:35:49.000216Z

@baptiste-from-paris like this (read-string "[:foo] [:bar]")

pesterhazy 2017-11-24T14:36:05.000051Z

unrepl.replG__20=> (read-string "[:foo] [:bar]")
[:foo]

pesterhazy 2017-11-24T14:36:36.000321Z

this is clojure's read-string, the function is unravel is similar except that it returns the remaining string as well

pesterhazy 2017-11-24T14:36:46.000006Z

what do you mean by spec?

baptiste-from-paris 2017-11-24T14:36:52.000101Z

yes I know what read-string is supposed to do, but the kind of message that it reads follow the unrepl protocol

pesterhazy 2017-11-24T14:37:03.000015Z

yeah exactly

baptiste-from-paris 2017-11-24T14:37:13.000121Z

that’s what I was trying to ask ^^

pesterhazy 2017-11-24T14:37:19.000109Z

you can check by passing --debug - it will print all messages

pesterhazy 2017-11-24T14:37:29.000467Z

at the cost of making it unusable because of all the noise 🙂

baptiste-from-paris 2017-11-24T14:37:52.000030Z

Yes I’ve seen it !

pesterhazy 2017-11-24T14:37:55.000114Z

@cgrand you mean like passing a --init-ns my.core option?

baptiste-from-paris 2017-11-24T14:38:03.000164Z

thx

pesterhazy 2017-11-24T14:38:24.000106Z

it would be cool to have a --debug-out argument, so you can tail that file in another terminal

pesterhazy 2017-11-24T14:38:40.000188Z

you can see debug messages and still actually use the prompt

cgrand 2017-11-24T14:40:42.000182Z

no, I didn’t mean much that users in shared env should have the habit to swicth ns

cgrand 2017-11-24T14:40:54.000409Z

maybe a conf file

baptiste-from-paris 2017-11-24T14:41:00.000359Z

you mean a read-only terminal ?

cgrand 2017-11-24T14:41:27.000113Z

yeah he means tail -f debug.log in another term

baptiste-from-paris 2017-11-24T14:41:33.000253Z

yep

baptiste-from-paris 2017-11-24T14:42:31.000204Z

you could pipe out to a file then

(defn err-prn
  "Print directly to stderr, circumventing *out*"
  [& args]
  ;; TODO: flush?
  (.write js/process.stderr (apply prn-str args)))

pesterhazy 2017-11-24T14:43:08.000390Z

yeah stderr would work too, true

volrath 2017-11-24T14:43:27.000220Z

@pesterhazy when I was working on the side loader and copying from unravel's sideloader branch, I used to do: ./scripts/run localhost 5555 2> debug.log then tail that.. it works. definitely easier with an argument though

pesterhazy 2017-11-24T14:43:32.000086Z

oh your point is that it already writes to stderr, forgot about that!

pesterhazy 2017-11-24T14:43:37.000167Z

sweet

cgrand 2017-11-24T14:43:49.000177Z

0-line feature achieved!

pesterhazy 2017-11-24T14:44:04.000042Z

the best feature is the one that doesn't have to be implemented

volrath 2017-11-24T14:44:09.000220Z

hahaha

baptiste-from-paris 2017-11-24T14:44:19.000045Z

😂

pesterhazy 2017-11-24T15:00:06.000415Z

@cgrand can't reproduce the autodoc issue right now?!

cgrand 2017-11-24T15:02:27.000284Z

@pesterhazy ^^ not like Chez

cgrand 2017-11-24T15:03:41.000147Z

me neither

cgrand 2017-11-24T15:04:02.000199Z

I’ve never really qualified the issue, so it may have been a dev glitch

pesterhazy 2017-11-24T15:05:05.000360Z

let's consider it 0-line fixed then

pesterhazy 2017-11-24T15:06:17.000256Z

one more question about the PR ^^

pesterhazy 2017-11-24T15:25:27.000057Z

@cgrand, do you commit a new blob to the repo when you update unrepl's master? Or are consumers expected to run lein unrepl-make-blob themselves?

pesterhazy 2017-11-24T15:31:54.000093Z

@cgrand, latest blob seems to break the tests: https://github.com/Unrepl/unravel/pull/40

Error: stream.push() after EOF

pesterhazy 2017-11-24T15:32:26.000001Z

it also returns #unrepl/ns user - should I just unwrap that on the client side?

volrath 2017-11-24T15:32:43.000238Z

latest blob has a new #unrepl/quote tag that, tbh, i don't know what is it for haha, so I'm on master~1

pesterhazy 2017-11-24T15:34:54.000211Z

hehe

cgrand 2017-11-24T15:35:59.000233Z

s**t indeed I messed up with unrepl/quote

cgrand 2017-11-24T15:47:15.000093Z

better but still broken

cgrand 2017-11-24T17:46:59.000007Z

I have tweaked the packed printer, it gives interesting results.

pesterhazy 2017-11-24T17:48:09.000153Z

@cgrand, what's the advantage over clojure.pprint?

cgrand 2017-11-24T17:53:10.000186Z

=> (binding [clojure.pprint/*print-right-margin* 30]
     (clojure.pprint/pprint {:a :b :c {:e :f :g :h :i :j :k :l} :m :n :o {:p {:q :r :s :t}}}))
{:a :b,
 :c
 {:e :f,
  :g :h,
  :i :j,
  :k :l},
 :m :n,
 :o {:p {:q :r, :s :t}}}
nil

cgrand 2017-11-24T17:53:28.000015Z

=> (pprint {:a :b :c {:e :f :g :h :i :j :k :l} :m :n :o {:p {:q :r :s :t}}} :width 30)
{:a :b, :c {:e :f, :g :h,
            :i :j, :k :l},
 :m :n, :o {:p {:q :r, :s :t}}}

cgrand 2017-11-24T17:54:18.000042Z

=> (czprint {:a :b :c {:e :f :g :h :i :j :k :l} :m :n :o {:p {:q :r :s :t}}} 30 {:map {:nl-separator? true}})

{:a :b,
 :c {:e :f,
     :g :h,
     :i :j,
     :k :l},
 :m :n,
 :o {:p {:q :r, :s :t}}}

cgrand 2017-11-24T17:54:30.000216Z

Mine is the middle one

cgrand 2017-11-24T17:55:52.000050Z

It’s relatively small, open (like fipp it works on a stream of spans)

pesterhazy 2017-11-24T18:09:32.000163Z

pretty cool!

pesterhazy 2017-11-24T18:09:49.000216Z

It would be great to have pluggable printers in unravel

pesterhazy 2017-11-24T18:11:39.000016Z

You could even switch the printer "live"

pesterhazy 2017-11-24T18:12:33.000057Z

"That's not readable - let me switch to packed layout"

pesterhazy 2017-11-24T18:12:42.000060Z

I've wished for that many times

cgrand 2017-11-24T20:59:38.000065Z

clojure.pprint doesn’t give us enough control (eg elisions rendering). Both fipp and packed work on an intermediate representation. I believe that such an intermediate representation is a good integration point.

cgrand 2017-11-24T21:18:18.000197Z

Quoting intend to make it possible to not have display glitches when working on unrepl source code – granted it’s a niche

cgrand 2017-11-24T21:48:28.000019Z

There are three stages: 1/ data -> spans (`spans`) 2/ spans -> layout (`layout`) 3/ layout -> io (`render`) The main stage is the second one and has simple inputs and outputs