No glue code I have looked at seems to ever implement Effect
and its functions. What does each function do?
Besides, even if there is no documentation, writing a platform is actually quite easy. I gave myself 1 hour since I really needed a solution for my problem. And I finished writing the basics of it.
Ah, if Effect
is indeed a special case, why isn't it inside of the standard library then?
The platform implements the effects, not glue.
The glue code just expresses the Roc types in Rust syntax. The actual call itself is in Roc code.
There's a naming convention where the effect functions on the Rust side begin with roc_fx_ or something like that.
Yes generates
is special syntax that platforms use. The Effect type is different for different platforms so it needs special code generation.
I am not sure if I understood this correct. So far I have managed to implement my own logging effects. The glue generates the function stubs for each architecture inside the glue. And I just went ahead and implemented the function body. Like here: https://github.com/roc-lang/basic-cli/blob/dee04a8ca735f2431e99631041c7105c3cd6d52e/src/src/lib.rs#L303-L313
However, I am wondering where exactly the Effect
type is implemented. In every platform so far it is defined as hosted Effect
, which for me indicates it is implemented on the host side: https://github.com/roc-lang/basic-cli/blob/dee04a8ca735f2431e99631041c7105c3cd6d52e/src/Effect.roc#L1
But I could never find an Effect struct or the likes nor could I find its accompanying methods apply
, forever
etc. on any platform so far.
Brian Carroll said:
Yes
generates
is special syntax that platforms use. The Effect type is different for different platforms so it needs special code generation.
But that code generation is not happening when I call the roc glue
command, right?
that's correct - we haven't wired that up, partially because we're in the process of changing how that works under the hood (so that what gets sent to Rust is a state machine - happy to elaborate on that if desired!) and at that point we'd be discarding the current system
but that change isn't done yet
mainrs said:
Brian Carroll said:
Yes
generates
is special syntax that platforms use. The Effect type is different for different platforms so it needs special code generation.But that code generation is not happening when I call the
roc glue
command, right?
That's right, I should have explained it's the compiler doing that particular code generation, not roc glue.
mainrs has marked this topic as resolved.
Last updated: Jul 06 2025 at 12:14 UTC