If we're rewriting the compiler, we have an opportunity to rethink some of the less important syntaxes while we're at it. One of those is not just how hosted modules look, but whether we want to have them in the first place. It has been suggested before that we combine them into the platform's main.roc
file, which has some pros and cons:
import Host
main.roc
will start to get pretty bigThat last reason is my biggest concern and why I think a separate module should stay around to make future large-scale platforms not difficult to manage
I think it might be nice to require the hosted module be named Host.roc
and be in the package root folder, though, to enforce a degree of stylistic consistency that shouldn't get in anyone's way with respect to writing clean, useful code
I feel like the platform main makes reasonable sense. That file is generally empty otherwise. It makes sense for it to hold the full interface to the host.
But that isn't a very strong feeling
I wonder if there is an overall better design....
It might be nice to put those hosted annotations at the bottom of the file
Because right now, the header is maybe 5-10 lines, and then the "connective tissue" functions between main!
and main_for_host!
is the important part of the file's contents
But in this world, if the hosted annotations are in the header, now the header is like 5-10 lines followed by 50 lines of types, and then the main_for_host!
body is buried under those
I think my concerns go away if we order the content of a platform's main.roc
by importance, namely:
main_for_host!
definitionI think let's leave this as-is for now
the reason we ended up here was because of problems with cyclic imports otherwise
module params are an alternative way to deal with that, but I'd like to not implement module params in the new compiler, and I don't think now is the right time to re-solve that problem :big_smile:
@Anthony Bullard we should keep hosted
modules, then
:+1:
Last updated: Jul 06 2025 at 12:14 UTC