klipse

Yehonathan Sharvit 2018-06-06T04:14:44.000208Z

@whilo what do you want to achieve exactly?

whilo 2018-06-06T06:37:52.000360Z

Anglican uses a continuation passing style transform to compile probabilistic programs (special forms it defines as a DSL) into Clojure. This happens at macro-expansion time.

whilo 2018-06-06T06:38:12.000173Z

@viebel I need for instance defquery.

whilo 2018-06-06T06:38:42.000182Z

I would like to render these Gorilla sheets with Klipse into interactive worksheets for the Browser (at least for examples where the inference is not too compute heavy).

whilo 2018-06-06T06:39:28.000186Z

I have managed to get the macro-expansion work in a normal ClojureScript compilation, but I am trying to figure out right now how to do it in self-hosted cljs and in particular in klipse.

whilo 2018-06-06T06:51:41.000088Z

I have found https://markbastian.github.io/posts-output/2017-07-10-polymacro/ and think this is pretty close to what I would love to have: https://markbastian.github.io/posts-output/2017-07-10-polymacro/

whilo 2018-06-06T06:51:57.000164Z

(as a format)

Yehonathan Sharvit 2018-06-06T07:09:39.000311Z

In self hosted cljs, there is a special syntax for macro definition and usage. Take a look here for example http://blog.klipse.tech/clojure/2016/05/01/macro-tutorial-1.html

Yehonathan Sharvit 2018-06-06T07:12:52.000079Z

1. The namespace must end with $macros 2. You must call the macro by its fully qualified name

Yehonathan Sharvit 2018-06-06T07:13:16.000218Z

Thats when you need to define your own macro

Yehonathan Sharvit 2018-06-06T07:13:30.000136Z

Is that your case @whilo?

whilo 2018-06-06T09:24:31.000220Z

Yes. I need to be able to do macro-expansion at runtime.

whilo 2018-06-06T10:23:57.000051Z

Ideally I would like to make the normal Anglican Clojure/Script macro namespaces just loadable in klipse. I have managed to get some basic macros working.

whilo 2018-06-06T10:24:55.000405Z

I am atm. also using ns-publics from cljs.core in one of them, which causes a problem, but I might be able to AOT expand these expressions somehow.

whilo 2018-06-06T10:25:23.000353Z

So I think I need to support load-fn for these macro namespaces in the klipse evaluator?

whilo 2018-06-06T11:02:53.000084Z

This happens through external-libs, as I can see.

whilo 2018-06-06T11:37:16.000027Z

The external loading concept for github won't work for me, because the code is currently not public (not to my choice). I would prefer to somehow inject the anglican namespaces directly from the figwheel klipse REPL, so I can first get some integration working before I factorize Anglican.

whilo 2018-06-06T11:37:35.000118Z

Especially because I need to adjust all the macro code and figure that out.

whilo 2018-06-06T11:38:04.000387Z

Is there a way a to make namespaces of the host available? I see klipse.lang.clojure.bundled-namespaces

whilo 2018-06-06T11:39:08.000234Z

I might be missing a crucial pointer to do so, I am taking a look at the examples.

Yehonathan Sharvit 2018-06-06T11:41:09.000293Z

@whilo What do you mean by: 1. the code is not public 2. inject the anglican namespaces directly from figwheel Klipse REPL

whilo 2018-06-06T12:04:29.000352Z

1. it is not yet pushed to a public repo (it will be)

whilo 2018-06-06T12:05:09.000249Z

2. i would like to make (:require [anglican.runtime :refer [...]]) work in my klipse repo first

whilo 2018-06-06T12:06:02.000506Z

maybe the external loading is ok though. but going through all the indirections is harder to understand in the beginning

whilo 2018-06-06T12:06:53.000061Z

puhh, i have to think about it

whilo 2018-06-06T12:07:39.000003Z

the loading of the codebase interacts with macro-expansions

Yehonathan Sharvit 2018-06-06T12:08:45.000107Z

@whilo Can you share a webpage/jsfiddle that shows your work in progress?

whilo 2018-06-06T12:13:42.000121Z

i don't have something reasonable to present in this direction. i have just got simple macro-expansions to work for some anglican macros

whilo 2018-06-06T12:14:05.000443Z

i am just wondering how do i load a full library into klipse including runtime macro-expansion

whilo 2018-06-06T12:14:24.000440Z

if there is some example for this, i will try to first follow it before i come with more questions

whilo 2018-06-06T12:24:12.000189Z

this is what i have got working

whilo 2018-06-06T12:24:19.000562Z

interestingly i can load core.matrix

whilo 2018-06-06T12:24:54.000122Z

ideally i would like to load anglican cljs functions as well, but i realized that they interleave with the macros

whilo 2018-06-06T12:25:12.000428Z

so probably i have to load everything in the klipse eval function

Yehonathan Sharvit 2018-06-06T12:25:20.000389Z

wait a minute

Yehonathan Sharvit 2018-06-06T12:26:01.000025Z

@whilo what external-libs are you providing to Klipse in order to load core.matrix?

whilo 2018-06-06T12:29:19.000193Z

I have done a first dirty hack and gone in klipse.lang.clojure and included

whilo 2018-06-06T12:29:33.000226Z

@whilo uploaded a file: https://clojurians.slack.com/files/U1C36HC6N/FB1U7GDCY/-.txt

whilo 2018-06-06T12:29:51.000429Z

with the original idea of setting up eval so that it can access these "hosted" functions directly

Yehonathan Sharvit 2018-06-06T12:30:08.000478Z

Are you running Klipse locally?

whilo 2018-06-06T12:30:12.000397Z

yes

Yehonathan Sharvit 2018-06-06T12:30:18.000099Z

Oh! I see

whilo 2018-06-06T12:30:29.000065Z

i figured that this gives me a better understanding

whilo 2018-06-06T12:30:45.000262Z

in the end i would like to use the hosted klipse, if this is possible

whilo 2018-06-06T12:30:57.000460Z

but i also need plotly plotting for instance

whilo 2018-06-06T12:31:46.000459Z

we have a bunch of gorilla worksheets that i would emit into a klipse style worksheet, if everything goes as planned

whilo 2018-06-06T12:31:47.000572Z

https://bitbucket.org/probprog/anglican-examples/

whilo 2018-06-06T12:32:25.000333Z

but the macro-expansion poses some uncertainty of the feasibility

whilo 2018-06-06T12:32:34.000092Z

i thing it is a bit of a stretch for self-hosted cljs maybe

Yehonathan Sharvit 2018-06-06T12:33:13.000376Z

@whilo Plotly plotting should not be an issue I’m still trying to understand exactly what is you issue with macro-expansion

whilo 2018-06-06T12:33:34.000048Z

yes, it shouldn't

whilo 2018-06-06T12:34:05.000515Z

how would i load anglican properly, assuming that i port its macros to properly named namespaces?

whilo 2018-06-06T12:34:26.000031Z

i have a WIP version that works with normal cljs (the released Anglican only works in Clojure)

Yehonathan Sharvit 2018-06-06T12:34:32.000058Z

Have you taken a look at macrovich?

Yehonathan Sharvit 2018-06-06T12:35:04.000270Z

@whilo https://github.com/cgrand/macrovich

Yehonathan Sharvit 2018-06-06T12:35:30.000479Z

It simplifies a lot the write of self-host compatible macros

whilo 2018-06-06T12:36:00.000422Z

cool!

whilo 2018-06-06T12:36:04.000597Z

somehow i have missed that

whilo 2018-06-06T12:36:19.000174Z

thanks a lot, that seems the way to go

Yehonathan Sharvit 2018-06-06T12:36:28.000126Z

happy to help.

Yehonathan Sharvit 2018-06-06T12:36:38.000010Z

Let me know when you need further help

whilo 2018-06-06T12:37:11.000539Z

btw. thanks for this really awesome project

whilo 2018-06-06T12:37:35.000538Z

are there some standard formats or environments for worksheet style documents with klipse?

Yehonathan Sharvit 2018-06-06T12:38:30.000099Z

@whilo can you please be more specific

Yehonathan Sharvit 2018-06-06T12:38:44.000539Z

?

whilo 2018-06-06T12:38:58.000446Z

like https://markbastian.github.io/posts-output/2017-07-10-polymacro/ but also with plotting maybe(?)

whilo 2018-06-06T12:39:17.000036Z

where you interleave code snippets with result boxes and markdown segments

whilo 2018-06-06T12:39:28.000549Z

ideally they would be editable, but this is not necessary right now

whilo 2018-06-06T12:39:47.000009Z

do you know jupyter for instance?

Yehonathan Sharvit 2018-06-06T12:39:53.000307Z

Yes

Yehonathan Sharvit 2018-06-06T12:40:18.000433Z

I’d love to have some contribute to Klipse and make it like jupyter client side

Yehonathan Sharvit 2018-06-06T12:40:47.000252Z

@whilo What do you mean by standard formats?

whilo 2018-06-06T12:41:40.000597Z

whether there is something in this direction already that people tend to use to build klipse documents (beyond plain HTML)

whilo 2018-06-06T12:41:57.000295Z

standard in this sense

Yehonathan Sharvit 2018-06-06T12:42:03.000140Z

I use markdown for my blog posts

whilo 2018-06-06T12:42:22.000039Z

ok, cool

Yehonathan Sharvit 2018-06-06T12:43:03.000331Z

@whilo you might be interested in discovering that there is already an integration of Google Charts with Klipse. See http://blog.klipse.tech/data/2017/03/17/data-driven-documents-google-charts.html We could make something similar for plotly

Yehonathan Sharvit 2018-06-06T12:43:59.000054Z

Also, for “Function plot” http://blog.klipse.tech/data/2017/03/28/function-plot.html

whilo 2018-06-06T12:45:13.000159Z

i see. yes, this sounds interesting. i will take a look

whilo 2018-06-06T12:45:42.000347Z

how would i properly load anglican (with macrovich macros) into klipse?

whilo 2018-06-06T12:46:56.000372Z

through external-libs? or can i somehow load it also from the "classpath"

Yehonathan Sharvit 2018-06-06T12:48:33.000180Z

external-libs is the simpler option but it has a performance hit at loading time Here are the instructions for adding a lib to the classpath: https://github.com/viebel/klipse/blob/master/contributing.md#update-clojurescript-analysis-cache @whilo

whilo 2018-06-06T12:48:58.000155Z

thanks, that should keep me busy for some time 🙂

Yehonathan Sharvit 2018-06-06T12:49:13.000233Z

Enjoy! 😎