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.
@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).
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
roc-platform-builder looks really useful :smiley:
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.
I'm trying to understand what the port is, as compared to that migrate-zig-compiler branch
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.
Luke Boswell said:
I'm trying to understand what the port is, as compared to that
migrate-zig-compilerbranch
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.
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.
Yeah I already got the feeling that there might be some things to iterate on. Looking forward to reading your post.
I don't know if we can really explore it though until we have a working platform and start porting all the examples over.
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
! 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"?!
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
I guess a better example is similar to how Zig is now doing the Io thing and passing that in.
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?
yes exactly!
It's all still so new I don't have any examples to point you to
But it's been on my todo list to make a package that does something as a demo with effectful functions
Like a cross-platform package that does S3 uploads or something like that.
I haven't thought very hard about what a good simple example might be
Last updated: Feb 20 2026 at 12:27 UTC