is someone working on an html/browser platform?
I'm interested in contributing to this ecosystem by starting to create some packages for that domain even if the platform itself is far from ready. would that make sense at this moment? should I wait?
I'm the creator of elm-book and I'm also preparing a suite of other UI libs for Elm. I'd be glad to maintain similar ones for the Roc world.
Hi Georges! Nobody's working on that at the moment, no. Would be great to have you involved! Some thinking has been done about it though, by Richard and myself and maybe others.
The Elm architecture won't work well exactly as-is, for various reasons. Richard wrote up a document about it here https://docs.google.com/document/d/16qY4NGVOHu8mvInVD-ddTajZYSsFvFBvQON_hmyHGfo/edit
That's a good place to start. It's fairly long but worth a read before getting into this.
I did a project a while ago to port Elm to Wasm. I managed to get Richard's Elm SPA Example to compile and run. The performance was roughly similar to JS. The biggest bottleneck by far is encoding JS values to bytes and decoding them back again. The architecture of a front end framework for Roc would need to be designed around how to minimise these "border crossings".
I have lots of experience with this sort of thing from that previous project and would be happy to help.
Click handler functions are tricky, for example. The design I have in mind is that the JS handler attached to the DOM node would simply send an integer ID to the Wasm module to indicate "event handler 123 fired". Then the Wasm module would look up some sort of dictionary of lambdas to call.
But the user might want to decode the JS event object. Unfortunately those event object contain circular references so are not actually serializable. You have to get the app developer to provide a list of fields to decode, then JSON.stringify
only those fields and write them into the Wasm module for further JSON deserialization.
thank you! just read through it -
this is just a illustrative tutorial to understand how things would work, right? Is there any code related to it even if incomplete?
one thing I'm not getting is how would an UI platform be shared. can a Roc application use N platforms at the same time? so I could, as an example, use a native UI platform and also use something that is related to databases or something like that? html and the browser are two different things right but Elm uses both as the "platform".
*rant.. whyyy use things like Str and Elem :sweat_smile: saving 3 letters in place of legibility doesn't make sense to me. it is my only pet peeve related to Roc.
Have a look in examples/gui
in the repo.
An app can only use one platform at a time.
Last updated: Jul 06 2025 at 12:14 UTC