Stream: ideas

Topic: Feature Proposal: Platform Requirements with Interface Const


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

https://github.com/roc-lang/roc/issues/9097

An idea I had to enable applications to provide a value that conforms to a particular interface, specified by the platform requires using where clause constraints.

app [MyApp] { pf: platform "./platform/main.roc" }

import pf.Elem exposing [Elem]

MyApp := { count : I64, name : Str }.{
    init : () -> Box(MyApp)
    init = || Box.box({ count: 42, name: "John" })

    render : Box(MyApp) -> Elem
    render = |boxed_model| {
        model = boxed_model.unbox()

        Elem.text("Hello, ${model.name.to_str()}")
    }
}

view this post on Zulip Dan G Knutson (Feb 01 2026 at 01:35):

Is there an existing syntax that lets you declare that you intend some value of yours to meet some external interface?
For example, if I (as an app author) want the MyApp record above to meet the required methods for the platform, and also the required methods for a library I'm using, is there a way to declare that with multiple where clauses that would give local error messages?

view this post on Zulip Luke Boswell (Feb 01 2026 at 01:36):

I think the way it was described is that our design is implicit not explicit -- I think the example given was Go's interfaces

view this post on Zulip Luke Boswell (Feb 01 2026 at 01:36):

I think the answer is no there isn't

view this post on Zulip Brendan Hansknecht (Feb 01 2026 at 01:50):

I thought we made an interface syntax already for this. Not sure it ever got implemented though. But I though you could essentially make an alias that could be used in a where clause and contain a group of method requirements.

view this post on Zulip Luke Boswell (Feb 01 2026 at 01:51):

yeah we talked about an alias for multiple where clauses... no idea what the syntax is or what the status of that idea is

view this post on Zulip Luke Boswell (Feb 01 2026 at 01:51):

But I thought that wouldn't help in this situation because you still have no way of saying saying my type meets that external interface.

view this post on Zulip Dan G Knutson (Feb 01 2026 at 01:52):

Yeah, I remembered the type aliases for where clause things, I was just thinking of how to say, like, "I'm trying to fulfill these two". I suppose if nothing else you could use local variables in expect blocks.

view this post on Zulip Eli Dowling (Feb 01 2026 at 03:09):

I think as the community matures having known interfaces for things like http and streams and file operations that you can then implement and conform too with your platform will be very important!

view this post on Zulip Rick Hull (Feb 01 2026 at 04:00):

with Ruby, rack was an improvement on python's WSGI in some sense and hyper-accelerated independent webserver development efforts; but it also entrenched some anti-streaming things that took a while to work out.

view this post on Zulip Luke Boswell (Feb 01 2026 at 05:22):

Eli Dowling said:

I think as the community matures having known interfaces for things like http and streams and file operations that you can then implement and conform too with your platform will be very important!

I agree.

From memory I feel like Richard designed a Http package I think with the intent that basic-cli and basic-webserver etc would all use that, the same Request/Response types etc. I'll see if I can dig that out.

view this post on Zulip Luke Boswell (Feb 01 2026 at 05:24):

ah here is is

Http

https://github.com/roc-lang/http

Path

https://github.com/roc-lang/path

view this post on Zulip Luke Boswell (Feb 01 2026 at 05:27):

It's probably a good idea for us to beat down this path and get one or both of these up and fully operational as a priority.

We could use Path in something like the zig platform template and change the scope of the platform beyond just stdio, to include simple File operations. I wanted to avoid making it too complex, but it's probably really helpful to have the templates use a cross-platform package like this.

view this post on Zulip Luke Boswell (Feb 01 2026 at 05:32):

So the idea is we migrate those to the new syntax (probably leave some parts as crash "not implemented yet", then make a package release, then use that package and types in the platforms.


Last updated: Jun 16 2026 at 16:19 UTC