Stream: ideas

Topic: Literate Roc


view this post on Zulip Hannes (Mar 15 2024 at 09:24):

A workflow that I think Roc would be well suited to is literate programming, but before I start trying to implement anything, I want to know if it's even possible with the current Roc ecosystem.

I'm imagining the output to be a document alternating between a Roc expression and a representation of the value of the expression. I don't think there is a way for a platform to parse Roc code or run it like how some languages have an eval function. Instead, maybe an external program could take a Roc script, split it into all the different assignment statements, run the first one and get the value of the variable, then run the first and second and get the value of the second variable, etc.

Can anyone think of a better way to do something like this?

Thanks :grinning_face_with_smiling_eyes:

view this post on Zulip Anton (Mar 15 2024 at 09:54):

@Ayaz Hafiz once made a small jupyter notebook kernel for Roc, I can't find the source though...

view this post on Zulip Hristo (Mar 15 2024 at 10:25):

I'm also working on an IPython/Jupyter kernel for Roc as well!
I didn't know that there have been any previous efforts :man_facepalming: and I wanted to keep it as a surprise (I haven't brought it yet to a stage where I'm ready to share it in #show and tell).

view this post on Zulip Anton (Mar 15 2024 at 13:03):

Exciting :)

view this post on Zulip Ayaz Hafiz (Mar 16 2024 at 00:48):

here's the kernel i made a long time ago if someone wants to use it to base their own work off https://gist.github.com/ayazhafiz/2ecb5d07393421c06fde945784efb384

view this post on Zulip Ayaz Hafiz (Mar 16 2024 at 00:49):

corresponding patch for the compiler: https://github.com/roc-lang/roc/commit/888812b6d8f4efb34d137a4dd29d245ae8685e2a

view this post on Zulip Anton (Mar 16 2024 at 09:41):

Thanks for sharing @Ayaz Hafiz :)


Last updated: Jun 16 2026 at 16:19 UTC