Stream: show and tell

Topic: Roc platform builder


view this post on Zulip lozzy (Jan 27 2026 at 20:55):

I have been doing some experiments on how to make building roc platforms in rust easier: https://github.com/johanneshorner/roc-platform-builder
There are no docs, likely a lot of bugs and I'm not sure if the abstractions I have so far are actually useful, so caution is advised :smile: .
So far it tries to shield the user from writing unsafe code and automatically sorts the hosted functions by name.

Here I used the crate to port basic-cli.

view this post on Zulip Luke Boswell (Jan 27 2026 at 20:57):

@lozzy have you heard about roc glue and the design for that? @Dan G Knutson has just started implementing that in #9083 - but the general idea is you give the roc cli a plugin (a RustGlue.roc script) which it uses to codegen all the Roc types (e.g. in Rust).

view this post on Zulip Luke Boswell (Jan 27 2026 at 20:58):

Also there is a PR to migrate basic-cli if you are interested in contributing to that https://github.com/roc-lang/basic-cli/pull/413

view this post on Zulip Luke Boswell (Jan 27 2026 at 21:01):

roc-platform-builder looks really useful :smiley:

view this post on Zulip lozzy (Jan 27 2026 at 21:02):

I haven't seen the roc glue PR. I'll check that out, thanks.

Luke Boswell said:

Also there is a PR to migrate basic-cli if you are interested in contributing to that https://github.com/roc-lang/basic-cli/pull/413

I was about to start on migrating the Http module yesterday but I got distracted :smile: . I'll start a PR in the coming days if no one beats me to it.

view this post on Zulip Luke Boswell (Jan 27 2026 at 21:02):

I'm trying to understand what the port is, as compared to that migrate-zig-compiler branch

view this post on Zulip Luke Boswell (Jan 27 2026 at 21:03):

Yeah if your happy to contribute, that'd be awesome. I'd recommend making another branch that merges into migrate-zig-compiler -- and then CI can do it's thing.

view this post on Zulip lozzy (Jan 27 2026 at 21:05):

Luke Boswell said:

I'm trying to understand what the port is, as compared to that migrate-zig-compiler branch

I pretty much just replaced all of the manual unsafe ptr shenanigans with proc macro magic. So there isn't a lot of difference there.

view this post on Zulip Luke Boswell (Jan 27 2026 at 21:08):

I think there's some R&D or re-design work on that API that we probably need to think about. I've got an idea cooking this morning to post in an ideas thread on something I was exploring with roc-ray, but basically the current API worked with our older syntax but it may not be idiomatic Roc in a static dispatch world.

view this post on Zulip lozzy (Jan 27 2026 at 21:09):

Yeah I already got the feeling that there might be some things to iterate on. Looking forward to reading your post.

view this post on Zulip Luke Boswell (Jan 27 2026 at 21:09):

I don't know if we can really explore it though until we have a working platform and start porting all the examples over.

view this post on Zulip Luke Boswell (Jan 28 2026 at 07:38):

I ran out of steam and never got around to posting about the API idea I had... but you can see the latest design in this roc-ray example https://github.com/lukewilliamboswell/roc-ray/blob/new-compiler/examples/read_env.roc

The idea is to pass in a "host" which has effectful methods on it

view this post on Zulip lozzy (Jan 28 2026 at 18:44):

! Very limited knowledge of old and new compiler ahead !
Wouldn't that break the pattern that roc packages used in the past to get access to effectful functions? For example in https://github.com/imclerran/roc-ai/blob/main/package/Toolkit/FileSystem.roc the module takes some effectful functions as input and then provide something new wrapping these functions.
If the effectful functions are now methods on an object you lose this paradigm as you cannot pass the host object at "import time"?!

view this post on Zulip Luke Boswell (Jan 29 2026 at 09:40):

Ah the module params thing... we decided that that wasn't the right design for Roc. Instead the preference is to feed things through arguments. Like a Ctx object or similar

view this post on Zulip Luke Boswell (Jan 29 2026 at 09:41):

I guess a better example is similar to how Zig is now doing the Io thing and passing that in.

view this post on Zulip lozzy (Jan 29 2026 at 09:51):

I see. So for a example a function exposed by a package could take some type (which represents the host and its effectful functions) as an argument and require it to implement read_env and stdout_write using a where clause?

view this post on Zulip Luke Boswell (Jan 29 2026 at 09:53):

yes exactly!

view this post on Zulip Luke Boswell (Jan 29 2026 at 09:54):

It's all still so new I don't have any examples to point you to

view this post on Zulip Luke Boswell (Jan 29 2026 at 09:54):

But it's been on my todo list to make a package that does something as a demo with effectful functions

view this post on Zulip Luke Boswell (Jan 29 2026 at 09:55):

Like a cross-platform package that does S3 uploads or something like that.

view this post on Zulip Luke Boswell (Jan 29 2026 at 09:55):

I haven't thought very hard about what a good simple example might be


Last updated: Feb 20 2026 at 12:27 UTC