Stream: show and tell

Topic: Porting Gleam's Squirrel to Roc -- SQL to Roc code gen


view this post on Zulip Stuart Hinson (Oct 12 2024 at 09:31):

Rocky the Flying Squirrel, a port of Gleam's Squirrel, generates the code needed to run Postgres SQL queries easily within Roc applications :tada:

Note that it's at the embarrassingly early stage, but expect improvements soon. Feedback and PRs appreciated!

https://github.com/stuarth/rocky-the-flying-squirrel

view this post on Zulip Sam Mohr (Oct 12 2024 at 09:42):

Woah, super cool! This is yet another tool leaning into the benefits of codegen for filling the hole that macros want to fill (but probably shouldn't).

view this post on Zulip Sam Mohr (Oct 12 2024 at 09:43):

I've never used Gleam's Squirrel myself, my main experience similar to this is Rust's sqlx, which usually does this with procedural macros, but works pretty similarly if you squint a little

view this post on Zulip Sam Mohr (Oct 12 2024 at 09:44):

Do you have experience using this kind of tool in a project? It looks like the right idea, but you never know how good a tool is until you use it.

view this post on Zulip Sam Mohr (Oct 12 2024 at 09:53):

Also, very relatable comment haha

view this post on Zulip Stuart Hinson (Oct 12 2024 at 10:02):

Yep, definitely closely related to sqlx as well!

Do you have experience using this kind of tool in a project? It looks like the right idea, but you never know how good a tool is until you use it.

Limited to sqlx actually, which I enjoy. Fingers crossed it'll carry over well to Roc, but we'll see!

view this post on Zulip Agus Zubiaga (Oct 12 2024 at 12:33):

Woah! This is so cool. I think this direction makes a lot of sense, it's hard to beat raw SQL and getting type safety is awesome :heart_eyes:

view this post on Zulip Agus Zubiaga (Oct 12 2024 at 12:35):

As soon as I'm done with purity inference, I'm going to update roc-pg to the newer stuff. (I know you must be getting quite a few backpassing warnings right now :upside_down:)

view this post on Zulip Isaac Van Doren (Oct 12 2024 at 14:17):

That is awesome! I am a big fan of writing sql by hand so very glad to see this :big_smile:

view this post on Zulip Zeljko Nesic (Oct 12 2024 at 17:45):

SUPER COOL!
I have always wanted to do this, but couldn't find the time to sit down and do it!

I have another idea of maintaining declarative structure of DB that would diff existing db and generate a diff that could be executed in order to catch up with the declared schema.
Great job, I will start playing with it on Monday!


Last updated: Jul 06 2025 at 12:14 UTC