Stream: beginners

Topic: ✔ OS-specific APIs in platforms


view this post on Zulip Richard Feldman (Oct 08 2026 at 18:02):

I have some ideas about how to handle this but I haven't figured out the right way yet

view this post on Zulip Richard Feldman (Oct 08 2026 at 18:06):

one idea is:

view this post on Zulip Richard Feldman (Oct 08 2026 at 18:10):

the reason I'd do it as an effectful function (System.target!) is that we currently have the invariant that if you call a Roc pure function passing the same arguments, you are guaranteed to get the same answer no matter what target you're building for. I wouldn't want to sacrifice that invariant just to make this operation callable in more places, especially when the reason you'd use it would be to unlock calling effectful functions from your platform anyway.

view this post on Zulip Richard Feldman (Oct 08 2026 at 18:11):

but of course if it's going to be an effectful function, it doesn't need to be a builtin; any platform can just offer an effectful function like that today

view this post on Zulip Richard Feldman (Oct 08 2026 at 18:12):

or, alternatively, pass the target info into main! along with env etc. - that has the downside that application authors would need to thread it through more places, but there are other tradeoffs to doing it that way.

view this post on Zulip Richard Feldman (Oct 08 2026 at 18:13):

anyway, so I don't know whether it will someday make sense to do that as a builtin, but certainly for right now there's nothing stopping any platform from doing that today, so that's what I'd recommend!

view this post on Zulip Richard Feldman (Oct 08 2026 at 18:14):

happy to explain any of the details there

view this post on Zulip notramo (Oct 08 2026 at 23:31):

Thanks, this seems to be a good solution without changing the language.

view this post on Zulip notramo (Oct 08 2026 at 23:32):

I agree with the platform check function being effectful.

view this post on Zulip Notification Bot (Oct 08 2026 at 23:33):

notramo has marked this topic as resolved.


Last updated: Oct 15 2026 at 17:56 UTC