I am trying to understand what is this doing:
app "main" imports [ Effect ] provides [ rocMain ] to "./platform"
I mean this provides ... to .....
syntax, not sure what changes in platfrom
the compiler needs to know what the main function is, and what the platform is that you want to compile
Ah, so no main
as default?
Oh interesting, and its a list? So could it be [ mainA, mainB ]
?
right. This might be something to reconsider now. Originally, the idea was that you could hand multiple things to the platform (e.g. provide a update
, a view
, ect as separate functions)
but we've confirmed that bundling all those functions in a record has no overhead; LLVM completely optimizes the struct/record away
❯ cat examples/balance/Main.roc
app "main" imports [ Effect ] provides [ rocMain, roKMain ] to "./platform"
rocMain : Effect.Effect {} as Fx
rocMain = ..
roKMain : Effect.Effect {} as Fx
roKMain = ..
THis is invalid syntax right?
There can be only one?!
:D
well no, a platform could decide to allow this
e.g. provides [ serverMain, clientMain ]
So, in theory, there could be a Roc mono repo, with the frontend and backend code base, like:
provides [ view, update, dbConnection, http ]
?
that should be a record then?
yea I think that is generally preferable
because then you have better docs for what the platform needs
provides { view, update: mainUpdateFix2 } to "xy"
but that is would be then equal to defaulting to only one main
, where platform provides a spec what kind of data type it should be?
Last updated: Jul 05 2025 at 12:14 UTC