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()}")
}
}
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?
I think the way it was described is that our design is implicit not explicit -- I think the example given was Go's interfaces
I think the answer is no there isn't
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.
yeah we talked about an alias for multiple where clauses... no idea what the syntax is or what the status of that idea is
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.
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.
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!
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.
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.
ah here is is
https://github.com/roc-lang/http
https://github.com/roc-lang/path
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.
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