Stream: beginners

Topic: "_1_", "exposed", "exposed_generic"???


view this post on Zulip Shaiden Spreitzer (Dec 02 2023 at 17:19):

Utterly mysterious ... :thinking:
What do these mean? What is the difference between "exposed" and "exposed_generic"?? Why does "1" start at one and not zero? Can I have more than one "main" exposed to the platform? Did I miss some documentation?
Guidance appreciated!!

view this post on Zulip Brendan Hansknecht (Dec 02 2023 at 17:21):

What are you working on/trying to do? Generally, beginners don't jump right into this stuff.

view this post on Zulip Shaiden Spreitzer (Dec 02 2023 at 17:22):

Not sure yet.. Trying to figure things out...

view this post on Zulip Brendan Hansknecht (Dec 02 2023 at 17:23):

If you are just trying to write a basic application in roc to get a feel for the language, I would advise first following the tutorial and then messing around with basic-cli.

view this post on Zulip Shaiden Spreitzer (Dec 02 2023 at 17:26):

I'm past that already. I want my own platform. With support for concurrency/async. What is the difference between "exposed" and "exposed_generic"?? Sure it's some easy stuff explained in two or three sentences. Backwards/legacy stuff?? pls!!

view this post on Zulip Brendan Hansknecht (Dec 02 2023 at 17:32):

Sure, though if you are building your own platform, I would highly advise making it a rust platform and using roc glue to avoid needing to know many of these low level details.

view this post on Zulip Brendan Hansknecht (Dec 02 2023 at 17:33):

"exposed" -> standard cabi
"exposed_generic" -> wrapper where the output is passed in as a pointer

view this post on Zulip Shaiden Spreitzer (Dec 02 2023 at 17:33):

"cabi"??

view this post on Zulip Brendan Hansknecht (Dec 02 2023 at 17:34):

c abi

view this post on Zulip Shaiden Spreitzer (Dec 02 2023 at 17:35):

What does "exposed_generic" return? Nothing? Void?

view this post on Zulip Brendan Hansknecht (Dec 02 2023 at 17:35):

yeah, it should be void.

view this post on Zulip Brendan Hansknecht (Dec 02 2023 at 17:35):

`> Why does "1" start at one and not zero?

IIRC, This is the internal layout id of the function.

view this post on Zulip Shaiden Spreitzer (Dec 02 2023 at 17:36):

ok, make sense! Thanks!

view this post on Zulip Shaiden Spreitzer (Dec 02 2023 at 17:42):

Brendan Hansknecht said:

Sure, though if you are building your own platform, I would highly advise making it a rust platform and using roc glue to avoid needing to know many of these low level details.

roc glue btw. does not work for me: "thread 'main' panicked at 'called' 'Option::unwrap()' on a 'None' value..."

view this post on Zulip Brendan Hansknecht (Dec 02 2023 at 17:43):

can you share the full command you used?

view this post on Zulip Shaiden Spreitzer (Dec 02 2023 at 17:44):

Brendan Hansknecht said:

can you share the full command you used?

./roc glue RustGlue.roc platform/ main.roc

view this post on Zulip Brendan Hansknecht (Dec 02 2023 at 17:45):

can you also share the full error, should have a src file and line number hopefully.

view this post on Zulip Shaiden Spreitzer (Dec 02 2023 at 17:48):

ok sorry I must type it all...
"thread 'main' panicked at 'called Option::unwrap() on a None value' crates/glue/src/load.rs:390:50 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace"

view this post on Zulip Brendan Hansknecht (Dec 02 2023 at 17:50):

that is not at all where I expected an error to be. Any chance you can share your main.roc file?

view this post on Zulip Shaiden Spreitzer (Dec 02 2023 at 17:51):

`app "arbitmon-backend"
packages { pf: "platform/main.roc" }
imports [pf.Effect.{Effect, Future}]
provides [main] to pf

main : Effect Future
main =
future <- Effect.after Effect.sleep
Effect.always future
`

view this post on Zulip Shaiden Spreitzer (Dec 02 2023 at 17:52):

'`platform "arbitmon-backend-platform"
requires {} { main : Effect Future }
exposes []
packages {}
imports [Effect.{ Effect, Future }]
provides [mainForHost]

mainForHost : Effect Future as Fx
mainForHost = main`'

view this post on Zulip Shaiden Spreitzer (Dec 02 2023 at 17:52):

'hosted Effect
exposes [Effect, after, always, sleep]
imports []
generates Effect with [after, always]

Future := Nat

sleep : Effect Future
'

view this post on Zulip Shaiden Spreitzer (Dec 02 2023 at 17:52):

That's it.

view this post on Zulip Brendan Hansknecht (Dec 02 2023 at 18:10):

With those files (after re-adding tabbing), this works for me:

roc glue crates/glue/src/RustGlue.roc /tmp/test/platform/glue /tmp/test/platform/main.roc

view this post on Zulip Shaiden Spreitzer (Dec 02 2023 at 18:57):

Brendan Hansknecht said:

With those files (after re-adding tabbing), this works for me:

roc glue crates/glue/src/RustGlue.roc /tmp/test/platform/glue /tmp/test/platform/main.roc

Won't work for me. Even when giving an absolute path it changes the path in a nonsensical way:
./roc glue RustGlue.roc ./glue /home/shaiden/roc_test/src/platform/main.roc
The error I get is:
FileProblem { filename: "/home/shaiden/roc_test/src/../platform/main.roc", error: NotFound }

I don't know where the random "/../" comes from, but I couldn’t get rid of it ...


Last updated: Jul 06 2025 at 12:14 UTC