roc/examples/platform-switching
2023-03-08 19:46:00 +01:00
..
c-platform Drop obsolete mentions of roc_send_signal 2022-12-08 06:36:12 -05:00
rust-platform Merge remote-tracking branch 'origin/main' into glue-getters-rtfeldman 2023-03-08 19:46:00 +01:00
swift-platform moved platform-switching 2022-10-17 15:22:20 +02:00
web-assembly-platform add nightly instructions 2022-11-12 13:55:06 +01:00
zig-platform WIP 2023-01-08 14:49:13 +01:00
.gitignore moved platform-switching 2022-10-17 15:22:20 +02:00
main.roc moved platform-switching 2022-10-17 15:22:20 +02:00
README.md moved platform-switching 2022-10-17 15:22:20 +02:00
rocLovesC.roc moved platform-switching 2022-10-17 15:22:20 +02:00
rocLovesRust.roc revert rocLovesRust to main 2023-03-01 21:57:10 +01:00
rocLovesSwift.roc moved platform-switching 2022-10-17 15:22:20 +02:00
rocLovesWebAssembly.roc moved platform-switching 2022-10-17 15:22:20 +02:00
rocLovesZig.roc moved platform-switching 2022-10-17 15:22:20 +02:00

Platform switching

To run, cd into this directory and run this in your terminal:

roc run

This will run main.roc because, unless you explicitly give it a filename, roc run defaults to running a file named main.roc. Other roc commands (like roc build, roc test, and so on) also default to main.roc unless you explicitly give them a filename.

About this example

This uses a very simple platform which does nothing more than printing the string you give it.

The line main = "Which platform am I running on now?\n" sets this string to be "Which platform am I running on now?" with a newline at the end, and the lines packages { pf: "c-platform/main.roc" } and provides [main] to pf specify that the c-platform/ directory contains this app's platform.

This platform is called c-platform because its lower-level code is written in C. There's also a rust-platform, zig-platform, and so on; if you like, you can try switching pf: "c-platform/main.roc" to pf: "zig-platform/main.roc" or pf: "rust-platform/main.roc" to try one of those platforms instead. They all do similar things, so the application won't look any different.

If you want to start building your own platforms, these are some very simple example platforms to use as starting points.