diff --git a/Cargo.toml b/Cargo.toml index e1ce6b2323..ac055aca3e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,9 +57,10 @@ members = [ "crates/wasi-libc-sys", ] exclude = [ - # Examples sometimes have Rust hosts in their platforms. The compiler should ignore those. - "examples", "ci/bench-runner", + # Examples sometimes have Rust hosts in their platforms. The compiler should ignore those. + "crates/cli_testing_examples", + "examples", # Ignore building these normally. They are only imported by tests. # The tests will still correctly build them. "crates/cli_utils", diff --git a/Earthfile b/Earthfile index d67866328b..7c59196695 100644 --- a/Earthfile +++ b/Earthfile @@ -50,7 +50,7 @@ install-zig-llvm-valgrind: copy-dirs: FROM +install-zig-llvm-valgrind - COPY --dir crates examples Cargo.toml Cargo.lock version.txt www ./ + COPY --dir crates Cargo.toml Cargo.lock version.txt www ./ # compile everything needed for benchmarks and output a self-contained dir from which benchmarks can be run. prep-bench-folder: @@ -60,11 +60,11 @@ prep-bench-folder: ARG BENCH_SUFFIX=branch RUN cargo criterion -V RUN --mount=type=cache,target=$SCCACHE_DIR cd crates/cli && cargo criterion --no-run + RUN mkdir -p bench-folder/crates/cli_testing_examples/benchmarks RUN mkdir -p bench-folder/crates/compiler/builtins/bitcode/src RUN mkdir -p bench-folder/target/release/deps - RUN mkdir -p bench-folder/examples/benchmarks - RUN cp examples/benchmarks/*.roc bench-folder/examples/benchmarks/ - RUN cp -r examples/benchmarks/platform bench-folder/examples/benchmarks/ + RUN cp crates/cli_testing_examples/benchmarks/*.roc bench-folder/crates/cli_testing_examples/benchmarks/ + RUN cp -r crates/cli_testing_examples/benchmarks/platform bench-folder/crates/cli_testing_examples/benchmarks/ RUN cp crates/compiler/builtins/bitcode/src/str.zig bench-folder/crates/compiler/builtins/bitcode/src RUN cp target/release/roc bench-folder/target/release # copy the most recent time bench to bench-folder diff --git a/TUTORIAL.md b/TUTORIAL.md index 9376749396..ce7486c3d3 100644 --- a/TUTORIAL.md +++ b/TUTORIAL.md @@ -115,7 +115,7 @@ Create a new file called `Hello.roc` and put this inside it: ```coffee app "hello" - packages { pf: "examples/interactive/cli-platform/main.roc" } + packages { pf: "examples/cli/cli-platform/main.roc" } imports [pf.Stdout] provides [main] to pf @@ -124,8 +124,8 @@ main = Stdout.line "I'm a Roc application!" > **NOTE:** This assumes you've put Hello.roc in the root directory of the Roc > source code. If you'd like to put it somewhere else, you'll need to replace -> `"examples/interactive/cli-platform/main.roc"` with the path to the -> `examples/interactive/cli-platform/main.roc` file in that source code. In the future, +> `"examples/cli/cli-platform/main.roc"` with the path to the +> `examples/cli/cli-platform/main.roc` file in that source code. In the future, > Roc will have the tutorial built in, and this aside will no longer be > necessary! @@ -1257,7 +1257,7 @@ Let's take a closer look at the part of `Hello.roc` above `main`: ```coffee app "hello" - packages { pf: "examples/interactive/cli-platform/main.roc" } + packages { pf: "examples/cli/cli-platform/main.roc" } imports [pf.Stdout] provides main to pf ``` @@ -1275,14 +1275,14 @@ without running it by running `roc build Hello.roc`. The remaining lines all involve the *platform* this application is built on: ```coffee -packages { pf: "examples/interactive/cli-platform/main.roc" } +packages { pf: "examples/cli/cli-platform/main.roc" } imports [pf.Stdout] provides main to pf ``` -The `packages { pf: "examples/interactive/cli-platform/main.roc" }` part says two things: +The `packages { pf: "examples/cli/cli-platform/main.roc" }` part says two things: -- We're going to be using a *package* (that is, a collection of modules) called `"examples/interactive/cli-platform/main.roc"` +- We're going to be using a *package* (that is, a collection of modules) called `"examples/cli/cli-platform/main.roc"` - We're going to name that package `pf` so we can refer to it more concisely in the future. The `imports [pf.Stdout]` line says that we want to import the `Stdout` module @@ -1302,16 +1302,16 @@ calling a function named `line` which is exposed by a module named When we write `imports [pf.Stdout]`, it specifies that the `Stdout` module comes from the `pf` package. -Since `pf` was the name we chose for the `examples/interactive/cli-platform/main.roc` -package (when we wrote `packages { pf: "examples/interactive/cli-platform/main.roc" }`), +Since `pf` was the name we chose for the `examples/cli/cli-platform/main.roc` +package (when we wrote `packages { pf: "examples/cli/cli-platform/main.roc" }`), this `imports` line tells the Roc compiler that when we call `Stdout.line`, it should look for that `line` function in the `Stdout` module of the -`examples/interactive/cli-platform/main.roc` package. +`examples/cli/cli-platform/main.roc` package. ## Tasks Tasks are technically not part of the Roc language, but they're very common in -platforms. Let's use the CLI platform in `examples/interactive/cli-platform/main.roc` as an example! +platforms. Let's use the CLI platform in `examples/cli/cli-platform/main.roc` as an example! In the CLI platform, we have four operations we can do: @@ -1326,7 +1326,7 @@ First, let's do a basic "Hello World" using the tutorial app. ```coffee app "cli-tutorial" - packages { pf: "examples/interactive/cli-platform/main.roc" } + packages { pf: "examples/cli/cli-platform/main.roc" } imports [pf.Stdout] provides [main] to pf @@ -1363,7 +1363,7 @@ Let's change `main` to read a line from `stdin`, and then print it back out agai ```swift app "cli-tutorial" - packages { pf: "examples/interactive/cli-platform/main.roc" } + packages { pf: "examples/cli/cli-platform/main.roc" } imports [pf.Stdout, pf.Stdin, pf.Task] provides [main] to pf @@ -1413,7 +1413,7 @@ This works, but we can make it a little nicer to read. Let's change it to the fo ```haskell app "cli-tutorial" - packages { pf: "examples/interactive/cli-platform/main.roc" } + packages { pf: "examples/cli/cli-platform/main.roc" } imports [pf.Stdout, pf.Stdin, pf.Task.{ await }] provides [main] to pf diff --git a/ci/bench-runner/src/main.rs b/ci/bench-runner/src/main.rs index bb44247ea9..03888e34e5 100644 --- a/ci/bench-runner/src/main.rs +++ b/ci/bench-runner/src/main.rs @@ -227,7 +227,7 @@ fn calc_hashes_for_folder(benches_path_str: &str) -> HashMap { } fn check_if_bench_executables_changed() -> bool { - let bench_folder_str = "/examples/benchmarks/"; + let bench_folder_str = "/crates/cli_testing_examples/benchmarks/"; let main_benches_path_str = [BENCH_FOLDER_MAIN, bench_folder_str].join(""); let main_bench_hashes = calc_hashes_for_folder(&main_benches_path_str); diff --git a/crates/cli/tests/cli_run.rs b/crates/cli/tests/cli_run.rs index deacbfbef5..21a9017261 100644 --- a/crates/cli/tests/cli_run.rs +++ b/crates/cli/tests/cli_run.rs @@ -707,7 +707,7 @@ mod cli_run { all_benchmarks.insert(benchmark.filename, benchmark); )* - check_for_benchmarks("../../examples/benchmarks", &mut all_benchmarks); + check_for_benchmarks("../../crates/cli_testing_examples/benchmarks", &mut all_benchmarks); } } } diff --git a/crates/cli/tests/known_bad/TypeError.roc b/crates/cli/tests/known_bad/TypeError.roc index c1052dd7b3..5f8215e70b 100644 --- a/crates/cli/tests/known_bad/TypeError.roc +++ b/crates/cli/tests/known_bad/TypeError.roc @@ -1,5 +1,5 @@ app "type-error" - packages { pf: "../../../../examples/interactive/cli-platform/main.roc" } + packages { pf: "../../../../examples/cli/cli-platform/main.roc" } imports [pf.Stdout.{ line }, pf.Task.{ await }] provides [main] to pf diff --git a/crates/cli_testing_examples/.gitignore b/crates/cli_testing_examples/.gitignore new file mode 100644 index 0000000000..58cb449bb9 --- /dev/null +++ b/crates/cli_testing_examples/.gitignore @@ -0,0 +1,6 @@ +*.dSYM +libhost.a +libapp.so +dynhost +preprocessedhost +metadata diff --git a/examples/algorithms/.gitignore b/crates/cli_testing_examples/algorithms/.gitignore similarity index 100% rename from examples/algorithms/.gitignore rename to crates/cli_testing_examples/algorithms/.gitignore diff --git a/examples/algorithms/README.md b/crates/cli_testing_examples/algorithms/README.md similarity index 100% rename from examples/algorithms/README.md rename to crates/cli_testing_examples/algorithms/README.md diff --git a/examples/algorithms/fibonacci-platform/host.zig b/crates/cli_testing_examples/algorithms/fibonacci-platform/host.zig similarity index 100% rename from examples/algorithms/fibonacci-platform/host.zig rename to crates/cli_testing_examples/algorithms/fibonacci-platform/host.zig diff --git a/examples/algorithms/fibonacci-platform/main.roc b/crates/cli_testing_examples/algorithms/fibonacci-platform/main.roc similarity index 100% rename from examples/algorithms/fibonacci-platform/main.roc rename to crates/cli_testing_examples/algorithms/fibonacci-platform/main.roc diff --git a/examples/algorithms/fibonacci.roc b/crates/cli_testing_examples/algorithms/fibonacci.roc similarity index 100% rename from examples/algorithms/fibonacci.roc rename to crates/cli_testing_examples/algorithms/fibonacci.roc diff --git a/examples/algorithms/quicksort-platform/host.zig b/crates/cli_testing_examples/algorithms/quicksort-platform/host.zig similarity index 100% rename from examples/algorithms/quicksort-platform/host.zig rename to crates/cli_testing_examples/algorithms/quicksort-platform/host.zig diff --git a/examples/algorithms/quicksort-platform/main.roc b/crates/cli_testing_examples/algorithms/quicksort-platform/main.roc similarity index 100% rename from examples/algorithms/quicksort-platform/main.roc rename to crates/cli_testing_examples/algorithms/quicksort-platform/main.roc diff --git a/examples/algorithms/quicksort.roc b/crates/cli_testing_examples/algorithms/quicksort.roc similarity index 100% rename from examples/algorithms/quicksort.roc rename to crates/cli_testing_examples/algorithms/quicksort.roc diff --git a/examples/benchmarks/.gitignore b/crates/cli_testing_examples/benchmarks/.gitignore similarity index 100% rename from examples/benchmarks/.gitignore rename to crates/cli_testing_examples/benchmarks/.gitignore diff --git a/examples/benchmarks/AStar.roc b/crates/cli_testing_examples/benchmarks/AStar.roc similarity index 100% rename from examples/benchmarks/AStar.roc rename to crates/cli_testing_examples/benchmarks/AStar.roc diff --git a/examples/benchmarks/Base64.roc b/crates/cli_testing_examples/benchmarks/Base64.roc similarity index 100% rename from examples/benchmarks/Base64.roc rename to crates/cli_testing_examples/benchmarks/Base64.roc diff --git a/examples/benchmarks/Base64/Decode.roc b/crates/cli_testing_examples/benchmarks/Base64/Decode.roc similarity index 100% rename from examples/benchmarks/Base64/Decode.roc rename to crates/cli_testing_examples/benchmarks/Base64/Decode.roc diff --git a/examples/benchmarks/Base64/Encode.roc b/crates/cli_testing_examples/benchmarks/Base64/Encode.roc similarity index 100% rename from examples/benchmarks/Base64/Encode.roc rename to crates/cli_testing_examples/benchmarks/Base64/Encode.roc diff --git a/examples/benchmarks/Bytes/Decode.roc b/crates/cli_testing_examples/benchmarks/Bytes/Decode.roc similarity index 100% rename from examples/benchmarks/Bytes/Decode.roc rename to crates/cli_testing_examples/benchmarks/Bytes/Decode.roc diff --git a/examples/benchmarks/Bytes/Encode.roc b/crates/cli_testing_examples/benchmarks/Bytes/Encode.roc similarity index 100% rename from examples/benchmarks/Bytes/Encode.roc rename to crates/cli_testing_examples/benchmarks/Bytes/Encode.roc diff --git a/examples/benchmarks/CFold.roc b/crates/cli_testing_examples/benchmarks/CFold.roc similarity index 100% rename from examples/benchmarks/CFold.roc rename to crates/cli_testing_examples/benchmarks/CFold.roc diff --git a/examples/benchmarks/Closure.roc b/crates/cli_testing_examples/benchmarks/Closure.roc similarity index 100% rename from examples/benchmarks/Closure.roc rename to crates/cli_testing_examples/benchmarks/Closure.roc diff --git a/examples/benchmarks/Deriv.roc b/crates/cli_testing_examples/benchmarks/Deriv.roc similarity index 100% rename from examples/benchmarks/Deriv.roc rename to crates/cli_testing_examples/benchmarks/Deriv.roc diff --git a/examples/benchmarks/Issue2279.roc b/crates/cli_testing_examples/benchmarks/Issue2279.roc similarity index 100% rename from examples/benchmarks/Issue2279.roc rename to crates/cli_testing_examples/benchmarks/Issue2279.roc diff --git a/examples/benchmarks/Issue2279Help.roc b/crates/cli_testing_examples/benchmarks/Issue2279Help.roc similarity index 100% rename from examples/benchmarks/Issue2279Help.roc rename to crates/cli_testing_examples/benchmarks/Issue2279Help.roc diff --git a/examples/benchmarks/NQueens.roc b/crates/cli_testing_examples/benchmarks/NQueens.roc similarity index 100% rename from examples/benchmarks/NQueens.roc rename to crates/cli_testing_examples/benchmarks/NQueens.roc diff --git a/examples/benchmarks/Quicksort.roc b/crates/cli_testing_examples/benchmarks/Quicksort.roc similarity index 100% rename from examples/benchmarks/Quicksort.roc rename to crates/cli_testing_examples/benchmarks/Quicksort.roc diff --git a/examples/benchmarks/QuicksortApp.roc b/crates/cli_testing_examples/benchmarks/QuicksortApp.roc similarity index 100% rename from examples/benchmarks/QuicksortApp.roc rename to crates/cli_testing_examples/benchmarks/QuicksortApp.roc diff --git a/examples/benchmarks/RBTreeCk.roc b/crates/cli_testing_examples/benchmarks/RBTreeCk.roc similarity index 100% rename from examples/benchmarks/RBTreeCk.roc rename to crates/cli_testing_examples/benchmarks/RBTreeCk.roc diff --git a/examples/benchmarks/RBTreeDel.roc b/crates/cli_testing_examples/benchmarks/RBTreeDel.roc similarity index 100% rename from examples/benchmarks/RBTreeDel.roc rename to crates/cli_testing_examples/benchmarks/RBTreeDel.roc diff --git a/examples/benchmarks/RBTreeInsert.roc b/crates/cli_testing_examples/benchmarks/RBTreeInsert.roc similarity index 100% rename from examples/benchmarks/RBTreeInsert.roc rename to crates/cli_testing_examples/benchmarks/RBTreeInsert.roc diff --git a/examples/benchmarks/TestAStar.roc b/crates/cli_testing_examples/benchmarks/TestAStar.roc similarity index 100% rename from examples/benchmarks/TestAStar.roc rename to crates/cli_testing_examples/benchmarks/TestAStar.roc diff --git a/examples/benchmarks/TestBase64.roc b/crates/cli_testing_examples/benchmarks/TestBase64.roc similarity index 100% rename from examples/benchmarks/TestBase64.roc rename to crates/cli_testing_examples/benchmarks/TestBase64.roc diff --git a/examples/benchmarks/platform/Effect.roc b/crates/cli_testing_examples/benchmarks/platform/Effect.roc similarity index 100% rename from examples/benchmarks/platform/Effect.roc rename to crates/cli_testing_examples/benchmarks/platform/Effect.roc diff --git a/examples/benchmarks/platform/Task.roc b/crates/cli_testing_examples/benchmarks/platform/Task.roc similarity index 100% rename from examples/benchmarks/platform/Task.roc rename to crates/cli_testing_examples/benchmarks/platform/Task.roc diff --git a/examples/benchmarks/platform/host.zig b/crates/cli_testing_examples/benchmarks/platform/host.zig similarity index 100% rename from examples/benchmarks/platform/host.zig rename to crates/cli_testing_examples/benchmarks/platform/host.zig diff --git a/examples/benchmarks/platform/main.roc b/crates/cli_testing_examples/benchmarks/platform/main.roc similarity index 100% rename from examples/benchmarks/platform/main.roc rename to crates/cli_testing_examples/benchmarks/platform/main.roc diff --git a/examples/platform-switching/.gitignore b/crates/cli_testing_examples/platform-switching/.gitignore similarity index 100% rename from examples/platform-switching/.gitignore rename to crates/cli_testing_examples/platform-switching/.gitignore diff --git a/examples/platform-switching/README.md b/crates/cli_testing_examples/platform-switching/README.md similarity index 100% rename from examples/platform-switching/README.md rename to crates/cli_testing_examples/platform-switching/README.md diff --git a/examples/platform-switching/c-platform/host.c b/crates/cli_testing_examples/platform-switching/c-platform/host.c similarity index 100% rename from examples/platform-switching/c-platform/host.c rename to crates/cli_testing_examples/platform-switching/c-platform/host.c diff --git a/examples/platform-switching/c-platform/main.roc b/crates/cli_testing_examples/platform-switching/c-platform/main.roc similarity index 100% rename from examples/platform-switching/c-platform/main.roc rename to crates/cli_testing_examples/platform-switching/c-platform/main.roc diff --git a/examples/platform-switching/main.roc b/crates/cli_testing_examples/platform-switching/main.roc similarity index 100% rename from examples/platform-switching/main.roc rename to crates/cli_testing_examples/platform-switching/main.roc diff --git a/examples/platform-switching/rocLovesC.roc b/crates/cli_testing_examples/platform-switching/rocLovesC.roc similarity index 100% rename from examples/platform-switching/rocLovesC.roc rename to crates/cli_testing_examples/platform-switching/rocLovesC.roc diff --git a/examples/platform-switching/rocLovesRust.roc b/crates/cli_testing_examples/platform-switching/rocLovesRust.roc similarity index 100% rename from examples/platform-switching/rocLovesRust.roc rename to crates/cli_testing_examples/platform-switching/rocLovesRust.roc diff --git a/examples/platform-switching/rocLovesSwift.roc b/crates/cli_testing_examples/platform-switching/rocLovesSwift.roc similarity index 100% rename from examples/platform-switching/rocLovesSwift.roc rename to crates/cli_testing_examples/platform-switching/rocLovesSwift.roc diff --git a/examples/platform-switching/rocLovesWebAssembly.roc b/crates/cli_testing_examples/platform-switching/rocLovesWebAssembly.roc similarity index 100% rename from examples/platform-switching/rocLovesWebAssembly.roc rename to crates/cli_testing_examples/platform-switching/rocLovesWebAssembly.roc diff --git a/examples/platform-switching/rocLovesZig.roc b/crates/cli_testing_examples/platform-switching/rocLovesZig.roc similarity index 100% rename from examples/platform-switching/rocLovesZig.roc rename to crates/cli_testing_examples/platform-switching/rocLovesZig.roc diff --git a/examples/platform-switching/rust-platform/Cargo.lock b/crates/cli_testing_examples/platform-switching/rust-platform/Cargo.lock similarity index 100% rename from examples/platform-switching/rust-platform/Cargo.lock rename to crates/cli_testing_examples/platform-switching/rust-platform/Cargo.lock diff --git a/examples/platform-switching/rust-platform/Cargo.toml b/crates/cli_testing_examples/platform-switching/rust-platform/Cargo.toml similarity index 100% rename from examples/platform-switching/rust-platform/Cargo.toml rename to crates/cli_testing_examples/platform-switching/rust-platform/Cargo.toml diff --git a/examples/platform-switching/rust-platform/build.rs b/crates/cli_testing_examples/platform-switching/rust-platform/build.rs similarity index 100% rename from examples/platform-switching/rust-platform/build.rs rename to crates/cli_testing_examples/platform-switching/rust-platform/build.rs diff --git a/examples/platform-switching/rust-platform/host.c b/crates/cli_testing_examples/platform-switching/rust-platform/host.c similarity index 100% rename from examples/platform-switching/rust-platform/host.c rename to crates/cli_testing_examples/platform-switching/rust-platform/host.c diff --git a/examples/platform-switching/rust-platform/main.roc b/crates/cli_testing_examples/platform-switching/rust-platform/main.roc similarity index 100% rename from examples/platform-switching/rust-platform/main.roc rename to crates/cli_testing_examples/platform-switching/rust-platform/main.roc diff --git a/examples/platform-switching/rust-platform/src/lib.rs b/crates/cli_testing_examples/platform-switching/rust-platform/src/lib.rs similarity index 100% rename from examples/platform-switching/rust-platform/src/lib.rs rename to crates/cli_testing_examples/platform-switching/rust-platform/src/lib.rs diff --git a/examples/platform-switching/rust-platform/src/main.rs b/crates/cli_testing_examples/platform-switching/rust-platform/src/main.rs similarity index 100% rename from examples/platform-switching/rust-platform/src/main.rs rename to crates/cli_testing_examples/platform-switching/rust-platform/src/main.rs diff --git a/examples/platform-switching/swift-platform/host.h b/crates/cli_testing_examples/platform-switching/swift-platform/host.h similarity index 100% rename from examples/platform-switching/swift-platform/host.h rename to crates/cli_testing_examples/platform-switching/swift-platform/host.h diff --git a/examples/platform-switching/swift-platform/host.swift b/crates/cli_testing_examples/platform-switching/swift-platform/host.swift similarity index 100% rename from examples/platform-switching/swift-platform/host.swift rename to crates/cli_testing_examples/platform-switching/swift-platform/host.swift diff --git a/examples/platform-switching/swift-platform/main.roc b/crates/cli_testing_examples/platform-switching/swift-platform/main.roc similarity index 100% rename from examples/platform-switching/swift-platform/main.roc rename to crates/cli_testing_examples/platform-switching/swift-platform/main.roc diff --git a/examples/platform-switching/web-assembly-platform/README.md b/crates/cli_testing_examples/platform-switching/web-assembly-platform/README.md similarity index 77% rename from examples/platform-switching/web-assembly-platform/README.md rename to crates/cli_testing_examples/platform-switching/web-assembly-platform/README.md index 76f5720e29..a1dba338dc 100644 --- a/examples/platform-switching/web-assembly-platform/README.md +++ b/crates/cli_testing_examples/platform-switching/web-assembly-platform/README.md @@ -3,12 +3,12 @@ To run this website, first compile either of these identical apps: ```bash -# Option A: Compile examples/platform-switching/rocLovesWebAssembly.roc -cargo run -- build --target=wasm32 examples/platform-switching/rocLovesWebAssembly.roc +# Option A: Compile crates/cli_testing_examples/platform-switching/rocLovesWebAssembly.roc +cargo run -- build --target=wasm32 crates/cli_testing_examples/platform-switching/rocLovesWebAssembly.roc -# Option B: Compile examples/platform-switching/main.roc with `pf: "web-assembly-platform/main.roc"` and move the result -cargo run -- build --target=wasm32 examples/platform-switching/main.roc -(cd examples/platform-switching && mv rocLovesPlatforms.wasm web-assembly-platform/rocLovesWebAssembly.wasm) +# Option B: Compile crates/cli_testing_examples/platform-switching/main.roc with `pf: "web-assembly-platform/main.roc"` and move the result +cargo run -- build --target=wasm32 crates/cli_testing_examples/platform-switching/main.roc +(cd crates/cli_testing_examples/platform-switching && mv rocLovesPlatforms.wasm web-assembly-platform/rocLovesWebAssembly.wasm) ``` Then `cd` into the website directory @@ -16,7 +16,7 @@ and run any web server that can handle WebAssembly. For example, with `http-server`: ```bash -cd examples/platform-switching/web-assembly-platform +cd crates/cli_testing_examples/platform-switching/web-assembly-platform npm install -g http-server http-server ``` diff --git a/examples/platform-switching/web-assembly-platform/host.js b/crates/cli_testing_examples/platform-switching/web-assembly-platform/host.js similarity index 100% rename from examples/platform-switching/web-assembly-platform/host.js rename to crates/cli_testing_examples/platform-switching/web-assembly-platform/host.js diff --git a/examples/platform-switching/web-assembly-platform/host.test.js b/crates/cli_testing_examples/platform-switching/web-assembly-platform/host.test.js similarity index 100% rename from examples/platform-switching/web-assembly-platform/host.test.js rename to crates/cli_testing_examples/platform-switching/web-assembly-platform/host.test.js diff --git a/examples/platform-switching/web-assembly-platform/host.zig b/crates/cli_testing_examples/platform-switching/web-assembly-platform/host.zig similarity index 100% rename from examples/platform-switching/web-assembly-platform/host.zig rename to crates/cli_testing_examples/platform-switching/web-assembly-platform/host.zig diff --git a/examples/platform-switching/web-assembly-platform/index.html b/crates/cli_testing_examples/platform-switching/web-assembly-platform/index.html similarity index 100% rename from examples/platform-switching/web-assembly-platform/index.html rename to crates/cli_testing_examples/platform-switching/web-assembly-platform/index.html diff --git a/examples/platform-switching/web-assembly-platform/main.roc b/crates/cli_testing_examples/platform-switching/web-assembly-platform/main.roc similarity index 100% rename from examples/platform-switching/web-assembly-platform/main.roc rename to crates/cli_testing_examples/platform-switching/web-assembly-platform/main.roc diff --git a/examples/platform-switching/zig-platform/host.zig b/crates/cli_testing_examples/platform-switching/zig-platform/host.zig similarity index 100% rename from examples/platform-switching/zig-platform/host.zig rename to crates/cli_testing_examples/platform-switching/zig-platform/host.zig diff --git a/examples/platform-switching/zig-platform/main.roc b/crates/cli_testing_examples/platform-switching/zig-platform/main.roc similarity index 100% rename from examples/platform-switching/zig-platform/main.roc rename to crates/cli_testing_examples/platform-switching/zig-platform/main.roc diff --git a/crates/compiler/build/src/link.rs b/crates/compiler/build/src/link.rs index 29bfbcf15a..ea89b43e2c 100644 --- a/crates/compiler/build/src/link.rs +++ b/crates/compiler/build/src/link.rs @@ -373,7 +373,7 @@ pub fn build_zig_host_wasm32( "c", "-target", zig_target, - // "-femit-llvm-ir=/home/folkertdev/roc/roc/examples/benchmarks/platform/host.ll", + // "-femit-llvm-ir=/home/folkertdev/roc/roc/crates/cli_testing_examples/benchmarks/platform/host.ll", "-fPIC", "--strip", ]; @@ -1176,7 +1176,7 @@ fn link_wasm32( "-O", "ReleaseSmall", // useful for debugging - // "-femit-llvm-ir=/home/folkertdev/roc/roc/examples/benchmarks/platform/host.ll", + // "-femit-llvm-ir=/home/folkertdev/roc/roc/crates/cli_testing_examples/benchmarks/platform/host.ll", ]) .spawn()?; diff --git a/examples/README.md b/examples/README.md index 7097cb5397..0358683fdc 100644 --- a/examples/README.md +++ b/examples/README.md @@ -14,7 +14,7 @@ Run examples as follows: roc run hello-world/main.roc ``` -`examples/benchmarks/` contains some larger examples. +`crates/cli_testing_examples/benchmarks/` contains some larger examples. -Some examples like `examples/benchmarks/NQueens.roc` require input after running. +Some examples like `crates/cli_testing_examples/benchmarks/NQueens.roc` require input after running. For NQueens, input 10 in the terminal and press enter. diff --git a/getting_started/README.md b/getting_started/README.md index 64992ec650..ef574d9776 100644 --- a/getting_started/README.md +++ b/getting_started/README.md @@ -6,7 +6,7 @@ play around with as long as you have a high tolerance for missing features and c The [tutorial](../TUTORIAL.md) is the best place to learn about how to use the language - it assumes no prior knowledge of Roc or similar languages. (If you already know [Elm](https://elm-lang.org/), then [Roc for Elm Programmers](https://github.com/roc-lang/roc/blob/main/roc-for-elm-programmers.md) may be of interest.) -There's also a folder of [examples](https://github.com/roc-lang/roc/tree/main/examples) - the [CLI form example](https://github.com/roc-lang/roc/tree/main/examples/interactive/form.roc) in particular is a reasonable starting point to build on. +There's also a folder of [examples](https://github.com/roc-lang/roc/tree/main/examples) - the [CLI form example](https://github.com/roc-lang/roc/tree/main/examples/cli/form.roc) in particular is a reasonable starting point to build on. If you have a specific question, the [FAQ](../FAQ.md) might have an answer, although [Roc Zulip chat](https://roc.zulipchat.com) is overall the best place to ask questions and get help! It's also where we discuss [ideas](https://roc.zulipchat.com/#narrow/stream/304641-ideas) for the language. If you want to get involved in contributing to the language, Zulip is also a great place to ask about good first projects. @@ -27,10 +27,10 @@ cd examples roc run helloWorld.roc ``` -Some examples like `examples/benchmarks/NQueens.roc` require input after running. +Some examples like `crates/cli_testing_examples/benchmarks/NQueens.roc` require input after running. For NQueens, input 10 in the terminal and press enter. -[examples/benchmarks](examples/benchmarks) contains larger examples. +[crates/cli_testing_examples/benchmarks](crates/cli_testing_examples/benchmarks) contains larger examples. **Tip:** when programming in roc, we recommend to execute `./roc check myproject/Foo.roc` before `./roc myproject/Foo.roc` or `./roc build myproject/Foo.roc`. `./roc check` can produce clear error messages in cases where building/running may panic. diff --git a/getting_started/linux_x86.md b/getting_started/linux_x86.md index d0f4dff8b2..e3ac639c6f 100644 --- a/getting_started/linux_x86.md +++ b/getting_started/linux_x86.md @@ -44,9 +44,9 @@ you need to install one or more of these platform language compilers, too. ```sh # Note: If you installed Rust in this terminal session, you'll need to open a new one first! - ./roc examples/platform-switching/rocLovesRust.roc + ./roc crates/cli_testing_examples/platform-switching/rocLovesRust.roc - ./roc examples/platform-switching/rocLovesZig.roc + ./roc crates/cli_testing_examples/platform-switching/rocLovesZig.roc - ./roc examples/platform-switching/rocLovesC.roc + ./roc crates/cli_testing_examples/platform-switching/rocLovesC.roc ``` diff --git a/getting_started/macos_apple_silicon.md b/getting_started/macos_apple_silicon.md index 3036c5bcde..386eff24f7 100644 --- a/getting_started/macos_apple_silicon.md +++ b/getting_started/macos_apple_silicon.md @@ -40,9 +40,9 @@ you need to install one or more of these platform language compilers, too. ```sh # Note: If you installed rust in this terminal session, you'll need to open a new one first! - ./roc examples/platform-switching/rocLovesRust.roc + ./roc crates/cli_testing_examples/platform-switching/rocLovesRust.roc - ./roc examples/platform-switching/rocLovesZig.roc + ./roc crates/cli_testing_examples/platform-switching/rocLovesZig.roc - ./roc examples/platform-switching/rocLovesC.roc + ./roc crates/cli_testing_examples/platform-switching/rocLovesC.roc ``` diff --git a/getting_started/macos_x86.md b/getting_started/macos_x86.md index df507c5d36..c5b20e6c5b 100644 --- a/getting_started/macos_x86.md +++ b/getting_started/macos_x86.md @@ -40,9 +40,9 @@ you need to install one or more of these platform language compilers, too. ```sh # Note: If you installed rust in this terminal session, you'll need to open a new one first! - ./roc examples/platform-switching/rocLovesRust.roc + ./roc crates/cli_testing_examples/platform-switching/rocLovesRust.roc - ./roc examples/platform-switching/rocLovesZig.roc + ./roc crates/cli_testing_examples/platform-switching/rocLovesZig.roc - ./roc examples/platform-switching/rocLovesC.roc + ./roc crates/cli_testing_examples/platform-switching/rocLovesC.roc ``` diff --git a/getting_started/other.md b/getting_started/other.md index 70f01dd2e5..13c5c79db7 100644 --- a/getting_started/other.md +++ b/getting_started/other.md @@ -7,11 +7,11 @@ 1. Run examples: ```sh - cargo run examples/platform-switching/rocLovesRust.roc + cargo run crates/cli_testing_examples/platform-switching/rocLovesRust.roc # This requires installing the Zig compiler, too. - cargo run examples/platform-switching/rocLovesZig.roc + cargo run crates/cli_testing_examples/platform-switching/rocLovesZig.roc # This requires installing the `clang` C compiler, too. - cargo run examples/platform-switching/rocLovesC.roc + cargo run crates/cli_testing_examples/platform-switching/rocLovesC.roc ``` diff --git a/www/build.sh b/www/build.sh index b292377034..6797db6467 100755 --- a/www/build.sh +++ b/www/build.sh @@ -45,7 +45,7 @@ export ROC_DOCS_URL_ROOT=/examples/cli # Until https://github.com/roc-lang/roc/issues/3280 is done, # manually exclude the Internal* modules and `main.roc`. -ls examples/interactive/cli-platform/*.roc | grep -v Internal | grep -v main.roc | grep -v Effect.roc | xargs cargo run --bin roc-docs +ls examples/cli/cli-platform/*.roc | grep -v Internal | grep -v main.roc | grep -v Effect.roc | xargs cargo run --bin roc-docs mkdir www/build/examples rm generated-docs/*.* # we already copied over the *.js and *.css files earlier, so just drop these.