@whilo what do you want to achieve exactly?
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.
@viebel I need for instance defquery.
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).
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.
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/
(as a format)
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
1. The namespace must end with $macros 2. You must call the macro by its fully qualified name
Thats when you need to define your own macro
Is that your case @whilo?
Yes. I need to be able to do macro-expansion at runtime.
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.
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.
So I think I need to support load-fn for these macro namespaces in the klipse evaluator?
This happens through external-libs, as I can see.
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.
Especially because I need to adjust all the macro code and figure that out.
Is there a way a to make namespaces of the host available? I see klipse.lang.clojure.bundled-namespaces
I might be missing a crucial pointer to do so, I am taking a look at the examples.
@whilo What do you mean by: 1. the code is not public 2. inject the anglican namespaces directly from figwheel Klipse REPL
1. it is not yet pushed to a public repo (it will be)
2. i would like to make (:require [anglican.runtime :refer [...]]) work in my klipse repo first
maybe the external loading is ok though. but going through all the indirections is harder to understand in the beginning
puhh, i have to think about it
the loading of the codebase interacts with macro-expansions
@whilo Can you share a webpage/jsfiddle that shows your work in progress?
i don't have something reasonable to present in this direction. i have just got simple macro-expansions to work for some anglican macros
i am just wondering how do i load a full library into klipse including runtime macro-expansion
if there is some example for this, i will try to first follow it before i come with more questions
Have you tried something like this? @whilo http://app.klipse.tech/?cljs_in=(ns%20my.m%24macros)%0A(defmacro%20foo%20%5Bx%5D%20%60(if%20~x%20~x%20false))%0A%0A(macroexpand%20'(my.m%2Ffoo%201))%0A
this is what i have got working
interestingly i can load core.matrix
ideally i would like to load anglican cljs functions as well, but i realized that they interleave with the macros
so probably i have to load everything in the klipse eval function
wait a minute
@whilo what external-libs are you providing to Klipse in order to load core.matrix
?
I have done a first dirty hack and gone in klipse.lang.clojure and included
@whilo uploaded a file: https://clojurians.slack.com/files/U1C36HC6N/FB1U7GDCY/-.txt
with the original idea of setting up eval so that it can access these "hosted" functions directly
Are you running Klipse locally?
yes
Oh! I see
i figured that this gives me a better understanding
in the end i would like to use the hosted klipse, if this is possible
but i also need plotly plotting for instance
we have a bunch of gorilla worksheets that i would emit into a klipse style worksheet, if everything goes as planned
but the macro-expansion poses some uncertainty of the feasibility
i thing it is a bit of a stretch for self-hosted cljs maybe
@whilo Plotly plotting should not be an issue I’m still trying to understand exactly what is you issue with macro-expansion
yes, it shouldn't
how would i load anglican properly, assuming that i port its macros to properly named namespaces?
i have a WIP version that works with normal cljs (the released Anglican only works in Clojure)
Have you taken a look at macrovich?
It simplifies a lot the write of self-host compatible macros
cool!
somehow i have missed that
thanks a lot, that seems the way to go
happy to help.
Let me know when you need further help
btw. thanks for this really awesome project
are there some standard formats or environments for worksheet style documents with klipse?
@whilo can you please be more specific
?
like https://markbastian.github.io/posts-output/2017-07-10-polymacro/ but also with plotting maybe(?)
where you interleave code snippets with result boxes and markdown segments
ideally they would be editable, but this is not necessary right now
do you know jupyter for instance?
Yes
I’d love to have some contribute to Klipse and make it like jupyter client side
@whilo What do you mean by standard formats?
whether there is something in this direction already that people tend to use to build klipse documents (beyond plain HTML)
standard in this sense
I use markdown for my blog posts
ok, cool
@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
Also, for “Function plot” http://blog.klipse.tech/data/2017/03/28/function-plot.html
i see. yes, this sounds interesting. i will take a look
how would i properly load anglican (with macrovich macros) into klipse?
through external-libs? or can i somehow load it also from the "classpath"
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
thanks, that should keep me busy for some time 🙂
Enjoy! 😎