Stream: compiler development

Topic: The future of hosted modules


view this post on Zulip Sam Mohr (Feb 01 2025 at 16:34):

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:

Pros

Cons

view this post on Zulip Sam Mohr (Feb 01 2025 at 16:35):

That 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

view this post on Zulip Sam Mohr (Feb 01 2025 at 16:36):

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

view this post on Zulip Brendan Hansknecht (Feb 01 2025 at 16:39):

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.

view this post on Zulip Brendan Hansknecht (Feb 01 2025 at 16:40):

But that isn't a very strong feeling

view this post on Zulip Brendan Hansknecht (Feb 01 2025 at 16:40):

I wonder if there is an overall better design....

view this post on Zulip Sam Mohr (Feb 01 2025 at 16:41):

It might be nice to put those hosted annotations at the bottom of the file

view this post on Zulip Sam Mohr (Feb 01 2025 at 16:42):

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

view this post on Zulip Sam Mohr (Feb 01 2025 at 16:43):

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

view this post on Zulip Sam Mohr (Feb 01 2025 at 16:43):

I think my concerns go away if we order the content of a platform's main.roc by importance, namely:

view this post on Zulip Richard Feldman (Feb 01 2025 at 16:44):

I think let's leave this as-is for now

view this post on Zulip Richard Feldman (Feb 01 2025 at 16:45):

the reason we ended up here was because of problems with cyclic imports otherwise

view this post on Zulip Richard Feldman (Feb 01 2025 at 16:45):

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:

view this post on Zulip Sam Mohr (Feb 01 2025 at 16:46):

@Anthony Bullard we should keep hosted modules, then

view this post on Zulip Anthony Bullard (Feb 01 2025 at 16:46):

:+1:


Last updated: Jul 06 2025 at 12:14 UTC