Fork me on GitHub
#klipse
<
2018-06-06
>
Yehonathan Sharvit04:06:44

@whilo what do you want to achieve exactly?

whilo06:06:52

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.

whilo06:06:12

@viebel I need for instance defquery.

whilo06:06:42

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).

whilo06:06:28

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.

whilo06:06:57

(as a format)

Yehonathan Sharvit07:06:39

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 Sharvit07:06:52

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

Yehonathan Sharvit07:06:16

Thats when you need to define your own macro

whilo09:06:31

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

whilo10:06:57

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.

whilo10:06:55

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.

whilo10:06:23

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

whilo11:06:53

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

whilo11:06:16

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.

whilo11:06:35

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

whilo11:06:04

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

whilo11:06:08

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

Yehonathan Sharvit11:06:09

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

whilo12:06:29

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

whilo12:06:09

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

whilo12:06:02

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

whilo12:06:53

puhh, i have to think about it

whilo12:06:39

the loading of the codebase interacts with macro-expansions

Yehonathan Sharvit12:06:45

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

whilo12:06:42

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

whilo12:06:05

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

whilo12:06:24

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

whilo12:06:12

this is what i have got working

whilo12:06:19

interestingly i can load core.matrix

whilo12:06:54

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

whilo12:06:12

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

Yehonathan Sharvit12:06:01

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

whilo12:06:19

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

whilo12:06:51

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

Yehonathan Sharvit12:06:08

Are you running Klipse locally?

whilo12:06:29

i figured that this gives me a better understanding

whilo12:06:45

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

whilo12:06:57

but i also need plotly plotting for instance

whilo12:06:46

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

whilo12:06:25

but the macro-expansion poses some uncertainty of the feasibility

whilo12:06:34

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

Yehonathan Sharvit12:06:13

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

whilo12:06:34

yes, it shouldn't

whilo12:06:05

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

whilo12:06:26

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

Yehonathan Sharvit12:06:32

Have you taken a look at macrovich?

Yehonathan Sharvit12:06:30

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

whilo12:06:04

somehow i have missed that

whilo12:06:19

thanks a lot, that seems the way to go

Yehonathan Sharvit12:06:38

Let me know when you need further help

whilo12:06:11

btw. thanks for this really awesome project

whilo12:06:35

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

Yehonathan Sharvit12:06:30

@whilo can you please be more specific

whilo12:06:17

where you interleave code snippets with result boxes and markdown segments

whilo12:06:28

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

whilo12:06:47

do you know jupyter for instance?

Yehonathan Sharvit12:06:18

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

Yehonathan Sharvit12:06:47

@whilo What do you mean by standard formats?

whilo12:06:40

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

whilo12:06:57

standard in this sense

Yehonathan Sharvit12:06:03

I use markdown for my blog posts

Yehonathan Sharvit12:06:03

@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

whilo12:06:13

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

whilo12:06:42

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

whilo12:06:56

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

Yehonathan Sharvit12:06:33

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

whilo12:06:58

thanks, that should keep me busy for some time 🙂