unrepl

discussing specification of an edn-based repl and its implementations.
cgrand 2018-03-02T09:23:54.000023Z

not tied to unrepl but to tooling in general: scavenging the Eclipse incremental Java Compiler and repurposing as either a standalone agent or a plain lib started in a repl session would be useful. clj and such a lib/agent would be enough to do mixed projects

bozhidar 2018-03-02T10:49:56.000381Z

I wonder if anyone’s using Eclipse these days, apart from people in IBM and SAP. 🙂 When I started doing Java long time ago I was an Eclipse user myself, but when I swithed to IDEA I felt enlightened. Eclipse innovated very slowly and couldn’t get even basic things like git and maven integration, right, IDEA on the other hand felt like a speedtrain and always delivered tools to alleviate known pain points and leverage new trends in development.

bozhidar 2018-03-02T10:50:27.000001Z

But I guess you want to use the compiler only, not build something for Eclipse itself.

cgrand 2018-03-02T10:51:16.000365Z

That’s it, feasting on the carcass.

🦗 1
🦅 1
cgrand 2018-03-02T11:10:32.000405Z

Back to unrepl. I have in mind of adding a very small unrepl.core namespace which would not be shaded in blobs.

cgrand 2018-03-02T11:13:33.000140Z

Why? as one can do (clojure.main/repl ...) or even better (->> (read) eval prn (while true)) to upgrade their repl session I’d like to expose equivalent facilities.

volrath 2018-03-02T11:23:07.000269Z

as .cljc or just .clj? either way I like the idea

cgrand 2018-03-02T11:47:45.000390Z

the question is not really about the source file extension but, I guess, about cross-platform availability

cgrand 2018-03-02T11:48:18.000289Z

because of the async env of JS the API may have to diverge

cgrand 2018-03-02T11:49:04.000185Z

is it problematic to have one ns to host different definitions depending on the env?

cgrand 2018-03-02T11:49:26.000214Z

(as long as we don’t reuse names with different semantics)

2018-03-02T13:00:22.000079Z

The magic tagging is a pain.

cgrand 2018-03-02T13:13:24.000438Z

?

2018-03-02T13:29:21.000184Z

Vim cannot have compound map keys. The you got a map with symbol keys? Then I get a magically tagged alist having very fun accessing the innards......

2018-03-02T13:34:43.000362Z

Vim has no symbols. And no vectors/list duality. So I get "foo" vs. {"edn/symbol": "foo"}. And ["foo"] vs. {"edn/list": ["foo"]}

cgrand 2018-03-02T13:34:56.000482Z

I think that vimpire needs to modify the write part of unrepl.

2018-03-02T13:35:54.000022Z

I thought about a helper for one way simplification where needed.

cgrand 2018-03-02T13:36:36.000532Z

what would be easy for vimscript to read? (“nothing” chants the crowd)

2018-03-02T13:36:42.000255Z

Only the actions are problem. For consumption there can be ambiguety.

cgrand 2018-03-02T13:37:05.000048Z

I see

cgrand 2018-03-02T13:39:35.000465Z

so removing ambiguity everywhere would increase complexity, right?

cgrand 2018-03-02T13:41:00.000329Z

One issue is that embedded actions are contextual: they are not tagged you have to understand the structure of the message to know what is an action and what is “just data”

cgrand 2018-03-02T13:47:17.000213Z

well actions are not sprinkled everywhere (except elisions which are tagged) so it may be doable to have a post-processing of the edn to transform actions into something more palatable for vim

2018-03-02T13:54:50.000222Z

The actions are not really a problem in handling. They are from known sources. And are traversed for params. Not really a problem. The payload of events is the issue. Case: : prompt. But these are not sent back. So I can munge them.

cgrand 2018-03-02T13:55:43.000460Z

Do you have a concrete example?

2018-03-04T10:38:24.000072Z

The example from the SPEC for prompt is parsed as follows:

2018-03-04T10:38:34.000021Z

[':prompt', {'edn/map': [[':file', 'unrepl-session'], [':line', 1], [':column', 1 ], [':offset', 0], [{'edn/symbol': 'clojure.core/warn-on-reflection'}, v:null], [{'edn/symbol': 'clojure.core/ns'}, {'edn/tag': 'unrepl/ns', 'edn/value': {'edn/ symbol': 'user'}}]]}]

2018-03-04T10:38:53.000015Z

The interesting part is the very last 'user'.

2018-03-04T10:39:39.000036Z

So this is the code I need to get there:

2018-03-04T10:39:40.000057Z

for [ k, v ] in a:response[1]["edn/map"] if type(k) == v:t_dict \ && has_key(k, "edn/symbol") \ && k["edn/symbol"] == "clojure.core/ns" let a:this.namespace = v["edn/value"]["edn/symbol"] break endif endfor

2018-03-04T10:40:26.000067Z

Where I'd like to do: let a:this.namespace = a:response[1]["clojure.core/ns"]

2018-03-04T10:41:45.000024Z

I'll write a simplifier to apply in such cases, which translates for example list or symbols to vim lists and strings. The means, I cannot distinguish lists and vectors anymore. As well as symbols and strings.

2018-03-04T10:41:54.000035Z

But in this side, I don't have to anyway.

2018-03-04T10:42:34.000003Z

Elisions can be special cased to be left alone. But I don't need their contents, since they act as a template only.

cgrand 2018-03-04T12:17:53.000078Z

Why not use a serialized representation for keys?

cgrand 2018-03-04T12:19:31.000034Z

Aka don’t parse strings or symbols or keywords.

2018-03-04T19:10:38.000014Z

Serialized represantation?

cgrand 2018-03-04T19:20:26.000079Z

From what I get keywords are represented as “:kw” then keep on with this trend: “sym” and "\”str\”” etc

2018-03-04T20:57:19.000010Z

Hrm. That would be a possibility.

2018-03-04T20:57:44.000002Z

But maybe the :kw is already a bad idea and should be an edn/keyword map.

cgrand 2018-03-04T21:03:01.000030Z

Actually I think latent parsing (no it’s not a thing I just made the term up) is a good idea.

2018-03-04T21:10:55.000080Z

latent parsing?

cgrand 2018-03-04T21:17:10.000074Z

Parsing where some nodes in the resulting tree are just spans of the actual input.

2018-03-04T21:51:14.000108Z

Hmm... I'm not completely convinced. It may work with keywords, symbols and strings, because you can use the first character to discriminate the type.

2018-03-04T21:51:30.000016Z

But it breaks down with tagged values.

2018-03-04T21:52:45.000067Z

There you can still use # for the dispatch in the string, but you cannot access to payload easily.

2018-03-04T21:52:58.000071Z

Then you need again to fire up the parser.

cgrand 2018-03-04T23:49:19.000154Z

Are there tagged values used as keys?

2018-03-05T06:03:18.000169Z

Dunno hopefully not. This maybe a question, how general purpose the parser should be. Also keeping strings as double quoted puts the escape burden on the user. Not nice.

2018-03-05T06:04:15.000165Z

Fluffing around with strings.... Don't want that. This should be handled by the system.

cgrand 2018-03-05T07:54:57.000318Z

Treat strings as opaque and provide fns to check the actual type etc

cgrand 2018-03-05T07:57:08.000069Z

General purpose parser is somehow a sub project of its own. Parsley Clojure parser has been detrimental to CCW imo. However it has somehow succeeded on its own (because of an empty ecosystem niche)

2018-03-05T08:37:31.000335Z

It's also the other way: I can't just stick a string in. And that's almost always what I want to do. But then it would be considered a symbol. So I must wrap it in ". But now I also have to take care that things are escaped correctly. Bleh. :-(

2018-03-05T08:40:11.000093Z

But that might be an encoding issue. Maybe a prefix is better: :: keyword, ': symbol, s: string. And hope that there are no tagged literal as key. (#inst anyone?)

2018-03-05T08:45:30.000086Z

In the end it boils down to intended usage: Do I want a full blown parser/generator for EDN? Or is the need for vimpire more important/sufficient. Actually I need both. The first for the actions which have to be traversed for parameter replacement (so no opaque tagged literals!) and have to produce exact EDN. Then the latter for the tooling interaction, where ease of accessibility is key. But there I don't need sets or symbols. There I can live a simplified translation.

cgrand 2018-03-05T10:02:18.000117Z

yeah you could also introduce you own serialization to encode as strings all kind of keys. However if you really want to be generic then: what when you get maps as keys? You would need to write a canonicalization algorithm for maps to be independent of the key order...

cgrand 2018-03-05T10:03:57.000471Z

I disagree that you need a full blown parser to perform substitutions. It can be done at the string level (extra points for taking care to figure out that you are not in an escaped context (eg string))

2018-03-05T10:14:05.000044Z

String level? With escaped context? And who got that ever right?

cgrand 2018-03-05T10:16:52.000213Z

framed like that it feels preposterous to say “me” but.. in the blob generation code, the regex-from-hell-that-blows-stupid-Java-regex-matching or the hand crafted state-machine that replaces it.

cgrand 2018-03-05T10:17:35.000322Z

This state machine knows if you are in normal code or in some escaped context.

cgrand 2018-03-02T16:21:20.000220Z

So now one can use unrepl.core/write and unrepl.core/non-eliding-write (total-write. full-write, write++?)

cgrand 2018-03-02T21:07:30.000442Z

@igor.i.ges hi!

dominicm 2018-03-02T22:03:15.000334Z

https://github.com/cgrand/seqexp/blob/master/README.md you and rich have a shared way of thinking @cgrand

dominicm 2018-03-02T22:03:33.000357Z

(Or you're good at understanding him!)

richiardiandrea 2018-03-02T22:06:43.000131Z

Wow that is handy!

cgrand 2018-03-02T22:07:35.000522Z

Before that there was @chouser’s seqex iirc.

👏 1
cgrand 2018-03-02T22:08:12.000242Z

I still has plan to make seqexp and xforms to meet.

👍 1