mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 16:44:33 +00:00
snake_case
-ify all remaining camelCase
names in hiding (#7561)
* Snake-case-ify def names in comments * Snake-case-ify def names in strings * Snake-case-ify ignored function parameters * Snake-case-ify test script names, for consistency * Update CI snapshot to match snake_case * snake case correction --------- Co-authored-by: Anton-4 <17049058+Anton-4@users.noreply.github.com>
This commit is contained in:
parent
7154b3483b
commit
68e524e110
45 changed files with 157 additions and 150 deletions
|
@ -58,7 +58,7 @@ jobs:
|
|||
|
||||
- name: test with zig platform
|
||||
run: |
|
||||
cd ${{ env.RELEASE_FOLDER_NAME }} && ./roc --build-host --suppress-build-host-warning examples/platform-switching/rocLovesZig.roc
|
||||
cd ${{ env.RELEASE_FOLDER_NAME }} && ./roc --build-host --suppress-build-host-warning examples/platform-switching/roc_loves_zig.roc
|
||||
|
||||
- name: print short commit SHA
|
||||
run: git rev-parse --short "$GITHUB_SHA"
|
||||
|
|
|
@ -30,13 +30,13 @@ cd roc_release/*/
|
|||
# test rust platform (first prebuild the host)
|
||||
# temp disabled
|
||||
# examples/platform-switching/rust-platform/build.sh
|
||||
# ./roc examples/platform-switching/rocLovesRust.roc
|
||||
# ./roc examples/platform-switching/roc_loves_rust.roc
|
||||
|
||||
# test zig platform
|
||||
./roc --build-host --suppress-build-host-warning examples/platform-switching/rocLovesZig.roc
|
||||
./roc --build-host --suppress-build-host-warning examples/platform-switching/roc_loves_zig.roc
|
||||
|
||||
# test C platform
|
||||
./roc --build-host --suppress-build-host-warning examples/platform-switching/rocLovesC.roc
|
||||
./roc --build-host --suppress-build-host-warning examples/platform-switching/roc_loves_c.roc
|
||||
|
||||
# test repl
|
||||
cd ../../ci/repl_basic_test
|
||||
|
|
|
@ -16,7 +16,7 @@ mv crates/cli/tests/platform-switching $1/examples
|
|||
mv examples/README.md $1/examples
|
||||
|
||||
# temporary github.com/roc-lang/roc/pull/7231
|
||||
rm $1/examples/platform-switching/rocLovesRust.roc
|
||||
rm $1/examples/platform-switching/roc_loves_rust.roc
|
||||
rm -rf $1/examples/platform-switching/rust-platform
|
||||
|
||||
# copy zig builtins
|
||||
|
|
|
@ -103,21 +103,21 @@ astar = \cost_fn, move_fn, goal, model ->
|
|||
|
||||
astar(cost_fn, move_fn, goal, model_with_costs)
|
||||
|
||||
# takeStep = \moveFn, _goal, model, current ->
|
||||
# modelPopped =
|
||||
# take_step = \move_fn, _goal, model, current ->
|
||||
# model_popped =
|
||||
# { model &
|
||||
# openSet: Set.remove model.openSet current,
|
||||
# open_set: Set.remove model.open_set current,
|
||||
# evaluated: Set.insert model.evaluated current,
|
||||
# }
|
||||
#
|
||||
# neighbors = moveFn current
|
||||
# neighbors = move_fn current
|
||||
#
|
||||
# newNeighbors = Set.difference neighbors modelPopped.evaluated
|
||||
# new_neighbors = Set.difference neighbors model_popped.evaluated
|
||||
#
|
||||
# modelWithNeighbors = { modelPopped & openSet: Set.union modelPopped.openSet newNeighbors }
|
||||
# model_with_neighbors = { model_popped & open_set: Set.union model_popped.open_set new_neighbors }
|
||||
#
|
||||
# # a lot goes wrong here
|
||||
# modelWithCosts =
|
||||
# Set.walk newNeighbors modelWithNeighbors (\n, m -> updateCost current n m)
|
||||
# model_with_costs =
|
||||
# Set.walk new_neighbors model_with_neighbors (\n, m -> update_cost current n m)
|
||||
#
|
||||
# modelWithCosts
|
||||
# model_with_costs
|
||||
|
|
|
@ -59,7 +59,7 @@ lowest6_bits_mask = 63
|
|||
bits_to_chars_help : U32, Int * -> List U8
|
||||
bits_to_chars_help = \bits, missing ->
|
||||
# The input is 24 bits, which we have to partition into 4 6-bit segments. We achieve this by
|
||||
# shifting to the right by (a multiple of) 6 to remove unwanted bits on the right, then `Num.bitwiseAnd`
|
||||
# shifting to the right by (a multiple of) 6 to remove unwanted bits on the right, then `Num.bitwise_and`
|
||||
# with `0b111111` (which is 2^6 - 1 or 63) (so, 6 1s) to remove unwanted bits on the left.
|
||||
# any 6-bit number is a valid base64 digit, so this is actually safe
|
||||
p =
|
||||
|
|
|
@ -40,7 +40,7 @@ folder = \{ output, accum }, char ->
|
|||
{ output, accum: None }
|
||||
|
||||
# SGVs bG8g V29y bGQ=
|
||||
# encodeResidual : { output : List ByteEncoder, accum : State } -> List ByteEncoder
|
||||
# encode_residual : { output : List ByteEncoder, accum : State } -> List ByteEncoder
|
||||
encode_residual = \{ output, accum } ->
|
||||
when accum is
|
||||
Unreachable(_) -> output
|
||||
|
|
|
@ -63,7 +63,7 @@ mod cli_tests {
|
|||
|
||||
let cli_build = ExecCli::new(
|
||||
roc_cli::CMD_DEV,
|
||||
file_from_root("crates/cli/tests/platform-switching", "rocLovesRust.roc"),
|
||||
file_from_root("crates/cli/tests/platform-switching", "roc_loves_rust.roc"),
|
||||
);
|
||||
|
||||
let expected_output = "Roc <3 Rust!\n";
|
||||
|
@ -80,7 +80,7 @@ mod cli_tests {
|
|||
|
||||
let cli_build = ExecCli::new(
|
||||
CMD_BUILD,
|
||||
file_from_root("crates/cli/tests/platform-switching", "rocLovesZig.roc"),
|
||||
file_from_root("crates/cli/tests/platform-switching", "roc_loves_zig.roc"),
|
||||
)
|
||||
.arg(BUILD_HOST_FLAG)
|
||||
.arg(SUPPRESS_BUILD_HOST_WARNING_FLAG);
|
||||
|
@ -106,7 +106,7 @@ mod cli_tests {
|
|||
CMD_CHECK,
|
||||
file_from_root(
|
||||
"crates/cli/tests/platform-switching",
|
||||
"rocLovesWebAssembly.roc",
|
||||
"roc_loves_web_assembly.roc",
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -382,7 +382,7 @@ mod cli_tests {
|
|||
CMD_BUILD,
|
||||
file_from_root(
|
||||
"crates/cli/tests/test-projects/effectful",
|
||||
"combine-tasks.roc",
|
||||
"combine_tasks.roc",
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -605,7 +605,7 @@ mod cli_tests {
|
|||
CMD_BUILD,
|
||||
file_from_root(
|
||||
"crates/cli/tests/test-projects/fixtures/transitive-deps",
|
||||
"direct-one.roc",
|
||||
"direct_one.roc",
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -629,7 +629,7 @@ mod cli_tests {
|
|||
CMD_BUILD,
|
||||
file_from_root(
|
||||
"crates/cli/tests/test-projects/fixtures/transitive-deps",
|
||||
"direct-one-and-two.roc",
|
||||
"direct_one_and_two.roc",
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -653,7 +653,7 @@ mod cli_tests {
|
|||
CMD_BUILD,
|
||||
file_from_root(
|
||||
"crates/cli/tests/test-projects/fixtures/transitive-deps",
|
||||
"direct-zero.roc",
|
||||
"direct_zero.roc",
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -815,7 +815,7 @@ mod cli_tests {
|
|||
CMD_BUILD,
|
||||
file_from_root(
|
||||
"crates/cli/tests/test-projects/test-platform-effects-zig/",
|
||||
"app-stub.roc",
|
||||
"app_stub.roc",
|
||||
),
|
||||
)
|
||||
.arg(BUILD_HOST_FLAG)
|
||||
|
@ -841,7 +841,7 @@ mod cli_tests {
|
|||
|
||||
let cli_build = ExecCli::new(
|
||||
CMD_BUILD,
|
||||
file_from_root("crates/cli/tests/test-projects/effectful", "print-line.roc"),
|
||||
file_from_root("crates/cli/tests/test-projects/effectful", "print_line.roc"),
|
||||
);
|
||||
|
||||
let expected_output =
|
||||
|
@ -865,7 +865,7 @@ mod cli_tests {
|
|||
CMD_BUILD,
|
||||
file_from_root(
|
||||
"crates/cli/tests/test-projects/effectful",
|
||||
"inspect-logging.roc",
|
||||
"inspect_logging.roc",
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -1202,7 +1202,7 @@ mod cli_tests {
|
|||
Please enter an integer
|
||||
4
|
||||
"};
|
||||
test_benchmark("nQueens.roc", expected_output, Some("6"), UseValgrind::Yes);
|
||||
test_benchmark("n_queens.roc", expected_output, Some("6"), UseValgrind::Yes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1212,7 +1212,7 @@ mod cli_tests {
|
|||
Please enter an integer
|
||||
11 & 11
|
||||
"};
|
||||
test_benchmark("cFold.roc", expected_output, Some("3"), UseValgrind::Yes);
|
||||
test_benchmark("c_fold.roc", expected_output, Some("3"), UseValgrind::Yes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1234,7 +1234,7 @@ mod cli_tests {
|
|||
10
|
||||
"};
|
||||
test_benchmark(
|
||||
"rBTreeCk.roc",
|
||||
"r_b_tree_ck.roc",
|
||||
expected_output,
|
||||
Some("100"),
|
||||
UseValgrind::Yes,
|
||||
|
@ -1245,17 +1245,22 @@ mod cli_tests {
|
|||
#[cfg_attr(windows, ignore)]
|
||||
fn rbtree_insert() {
|
||||
let expected_output = "Node Black 0 {} Empty Empty\n";
|
||||
test_benchmark("rBTreeInsert.roc", expected_output, None, UseValgrind::Yes);
|
||||
test_benchmark(
|
||||
"r_b_tree_insert.roc",
|
||||
expected_output,
|
||||
None,
|
||||
UseValgrind::Yes,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(windows, ignore)]
|
||||
fn astar() {
|
||||
if cfg!(feature = "wasm32-cli-run") {
|
||||
eprintln!("WARNING: skipping testing benchmark testAStar.roc because it currently does not work on wasm32 due to dictionaries.");
|
||||
eprintln!("WARNING: skipping testing benchmark test_a_star.roc because it currently does not work on wasm32 due to dictionaries.");
|
||||
} else {
|
||||
let expected_output = "True\n";
|
||||
test_benchmark("testAStar.roc", expected_output, None, UseValgrind::Yes);
|
||||
test_benchmark("test_a_star.roc", expected_output, None, UseValgrind::Yes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1266,7 +1271,7 @@ mod cli_tests {
|
|||
encoded: SGVsbG8gV29ybGQ=
|
||||
decoded: Hello World
|
||||
"};
|
||||
test_benchmark("testBase64.roc", expected_output, None, UseValgrind::Yes);
|
||||
test_benchmark("test_base64.roc", expected_output, None, UseValgrind::Yes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1288,7 +1293,7 @@ mod cli_tests {
|
|||
fn quicksort_app() {
|
||||
let expected_output = "Please enter an integer\n[0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 6, 6, 8, 9]\n";
|
||||
test_benchmark(
|
||||
"quicksortApp.roc",
|
||||
"quicksort_app.roc",
|
||||
expected_output,
|
||||
Some("0"),
|
||||
UseValgrind::Yes,
|
||||
|
@ -1423,7 +1428,7 @@ mod cli_tests {
|
|||
CMD_FORMAT,
|
||||
file_from_root(
|
||||
"crates/cli/tests/test-projects/fixtures/format",
|
||||
"not-formatted.roc",
|
||||
"not_formatted.roc",
|
||||
),
|
||||
)
|
||||
.arg(CHECK_FLAG)
|
||||
|
@ -1433,7 +1438,7 @@ mod cli_tests {
|
|||
|
||||
#[test]
|
||||
fn format_check_folders() {
|
||||
// This fails, because "not-formatted.roc" is present in this folder
|
||||
// This fails, because "not_formatted.roc" is present in this folder
|
||||
ExecCli::new(
|
||||
CMD_FORMAT,
|
||||
dir_from_root("crates/cli/tests/test-projects/fixtures/format"),
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
To run, `cd` into this directory and run this in your terminal:
|
||||
|
||||
```bash
|
||||
roc --build-host --suppress-build-host-warning rocLovesC.roc
|
||||
roc --build-host --suppress-build-host-warning roc_loves_c.roc
|
||||
```
|
||||
|
||||
## About these examples
|
||||
|
|
|
@ -4,6 +4,6 @@ app [main] { pf: platform "c-platform/main.roc" }
|
|||
# ubuntu: sudo apt install build-essential clang
|
||||
# fedora: sudo dnf install clang
|
||||
|
||||
# run with `roc --build-host --suppress-build-host-warning rocLovesC.roc`
|
||||
# run with `roc --build-host --suppress-build-host-warning roc_loves_c.roc`
|
||||
|
||||
main = "Roc <3 C!\n"
|
|
@ -5,6 +5,6 @@ app [main] { pf: platform "zig-platform/main.roc" }
|
|||
# mkdir glue
|
||||
# cp crates/compiler/builtins/bitcode/src/* ./glue
|
||||
# cd -
|
||||
# roc --build-host --suppress-build-host-warning rocLovesZig.roc
|
||||
# roc --build-host --suppress-build-host-warning roc_loves_zig.roc
|
||||
|
||||
main = "Roc <3 Zig!\n"
|
|
@ -4,20 +4,20 @@ To run this website, we first compile the app that uses the Wasm platform:
|
|||
|
||||
- If you use the nightly roc release:
|
||||
```bash
|
||||
./roc build --target=wasm32 examples/platform-switching/rocLovesWebAssembly.roc
|
||||
./roc build --target=wasm32 examples/platform-switching/roc_loves_web_assembly.roc
|
||||
```
|
||||
- If you start from the compiler source code:
|
||||
```bash
|
||||
# Build roc compiler if you have not done so already
|
||||
cargo build
|
||||
target/debug/roc build --target=wasm32 examples/platform-switching/rocLovesWebAssembly.roc
|
||||
target/debug/roc build --target=wasm32 examples/platform-switching/roc_loves_web_assembly.roc
|
||||
```
|
||||
We then move the file:
|
||||
```bash
|
||||
# Go to the directory where index.html is
|
||||
cd examples/platform-switching/web-assembly-platform/
|
||||
# Move the .wasm file so that it's beside index.html
|
||||
mv ../rocLovesWebAssembly.wasm .
|
||||
mv ../roc_loves_web_assembly.wasm .
|
||||
```
|
||||
|
||||
In the directory where index.html is, run any web server on localhost.
|
||||
|
|
|
@ -15,7 +15,7 @@ global.fetch = (filename) =>
|
|||
|
||||
const { roc_web_platform_run } = require("./host");
|
||||
|
||||
roc_web_platform_run("./rocLovesWebAssembly.wasm", (string_from_roc) => {
|
||||
roc_web_platform_run("./roc_loves_web_assembly.wasm", (string_from_roc) => {
|
||||
const expected = "Roc <3 Web Assembly!\n";
|
||||
if (string_from_roc !== expected) {
|
||||
console.error(`Expected "${expected}", but got "${string_from_roc}"`);
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
<html>
|
||||
|
||||
<body>
|
||||
<div id="output"></div>
|
||||
<script src="./host.js"></script>
|
||||
<script>
|
||||
const elem = document.getElementById("output");
|
||||
roc_web_platform_run("./rocLovesWebAssembly.wasm", (string_from_roc) => {
|
||||
roc_web_platform_run("./roc_loves_web_assembly.wasm", (string_from_roc) => {
|
||||
elem.textContent = string_from_roc;
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -2,32 +2,32 @@
|
|||
source: crates/cli/tests/cli_tests.rs
|
||||
expression: cli_dev_out.normalize_stdout_and_stderr()
|
||||
---
|
||||
App1.baseUrl: https://api.example.com/one
|
||||
App2.baseUrl: http://api.example.com/two
|
||||
App3.baseUrl: https://api.example.com/three
|
||||
App1.getUser 1: https://api.example.com/one/users/1
|
||||
App2.getUser 2: http://api.example.com/two/users/2
|
||||
App3.getUser 3: https://api.example.com/three/users/3
|
||||
App1.getPost 1: https://api.example.com/one/posts/1
|
||||
App2.getPost 2: http://api.example.com/two/posts/2
|
||||
App3.getPost 3: https://api.example.com/three/posts/3
|
||||
App1.getPosts [1, 2]: ["https://api.example.com/one/posts/1", "https://api.example.com/one/posts/2"]
|
||||
App2.getPosts [3, 4]: ["http://api.example.com/two/posts/3", "http://api.example.com/two/posts/4"]
|
||||
App2.getPosts [5, 6]: ["http://api.example.com/two/posts/5", "http://api.example.com/two/posts/6"]
|
||||
App1.getPostComments 1: https://api.example.com/one/posts/1/comments
|
||||
App2.getPostComments 2: http://api.example.com/two/posts/2/comments
|
||||
App2.getPostComments 3: http://api.example.com/two/posts/3/comments
|
||||
App1.getCompanies [1, 2]: ["https://api.example.com/one/companies/1", "https://api.example.com/one/companies/2"]
|
||||
App2.getCompanies [3, 4]: ["http://api.example.com/two/companies/3", "http://api.example.com/two/companies/4"]
|
||||
App2.getCompanies [5, 6]: ["http://api.example.com/two/companies/5", "http://api.example.com/two/companies/6"]
|
||||
App1.getPostAliased 1: https://api.example.com/one/posts/1
|
||||
App2.getPostAliased 2: http://api.example.com/two/posts/2
|
||||
App3.getPostAliased 3: https://api.example.com/three/posts/3
|
||||
App1.baseUrlAliased: https://api.example.com/one
|
||||
App2.baseUrlAliased: http://api.example.com/two
|
||||
App3.baseUrlAliased: https://api.example.com/three
|
||||
App1.getUserSafe 1: https://api.example.com/one/users/1
|
||||
Prod.getUserSafe 2: http://api.example.com/prod_1/users/2?safe=true
|
||||
usersApp1: ["https://api.example.com/one/users/1", "https://api.example.com/one/users/2", "https://api.example.com/one/users/3"]
|
||||
getUserApp3Nested 3: https://api.example.com/three/users/3
|
||||
usersApp3Passed: ["https://api.example.com/three/users/1", "https://api.example.com/three/users/2", "https://api.example.com/three/users/3"]
|
||||
App1.base_url: https://api.example.com/one
|
||||
App2.base_url: http://api.example.com/two
|
||||
App3.base_url: https://api.example.com/three
|
||||
App1.get_user 1: https://api.example.com/one/users/1
|
||||
App2.get_user 2: http://api.example.com/two/users/2
|
||||
App3.get_user 3: https://api.example.com/three/users/3
|
||||
App1.get_post 1: https://api.example.com/one/posts/1
|
||||
App2.get_post 2: http://api.example.com/two/posts/2
|
||||
App3.get_post 3: https://api.example.com/three/posts/3
|
||||
App1.get_posts [1, 2]: ["https://api.example.com/one/posts/1", "https://api.example.com/one/posts/2"]
|
||||
App2.get_posts [3, 4]: ["http://api.example.com/two/posts/3", "http://api.example.com/two/posts/4"]
|
||||
App2.get_posts [5, 6]: ["http://api.example.com/two/posts/5", "http://api.example.com/two/posts/6"]
|
||||
App1.get_post_comments 1: https://api.example.com/one/posts/1/comments
|
||||
App2.get_post_comments 2: http://api.example.com/two/posts/2/comments
|
||||
App2.get_post_comments 3: http://api.example.com/two/posts/3/comments
|
||||
App1.get_companies [1, 2]: ["https://api.example.com/one/companies/1", "https://api.example.com/one/companies/2"]
|
||||
App2.get_companies [3, 4]: ["http://api.example.com/two/companies/3", "http://api.example.com/two/companies/4"]
|
||||
App2.get_companies [5, 6]: ["http://api.example.com/two/companies/5", "http://api.example.com/two/companies/6"]
|
||||
App1.get_post_aliased 1: https://api.example.com/one/posts/1
|
||||
App2.get_post_aliased 2: http://api.example.com/two/posts/2
|
||||
App3.get_post_aliased 3: https://api.example.com/three/posts/3
|
||||
App1.base_url_aliased: https://api.example.com/one
|
||||
App2.base_url_aliased: http://api.example.com/two
|
||||
App3.base_url_aliased: https://api.example.com/three
|
||||
App1.get_user_safe 1: https://api.example.com/one/users/1
|
||||
Prod.get_user_safe 2: http://api.example.com/prod_1/users/2?safe=true
|
||||
users_app1: ["https://api.example.com/one/users/1", "https://api.example.com/one/users/2", "https://api.example.com/one/users/3"]
|
||||
get_user_app3_nested 3: https://api.example.com/three/users/3
|
||||
users_app3_passed: ["https://api.example.com/three/users/1", "https://api.example.com/three/users/2", "https://api.example.com/three/users/3"]
|
||||
|
|
|
@ -7,7 +7,7 @@ module [
|
|||
walk_friend_names,
|
||||
]
|
||||
|
||||
## Datatype representing a community for demonstration purposes in inspect-gui.roc and inspect-logging.roc
|
||||
## Datatype representing a community for demonstration purposes in inspect_logging.roc
|
||||
|
||||
Community := {
|
||||
people : List Person,
|
||||
|
|
|
@ -63,7 +63,7 @@ with! = \path, callback! ->
|
|||
File.with_open!(path, \handle ->
|
||||
# I cant define scope here and put it in the list in callback. It breaks alias anaysis.
|
||||
# Instead I have to inline this.
|
||||
# root_scope = { data: Some handle, index: 0, buf: [], whileInfo: None }
|
||||
# root_scope = { data: Some handle, index: 0, buf: [], while_info: None }
|
||||
callback!({ scopes: [{ data: Some(handle), index: 0, buf: [], while_info: None }], state: Executing, stack: [], vars: List.repeat(Number(0), Variable.total_count) }))
|
||||
|
||||
# I am pretty sure there is a syntax to destructure and keep a reference to the whole, but Im not sure what it is.
|
||||
|
|
|
@ -278,7 +278,7 @@ step_exec_ctx! = \ctx, char ->
|
|||
Ok(a) ->
|
||||
Ok(a)
|
||||
|
||||
# Being explicit with error type is required to stop the need to propogate the error parameters to Context.popStack
|
||||
# Being explicit with error type is required to stop the need to propogate the error parameters to Context.pop_stack
|
||||
Err(EmptyStack) ->
|
||||
Err(EmptyStack)
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ base_url =
|
|||
## function def referencing params
|
||||
get_user : U32 -> Str
|
||||
get_user = \user_id ->
|
||||
# purposefully not using baseUrl to test top-level fn referencing param
|
||||
# purposefully not using base_url to test top-level fn referencing param
|
||||
protocol("api.example.com/${app_id}/users/${Num.to_str(user_id)}")
|
||||
|
||||
## function def referencing top-level value
|
||||
|
|
|
@ -27,33 +27,33 @@ main =
|
|||
List.map([1, 2, 3], App3.get_user)
|
||||
|
||||
"""
|
||||
App1.baseUrl: ${App1.base_url}
|
||||
App2.baseUrl: ${App2.base_url}
|
||||
App3.baseUrl: ${App3.base_url}
|
||||
App1.getUser 1: ${App1.get_user(1)}
|
||||
App2.getUser 2: ${App2.get_user(2)}
|
||||
App3.getUser 3: ${App3.get_user(3)}
|
||||
App1.getPost 1: ${App1.get_post(1)}
|
||||
App2.getPost 2: ${App2.get_post(2)}
|
||||
App3.getPost 3: ${App3.get_post(3)}
|
||||
App1.getPosts [1, 2]: ${Inspect.to_str(App1.get_posts([1, 2]))}
|
||||
App2.getPosts [3, 4]: ${Inspect.to_str(App2.get_posts([3, 4]))}
|
||||
App2.getPosts [5, 6]: ${Inspect.to_str(App2.get_posts([5, 6]))}
|
||||
App1.getPostComments 1: ${App1.get_post_comments(1)}
|
||||
App2.getPostComments 2: ${App2.get_post_comments(2)}
|
||||
App2.getPostComments 3: ${App2.get_post_comments(3)}
|
||||
App1.getCompanies [1, 2]: ${Inspect.to_str(App1.get_companies([1, 2]))}
|
||||
App2.getCompanies [3, 4]: ${Inspect.to_str(App2.get_companies([3, 4]))}
|
||||
App2.getCompanies [5, 6]: ${Inspect.to_str(App2.get_companies([5, 6]))}
|
||||
App1.getPostAliased 1: ${App1.get_post_aliased(1)}
|
||||
App2.getPostAliased 2: ${App2.get_post_aliased(2)}
|
||||
App3.getPostAliased 3: ${App3.get_post_aliased(3)}
|
||||
App1.baseUrlAliased: ${App1.base_url_aliased}
|
||||
App2.baseUrlAliased: ${App2.base_url_aliased}
|
||||
App3.baseUrlAliased: ${App3.base_url_aliased}
|
||||
App1.getUserSafe 1: ${App1.get_user_safe(1)}
|
||||
Prod.getUserSafe 2: ${Prod.get_user_safe(2)}
|
||||
usersApp1: ${Inspect.to_str(users_app1)}
|
||||
getUserApp3Nested 3: ${get_user_app3_nested(3)}
|
||||
usersApp3Passed: ${Inspect.to_str(users_app3_passed)}
|
||||
App1.base_url: ${App1.base_url}
|
||||
App2.base_url: ${App2.base_url}
|
||||
App3.base_url: ${App3.base_url}
|
||||
App1.get_user 1: ${App1.get_user(1)}
|
||||
App2.get_user 2: ${App2.get_user(2)}
|
||||
App3.get_user 3: ${App3.get_user(3)}
|
||||
App1.get_post 1: ${App1.get_post(1)}
|
||||
App2.get_post 2: ${App2.get_post(2)}
|
||||
App3.get_post 3: ${App3.get_post(3)}
|
||||
App1.get_posts [1, 2]: ${Inspect.to_str(App1.get_posts([1, 2]))}
|
||||
App2.get_posts [3, 4]: ${Inspect.to_str(App2.get_posts([3, 4]))}
|
||||
App2.get_posts [5, 6]: ${Inspect.to_str(App2.get_posts([5, 6]))}
|
||||
App1.get_post_comments 1: ${App1.get_post_comments(1)}
|
||||
App2.get_post_comments 2: ${App2.get_post_comments(2)}
|
||||
App2.get_post_comments 3: ${App2.get_post_comments(3)}
|
||||
App1.get_companies [1, 2]: ${Inspect.to_str(App1.get_companies([1, 2]))}
|
||||
App2.get_companies [3, 4]: ${Inspect.to_str(App2.get_companies([3, 4]))}
|
||||
App2.get_companies [5, 6]: ${Inspect.to_str(App2.get_companies([5, 6]))}
|
||||
App1.get_post_aliased 1: ${App1.get_post_aliased(1)}
|
||||
App2.get_post_aliased 2: ${App2.get_post_aliased(2)}
|
||||
App3.get_post_aliased 3: ${App3.get_post_aliased(3)}
|
||||
App1.base_url_aliased: ${App1.base_url_aliased}
|
||||
App2.base_url_aliased: ${App2.base_url_aliased}
|
||||
App3.base_url_aliased: ${App3.base_url_aliased}
|
||||
App1.get_user_safe 1: ${App1.get_user_safe(1)}
|
||||
Prod.get_user_safe 2: ${Prod.get_user_safe(2)}
|
||||
users_app1: ${Inspect.to_str(users_app1)}
|
||||
get_user_app3_nested 3: ${get_user_app3_nested(3)}
|
||||
users_app3_passed: ${Inspect.to_str(users_app3_passed)}
|
||||
"""
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -362,7 +362,7 @@ where
|
|||
// For now, using solve_trivial to avoid bug with loops.
|
||||
// Note: when disabling this, there was not much of a change in performance.
|
||||
// Notably, NQueens was about 5% slower. False interpreter was 0-5% faster (depending on input).
|
||||
// cFold and derive saw minor gains ~1.5%. rBTreeCk saw a big gain of ~4%.
|
||||
// c_fold and derive saw minor gains ~1.5%. r_b_tree_ck saw a big gain of ~4%.
|
||||
// This feels wrong, morphic should not really be able to slow down code.
|
||||
// Likely, noise or the bug and wrong inplace mutation lead to these perf changes.
|
||||
// When re-enabling this, we should analysis the perf and inplace mutations of a few apps.
|
||||
|
|
|
@ -3,7 +3,7 @@ module [Bool, Eq, true, false, not, is_eq, is_not_eq]
|
|||
## Defines a type that can be compared for total equality.
|
||||
##
|
||||
## Total equality means that all values of the type can be compared to each
|
||||
## other, and two values `a`, `b` are identical if and only if `isEq(a, b)` is
|
||||
## other, and two values `a`, `b` are identical if and only if `is_eq(a, b)` is
|
||||
## `Bool.true`.
|
||||
##
|
||||
## Not all types support total equality. For example, [`F32`](../Num#F32) and [`F64`](../Num#F64) can
|
||||
|
|
|
@ -59,7 +59,7 @@ DecodeError : [TooShort]
|
|||
## such as;
|
||||
## ```roc
|
||||
## expect
|
||||
## input = "\"hello\", " |> Str.toUtf8
|
||||
## input = "\"hello\", " |> Str.to_utf8
|
||||
## actual = Decode.from_bytes_partial(input, Json.json)
|
||||
## expected = Ok("hello")
|
||||
##
|
||||
|
@ -132,7 +132,7 @@ decode_with = |bytes, @Decoder(decode), fmt| decode(bytes, fmt)
|
|||
## Decode a `List U8` utf-8 bytes and return a [DecodeResult](#DecodeResult)
|
||||
## ```roc
|
||||
## expect
|
||||
## input = "\"hello\", " |> Str.toUtf8
|
||||
## input = "\"hello\", " |> Str.to_utf8
|
||||
## actual = Decode.from_bytes_partial(input Json.json)
|
||||
## expected = Ok("hello")
|
||||
##
|
||||
|
@ -146,7 +146,7 @@ from_bytes_partial = |bytes, fmt| decode_with(bytes, decoder, fmt)
|
|||
## remaining returns `Err Leftover (List U8)`.
|
||||
## ```roc
|
||||
## expect
|
||||
## input = "\"hello\", " |> Str.toUtf8
|
||||
## input = "\"hello\", " |> Str.to_utf8
|
||||
## actual = Decode.from_bytes(input, Json.json)
|
||||
## expected = Ok("hello")
|
||||
##
|
||||
|
|
|
@ -193,7 +193,7 @@ import Result exposing [Result]
|
|||
## have the type `Num *` at first, but usually end up taking on
|
||||
## a more specific type based on how they're used.
|
||||
##
|
||||
## For example, in `1 + List.len(myList)`, the `1` has the type `Num *` at first,
|
||||
## For example, in `1 + List.len(my_list)`, the `1` has the type `Num *` at first,
|
||||
## but because `List.len` returns a `U64`, the `1` ends up changing from
|
||||
## `Num *` to the more specific `U64`, and the expression as a whole
|
||||
## ends up having the type `U64`.
|
||||
|
@ -345,16 +345,16 @@ Int range : Num (Integer range)
|
|||
## If you don't specify a type, Roc will default to using [Dec] because it's
|
||||
## the least error-prone overall. For example, suppose you write this:
|
||||
## ```roc
|
||||
## wasItPrecise = 0.1 + 0.2 == 0.3
|
||||
## was_it_precise = 0.1 + 0.2 == 0.3
|
||||
## ```
|
||||
## The value of `wasItPrecise` here will be `Bool.true`, because Roc uses [Dec]
|
||||
## The value of `was_it_precise` here will be `Bool.true`, because Roc uses [Dec]
|
||||
## by default when there are no types specified.
|
||||
##
|
||||
## In contrast, suppose we use `f32` or `f64` for one of these numbers:
|
||||
## ```roc
|
||||
## wasItPrecise = 0.1f64 + 0.2 == 0.3
|
||||
## was_it_precise = 0.1f64 + 0.2 == 0.3
|
||||
## ```
|
||||
## Here, `wasItPrecise` will be `Bool.false` because the entire calculation will have
|
||||
## Here, `was_it_precise` will be `Bool.false` because the entire calculation will have
|
||||
## been done in a base-2 floating point calculation, which causes noticeable
|
||||
## precision loss in this case.
|
||||
##
|
||||
|
@ -726,7 +726,7 @@ abs_diff = |a, b|
|
|||
## Num.neg(0.0)
|
||||
## ```
|
||||
## !! Num.neg is not completely implemented for all types in all contexts, see github.com/roc-lang/roc/issues/6959
|
||||
## You can use `\someNum -> 0 - someNum` as a workaround.
|
||||
## You can use `\some_num -> 0 - some_num` as a workaround.
|
||||
##
|
||||
## This is safe to use with any [Frac], but it can cause overflow when used with certain [Int] values.
|
||||
##
|
||||
|
@ -904,7 +904,7 @@ log_checked = |x|
|
|||
## > access to hardware-accelerated performance, Roc follows these rules exactly.
|
||||
##
|
||||
## To divide an [Int] and a [Frac], first convert the [Int] to a [Frac] using
|
||||
## one of the functions in this module like #toDec.
|
||||
## one of the functions in this module like #to_dec.
|
||||
## ```roc
|
||||
## 5.0 / 7.0
|
||||
##
|
||||
|
@ -1125,7 +1125,7 @@ add_wrap : Int range, Int range -> Int range
|
|||
##
|
||||
## This is the same as [Num.add] except for the saturating behavior if the
|
||||
## addition is to overflow.
|
||||
## For example, if `x : U8` is 200 and `y : U8` is 100, `addSaturated x y` will
|
||||
## For example, if `x : U8` is 200 and `y : U8` is 100, `add_saturated x y` will
|
||||
## yield 255, the maximum value of a `U8`.
|
||||
add_saturated : Num a, Num a -> Num a
|
||||
|
||||
|
|
|
@ -597,8 +597,8 @@ expect (Str.from_utf8_lossy [82, 0xED, 0xA0, 0xBD, 99]) == "R<>c"
|
|||
## expect Str.from_utf16([0xd83d, 0xdc26]) == Ok("🐦")
|
||||
## expect Str.from_utf16([]) == Ok("")
|
||||
## # unpaired surrogates, first and second halves
|
||||
## expect Str.from_utf16([82, 0xd83d, 99]) |> Result.isErr
|
||||
## expect Str.from_utf16([82, 0xdc96, 99]) |> Result.isErr
|
||||
## expect Str.from_utf16([82, 0xd83d, 99]) |> Result.is_err
|
||||
## expect Str.from_utf16([82, 0xdc96, 99]) |> Result.is_err
|
||||
## ```
|
||||
from_utf16 : List U16 -> Result Str [BadUtf16 { problem : Utf8Problem, index : U64 }]
|
||||
from_utf16 = |codeunits|
|
||||
|
@ -700,10 +700,10 @@ expect Str.from_utf16_lossy([82, 0xdc96, 99]) == "R<>c"
|
|||
## expect Str.from_utf32([0xb9a, 0xbbf]) == Ok("சி")
|
||||
## expect Str.from_utf32([0x1f426]) == Ok("🐦")
|
||||
## # unpaired surrogates, first and second halves
|
||||
## expect Str.from_utf32([82, 0xd83d, 99]) |> Result.isErr
|
||||
## expect Str.from_utf32([82, 0xdc96, 99]) |> Result.isErr
|
||||
## expect Str.from_utf32([82, 0xd83d, 99]) |> Result.is_err
|
||||
## expect Str.from_utf32([82, 0xdc96, 99]) |> Result.is_err
|
||||
## # invalid codepoint
|
||||
## expect Str.from_utf32([82, 0x110000, 99]) |> Result.isErr
|
||||
## expect Str.from_utf32([82, 0x110000, 99]) |> Result.is_err
|
||||
## ```
|
||||
|
||||
from_utf32 : List U32 -> Result Str [BadUtf32 { problem : Utf8Problem, index : U64 }]
|
||||
|
|
|
@ -172,7 +172,7 @@ generate_entry_point = \buf, types, name, id ->
|
|||
extern_arguments =
|
||||
when Types.shape(types, id) is
|
||||
Function(roc_fn) ->
|
||||
to_arg_str(roc_fn.args, types, \_argId, shape, index ->
|
||||
to_arg_str(roc_fn.args, types, \_arg_id, shape, index ->
|
||||
index_str = Num.to_str(index)
|
||||
|
||||
if can_derive_copy(types, shape) then
|
||||
|
@ -254,7 +254,7 @@ generate_function = \buf, types, roc_fn ->
|
|||
|
||||
extern_call_arguments =
|
||||
without_unit =
|
||||
to_arg_str(roc_fn.args, types, \_argId, _shape, index ->
|
||||
to_arg_str(roc_fn.args, types, \_arg_id, _shape, index ->
|
||||
index_str = Num.to_str(index)
|
||||
|
||||
"&arg${index_str}")
|
||||
|
@ -814,7 +814,7 @@ generate_non_recursive_tag_union = \buf, types, id, name, tags, discriminant_siz
|
|||
b
|
||||
|> generate_roc_refcounted(types, union_type, escaped_name)
|
||||
|
||||
generate_non_nullable_unwrapped = \buf, types, name, tag_name, payload, discriminant_size, _discriminant_offset, _null_tagIndex ->
|
||||
generate_non_nullable_unwrapped = \buf, types, name, tag_name, payload, discriminant_size, _discriminant_offset, _null_tag_index ->
|
||||
escaped_name = escape_kw(name)
|
||||
discriminant_name = "discriminant_${escaped_name}"
|
||||
|
||||
|
@ -879,7 +879,7 @@ generate_recursive_tag_union = \buf, types, id, tag_union_name, tags, discrimina
|
|||
discriminant_name = "discriminant_${escaped_name}"
|
||||
tag_names = List.map(tags, \{ name: n } -> n)
|
||||
# self = "(&*self.union_pointer())"
|
||||
# selfMut = "(&mut *self.union_pointer())"
|
||||
# self_mut = "(&mut *self.union_pointer())"
|
||||
# other = "(&*other.union_pointer())"
|
||||
union_name = "union_${escaped_name}"
|
||||
|
||||
|
@ -1919,9 +1919,9 @@ has_float = \types, type ->
|
|||
has_float_help(types, type, Set.empty({}))
|
||||
|
||||
has_float_help = \types, type, do_not_recurse ->
|
||||
# TODO: is doNotRecurse problematic? Do we need an updated doNotRecurse for calls up the tree?
|
||||
# TODO: is do_not_recurse problematic? Do we need an updated do_not_recurse for calls up the tree?
|
||||
# I think there is a change it really only matters for RecursivePointer, so it may be fine.
|
||||
# Otherwise we need to deal with threading through updates to doNotRecurse
|
||||
# Otherwise we need to deal with threading through updates to do_not_recurse
|
||||
when type is
|
||||
Num(kind) ->
|
||||
when kind is
|
||||
|
@ -2145,9 +2145,9 @@ contains_refcounted = \types, type ->
|
|||
contains_refcounted_help(types, type, Set.empty({}))
|
||||
|
||||
contains_refcounted_help = \types, type, do_not_recurse ->
|
||||
# TODO: is doNotRecurse problematic? Do we need an updated doNotRecurse for calls up the tree?
|
||||
# TODO: is do_not_recurse problematic? Do we need an updated do_not_recurse for calls up the tree?
|
||||
# I think there is a change it really only matters for RecursivePointer, so it may be fine.
|
||||
# Otherwise we need to deal with threading through updates to doNotRecurse
|
||||
# Otherwise we need to deal with threading through updates to do_not_recurse
|
||||
when type is
|
||||
RocStr | RocList(_) | RocSet(_) | RocDict(_, _) | RocBox(_) | RecursivePointer(_) ->
|
||||
Bool.true
|
||||
|
|
|
@ -54,7 +54,7 @@ fn nixos_error_if_dynamic(url: &str, dest_dir: &Path) {
|
|||
Dynamically linked platforms can't be used on NixOS.\n\n\
|
||||
You can:\n\n\t\
|
||||
- Download the source of the platform and build it locally, like in this example:\n\t \
|
||||
https://github.com/roc-lang/roc/blob/main/examples/platform-switching/rocLovesC.roc.\n\t \
|
||||
https://github.com/roc-lang/roc/blob/main/examples/platform-switching/roc_loves_c.roc.\n\t \
|
||||
For some graphical platforms you may need to use https://github.com/guibou/nixGL.\n\n\t\
|
||||
- Contact the author of the platform to ask them to statically link their platform.\n\t \
|
||||
musl can be used to prevent a dynamic dependency on the systems' libc.\n\t \
|
||||
|
|
|
@ -64,11 +64,11 @@ get_page_info = \page_path_str ->
|
|||
Str.split_on(page_path_str, "/")
|
||||
|> List.take_last(2)
|
||||
|> List.first # we use the folder for name for the page title, e.g. Json from examples/Json/README.html
|
||||
|> unwrap_or_crash("This List.first should never fail. pagePathStr ($(page_path_str)) did not contain any `/`.")
|
||||
|> unwrap_or_crash("This List.first should never fail. page_path_str ($(page_path_str)) did not contain any `/`.")
|
||||
|> (\page_title ->
|
||||
{ title: "$(page_title) | Roc", description: "$(page_title) example in the Roc programming language." })
|
||||
else
|
||||
crash("Web page $(page_path_str) did not have a title and description specified in the pageData Dict. Please add one.")
|
||||
crash("Web page $(page_path_str) did not have a title and description specified in the page_data Dict. Please add one.")
|
||||
|
||||
unwrap_or_crash : Result a b, Str -> a where b implements Inspect
|
||||
unwrap_or_crash = \result, error_msg ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue