diff --git a/build.roc b/build.roc index 4c03c147..87f3ed19 100755 --- a/build.roc +++ b/build.roc @@ -15,16 +15,16 @@ import cli.Env main! : _ => Result {} _ main! = |_args| - roc_cmd = Env.var!("ROC") |> Result.with_default("roc") + roc_cmd = Env.var!("ROC") ?? "roc" debug_mode = when Env.var!("DEBUG") is - Ok(str) if !(Str.is_empty(str)) -> Debug + Ok(str) if !Str.is_empty(str) -> Debug _ -> Release roc_version!(roc_cmd)? - os_and_arch = get_os_and_arch!({})? + os_and_arch = get_os_and_arch!()? stub_lib_path = "platform/libapp.${stub_file_extension(os_and_arch)}" @@ -49,11 +49,11 @@ roc_version! = |roc_cmd| Cmd.exec!(roc_cmd, ["version"]) |> Result.map_err(RocVersionCheckFailed) -get_os_and_arch! : {} => Result OSAndArch _ -get_os_and_arch! = |{}| +get_os_and_arch! : () => Result OSAndArch _ +get_os_and_arch! = || info!("Getting the native operating system and architecture ...")? - convert_os_and_arch!(Env.platform!({})) + convert_os_and_arch!(Env.platform!()) OSAndArch : [ MacosArm64, @@ -117,7 +117,7 @@ get_rust_target_folder! = |debug_mode| cargo_build_host! : [Debug, Release] => Result {} _ cargo_build_host! = |debug_mode| - cargo_build_args! = |{}| + cargo_build_args! = || when debug_mode is Debug -> info!("Building rust host in debug mode...")? @@ -127,7 +127,7 @@ cargo_build_host! = |debug_mode| info!("Building rust host ...")? Ok(["build", "--release"]) - args = cargo_build_args!({})? + args = cargo_build_args!()? Cmd.exec!("cargo", args) |> Result.map_err(ErrBuildingHostBinaries) diff --git a/examples/command.roc b/examples/command.roc index f1611c41..60e7bca0 100644 --- a/examples/command.roc +++ b/examples/command.roc @@ -6,21 +6,22 @@ import pf.Stdout import pf.Cmd main! = |_args| - status_example!({})? + status_example!()? - output_example!({})? + output_example!()? - exec_example!({})? + exec_example!()? Ok({}) -exec_example! : {} => Result {} _ -exec_example! = |{}| Cmd.exec!("echo", ["EXEC"]) +exec_example! : () => Result {} _ +exec_example! = || + Cmd.exec!("echo", ["EXEC"]) # Run "env" with verbose option, clear all environment variables, and pass in # "FOO" and "BAZ". -status_example! : {} => Result {} _ -status_example! = |{}| +status_example! : () => Result {} _ +status_example! = || result = Cmd.new("env") |> Cmd.arg("-v") @@ -35,8 +36,8 @@ status_example! = |{}| # Run "env" with verbose option, clear all environment variables, and pass in # only as an environment variable "FOO" -output_example! : {} => Result {} _ -output_example! = |{}| +output_example! : () => Result {} _ +output_example! = || output = Cmd.new("env") @@ -45,6 +46,6 @@ output_example! = |{}| |> Cmd.args(["-v"]) |> Cmd.output! - msg = Str.from_utf8(output.stdout) |> Result.with_default("Failed to decode stdout") + msg = Str.from_utf8(output.stdout) ?? "Failed to decode stdout" Stdout.write!(msg) diff --git a/examples/countdown.roc b/examples/countdown.roc index 68895cda..d72d9f1b 100644 --- a/examples/countdown.roc +++ b/examples/countdown.roc @@ -7,7 +7,7 @@ import pf.Stdout main! = |_args| Stdout.line!("\nLet's count down from 3 together - all you have to do is press .")? - _ = Stdin.line!({}) + _ = Stdin.line!() tick!(3) tick! = |n| @@ -15,6 +15,6 @@ tick! = |n| Stdout.line!("🎉 SURPRISE! Happy Birthday! 🎂")? Ok({}) else - Stdout.line!("${Num.to_str n}...")? - _ = Stdin.line!({}) + Stdout.line!("${Num.to_str(n)}...")? + _ = Stdin.line!() tick!(n - 1) diff --git a/examples/echo.roc b/examples/echo.roc index 4cbb27b7..add65d5c 100644 --- a/examples/echo.roc +++ b/examples/echo.roc @@ -7,14 +7,14 @@ import pf.Stdout main! = |_args| Stdout.line!("Shout into this cave and hear the echo!")? - tick!({}) + tick!() -tick! : {} => Result {} [StdoutErr _] -tick! = |{}| - when Stdin.line!({}) is +tick! : () => Result {} [StdoutErr _] +tick! = || + when Stdin.line!() is Ok(str) -> Stdout.line!(echo(str))? - tick!({}) + tick!() Err(EndOfFile) -> Stdout.line!(echo("Received end of input (EOF)."))? @@ -32,10 +32,10 @@ echo = |shout| |> Str.to_utf8 |> List.map_with_index( |_, i| - length = (List.len(Str.to_utf8(shout)) - i) - phrase = (List.split_at(Str.to_utf8(shout), length)).before + length = List.len(Str.to_utf8(shout)) - i + { before: phrase} = List.split_at(Str.to_utf8(shout), length) - List.concat(silence((if i == 0 then 2 * length else length)), phrase), + List.concat(silence(if i == 0 then 2 * length else length), phrase), ) |> List.join |> Str.from_utf8 diff --git a/examples/file-mixed.roc b/examples/file-mixed.roc index c78e0e74..7a4c3f9f 100644 --- a/examples/file-mixed.roc +++ b/examples/file-mixed.roc @@ -11,9 +11,9 @@ import pf.Dir out_txt_path = "out.txt" -task! = |{}| +task! = || - cwd_str = Path.display(Env.cwd!({})?) + cwd_str = Path.display(Env.cwd!()?) Stdout.line!("cwd: ${cwd_str}")? @@ -34,7 +34,7 @@ task! = |{}| Ok({}) main! = |_args| - when task!({}) is + when task!() is Ok({}) -> Stdout.line!("Successfully wrote a string to out.txt") Err(err) -> msg = diff --git a/examples/file-read.roc b/examples/file-read.roc index c0e93de6..82379b33 100644 --- a/examples/file-read.roc +++ b/examples/file-read.roc @@ -7,7 +7,7 @@ import pf.File main! = |_args| - run!({}) + run!() ? |err| msg = when err is @@ -21,9 +21,9 @@ main! = |_args| Ok({}) -run! = |{}| +run! = || file_name = "LICENSE" contents = File.read_utf8!(file_name)? lines = Str.split_on(contents, "\n") - Stdout.line!(Str.concat("First line of ${file_name}: ", (List.first(lines) |> Result.with_default("err")))) + Stdout.line!(Str.concat("First line of ${file_name}: ", List.first(lines) ?? "err")) diff --git a/examples/form.roc b/examples/form.roc index c93ff7d0..2f65967d 100644 --- a/examples/form.roc +++ b/examples/form.roc @@ -9,10 +9,10 @@ main! = |_args| Stdout.line!("What's your first name?")? - first = Stdin.line!({})? + first = Stdin.line!()? Stdout.line!("What's your last name?")? - last = Stdin.line!({})? + last = Stdin.line!()? Stdout.line!("Hi, ${first} ${last}! 👋") diff --git a/examples/piping.roc b/examples/piping.roc index f92b2200..9ecd398e 100644 --- a/examples/piping.roc +++ b/examples/piping.roc @@ -11,6 +11,6 @@ main! = |_args| Stdout.line!("I read ${Num.to_str(lines)} lines from stdin.") count! = |n| - when Stdin.line!({}) is - Ok(_) -> count!((n + 1)) + when Stdin.line!() is + Ok(_) -> count!(n + 1) Err(_) -> n diff --git a/examples/stdin.roc b/examples/stdin.roc index 29e82d6e..4cbf3e8d 100644 --- a/examples/stdin.roc +++ b/examples/stdin.roc @@ -9,7 +9,7 @@ import pf.Stdin main! = |_args| Stdout.line!("Enter a series of number characters (0-9):")? - number_bytes = take_number_bytes!({})? + number_bytes = take_number_bytes!()? if List.is_empty(number_bytes) then Stderr.line!("Expected a series of number characters (0-9)") @@ -21,9 +21,9 @@ main! = |_args| Err(_) -> Stderr.line!("Error, bad utf8") -take_number_bytes! : {} => Result (List U8) _ -take_number_bytes! = |{}| - bytes_read = Stdin.bytes!({})? +take_number_bytes! : () => Result (List U8) _ +take_number_bytes! = || + bytes_read = Stdin.bytes!()? number_bytes = List.walk( diff --git a/examples/tcp-client.roc b/examples/tcp-client.roc index 9c67d4b4..9c46bd50 100644 --- a/examples/tcp-client.roc +++ b/examples/tcp-client.roc @@ -8,7 +8,7 @@ import pf.Stderr # To run this example: check the README.md in this folder main! = |_args| - when run!({}) is + when run!() is Ok({}) -> Ok({}) Err(err) -> handle_err!(err) @@ -42,8 +42,8 @@ handle_err! = |error| other -> Stderr.line!("Got other error: ${Inspect.to_str(other)}") -run! : {} => Result {} _ -run! = |{}| +run! : () => Result {} _ +run! = || stream = Tcp.connect!("127.0.0.1", 8085)? @@ -58,7 +58,7 @@ tick! : Tcp.Stream => Result {} _ tick! = |stream| Stdout.write!("> ")? - out_msg = Stdin.line!({})? + out_msg = Stdin.line!()? Tcp.write_utf8!(stream, "${out_msg}\n")? diff --git a/examples/temp-dir.roc b/examples/temp-dir.roc index 270b705d..c49d0c47 100644 --- a/examples/temp-dir.roc +++ b/examples/temp-dir.roc @@ -12,7 +12,7 @@ import pf.Path ## for example: `roc build examples/temp-dir.roc --linker=legacy` main! = |_args| - temp_dir_str = Path.display(Env.temp_dir!({})) + temp_dir_str = Path.display(Env.temp_dir!()) Stdout.line!("The temp dir path is ${temp_dir_str}") |> Result.map_err(|err| Exit(1, "Failed to print temp dir:\n\t${Inspect.to_str(err)}")) diff --git a/examples/time.roc b/examples/time.roc index 13cbcaf1..04a201a5 100644 --- a/examples/time.roc +++ b/examples/time.roc @@ -7,11 +7,11 @@ import pf.Sleep # To run this example: check the README.md in this folder main! = |_args| - start = Utc.now!({}) + start = Utc.now!() Sleep.millis!(1500) - finish = Utc.now!({}) + finish = Utc.now!() duration = Num.to_str(Utc.delta_as_nanos(start, finish)) diff --git a/platform/Env.roc b/platform/Env.roc index 83ddb87d..e1afabc5 100644 --- a/platform/Env.roc +++ b/platform/Env.roc @@ -16,9 +16,9 @@ import Host ## Reads the [current working directory](https://en.wikipedia.org/wiki/Working_directory) ## from the environment. File operations on relative [Path]s are relative to this directory. -cwd! : {} => Result Path [CwdUnavailable] -cwd! = |{}| - bytes = Host.cwd!({}) |> Result.with_default([]) +cwd! : () => Result Path [CwdUnavailable] +cwd! = || + bytes = Host.cwd!() ?? [] if List.is_empty(bytes) then Err(CwdUnavailable) @@ -30,13 +30,12 @@ cwd! = |{}| ## to this directory. set_cwd! : Path => Result {} [InvalidCwd] set_cwd! = |path| - Host.set_cwd!(InternalPath.to_bytes(path)) - |> Result.map_err(|{}| InvalidCwd) + Host.set_cwd!(InternalPath.to_bytes(path)) |> Result.map_err(|_| InvalidCwd) ## Gets the path to the currently-running executable. -exe_path! : {} => Result Path [ExePathUnavailable] -exe_path! = |{}| - when Host.exe_path!({}) is +exe_path! : () => Result Path [ExePathUnavailable] +exe_path! = || + when Host.exe_path!() is Ok(bytes) -> Ok(InternalPath.from_os_bytes(bytes)) Err({}) -> Err(ExePathUnavailable) @@ -46,8 +45,7 @@ exe_path! = |{}| ## [Unicode replacement character](https://unicode.org/glossary/#replacement_character) ('�'). var! : Str => Result Str [VarNotFound] var! = |name| - Host.env_var!(name) - |> Result.map_err(|{}| VarNotFound) + Host.env_var!(name) |> Result.map_err(|_| VarNotFound) ## Reads the given environment variable and attempts to decode it. ## @@ -81,17 +79,16 @@ decode! = |name| Err({}) -> Err(VarNotFound) Ok(var_str) -> Str.to_utf8(var_str) - |> Decode.from_bytes(EnvDecoding.format({})) + |> Decode.from_bytes(EnvDecoding.format()) |> Result.map_err(|_| DecodeErr(TooShort)) ## Reads all the process's environment variables into a [Dict]. ## ## If any key or value contains invalid Unicode, the [Unicode replacement character](https://unicode.org/glossary/#replacement_character) ## will be used in place of any parts of keys or values that are invalid Unicode. -dict! : {} => Dict Str Str -dict! = |{}| - Host.env_dict!({}) - |> Dict.from_list +dict! : () => Dict Str Str +dict! = || + Dict.from_list(Host.env_dict!()) # ## Walks over the process's environment variables as key-value arguments to the walking function. # ## @@ -135,10 +132,10 @@ OS : [LINUX, MACOS, WINDOWS, OTHER Str] ## ## Note these values are constants from when the platform is built. ## -platform! : {} => { arch : ARCH, os : OS } -platform! = |{}| +platform! : () => { arch : ARCH, os : OS } +platform! = || - from_rust = Host.current_arch_os!({}) + from_rust = Host.current_arch_os!() arch = when from_rust.arch is @@ -166,7 +163,6 @@ platform! = |{}| ## to create a uniquely named file. Creating a file or directory with a fixed or predictable name may ## result in “insecure temporary file” security vulnerabilities. ## -temp_dir! : {} => Path -temp_dir! = |{}| - Host.temp_dir!({}) - |> InternalPath.from_os_bytes +temp_dir! : () => Path +temp_dir! = || + InternalPath.from_os_bytes(Host.temp_dir!()) diff --git a/platform/EnvDecoding.roc b/platform/EnvDecoding.roc index 4c710804..b51452c2 100644 --- a/platform/EnvDecoding.roc +++ b/platform/EnvDecoding.roc @@ -26,8 +26,8 @@ EnvFormat := {} implements [ }, ] -format : {} -> EnvFormat -format = |{}| @EnvFormat({}) +format : () -> EnvFormat +format = || @EnvFormat({}) decode_bytes_to_num = |bytes, transformer| when Str.from_utf8(bytes) is diff --git a/platform/Host.roc b/platform/Host.roc index a12791ea..28a37631 100644 --- a/platform/Host.roc +++ b/platform/Host.roc @@ -80,17 +80,17 @@ dir_delete_all! : List U8 => Result {} InternalIOErr.IOErrFromHost hard_link! : List U8 => Result {} InternalIOErr.IOErrFromHost path_type! : List U8 => Result InternalPath.InternalPathType InternalIOErr.IOErrFromHost -cwd! : {} => Result (List U8) {} -temp_dir! : {} => List U8 +cwd! : () => Result (List U8) {} +temp_dir! : () => List U8 # STDIO stdout_line! : Str => Result {} InternalIOErr.IOErrFromHost stdout_write! : Str => Result {} InternalIOErr.IOErrFromHost stderr_line! : Str => Result {} InternalIOErr.IOErrFromHost stderr_write! : Str => Result {} InternalIOErr.IOErrFromHost -stdin_line! : {} => Result Str InternalIOErr.IOErrFromHost -stdin_bytes! : {} => Result (List U8) InternalIOErr.IOErrFromHost -stdin_read_to_end! : {} => Result (List U8) InternalIOErr.IOErrFromHost +stdin_line! : () => Result Str InternalIOErr.IOErrFromHost +stdin_bytes! : () => Result (List U8) InternalIOErr.IOErrFromHost +stdin_read_to_end! : () => Result (List U8) InternalIOErr.IOErrFromHost # TCP send_request! : InternalHttp.RequestToAndFromHost => InternalHttp.ResponseToAndFromHost @@ -111,19 +111,19 @@ sqlite_step! : Box {} => Result InternalSqlite.SqliteState InternalSqlite.Sqlite sqlite_reset! : Box {} => Result {} InternalSqlite.SqliteError # OTHERS -current_arch_os! : {} => { arch : Str, os : Str } +current_arch_os! : () => { arch : Str, os : Str } -get_locale! : {} => Result Str {} -get_locales! : {} => List Str +get_locale! : () => Result Str {} +get_locales! : () => List Str -posix_time! : {} => U128 # TODO why is this a U128 but then getting converted to a I128 in Utc.roc? +posix_time! : () => U128 # TODO why is this a U128 but then getting converted to a I128 in Utc.roc? sleep_millis! : U64 => {} -tty_mode_canonical! : {} => {} -tty_mode_raw! : {} => {} +tty_mode_canonical! : () => {} +tty_mode_raw! : () => {} -env_dict! : {} => List (Str, Str) +env_dict! : () => List (Str, Str) env_var! : Str => Result Str {} -exe_path! : {} => Result (List U8) {} +exe_path! : () => Result (List U8) {} set_cwd! : List U8 => Result {} {} diff --git a/platform/Http.roc b/platform/Http.roc index f99d6ed8..9aae4e40 100644 --- a/platform/Http.roc +++ b/platform/Http.roc @@ -55,7 +55,7 @@ header = |(name, value)| { name, value } ## ## ``` ## # Prints out the HTML of the Roc-lang website. -## response = || +## response = or ## Http.send!({ Http.default_request & url: "https://www.roc-lang.org" })? ## ## diff --git a/platform/InternalDateTime.roc b/platform/InternalDateTime.roc index 49dc0e03..17af6dc0 100644 --- a/platform/InternalDateTime.roc +++ b/platform/InternalDateTime.roc @@ -55,14 +55,14 @@ is_leap_year = |year| && # divided evenly by 4 unless... ( (year % 100 != 0) - || # divided by 100 not a leap year + or # divided by 100 not a leap year (year % 400 == 0) # expecpt when also divisible by 400 ) expect is_leap_year(2000) expect is_leap_year(2012) -expect !(is_leap_year(1900)) -expect !(is_leap_year(2015)) +expect !is_leap_year(1900) +expect !is_leap_year(2015) expect List.map([2023, 1988, 1992, 1996], is_leap_year) == [Bool.false, Bool.true, Bool.true, Bool.true] expect List.map([1700, 1800, 1900, 2100, 2200, 2300, 2500, 2600], is_leap_year) == [Bool.false, Bool.false, Bool.false, Bool.false, Bool.false, Bool.false, Bool.false, Bool.false] @@ -116,9 +116,9 @@ epoch_millis_to_datetimeHelp = |current| count_days_in_month = days_in_month(current.year, current.month) count_days_in_prev_month = if current.month == 1 then - days_in_month((current.year - 1), 12) + days_in_month(current.year - 1, 12) else - days_in_month(current.year, (current.month - 1)) + days_in_month(current.year, current.month - 1) if current.day < 1 then epoch_millis_to_datetimeHelp( diff --git a/platform/Locale.roc b/platform/Locale.roc index 9c32fe72..cf667162 100644 --- a/platform/Locale.roc +++ b/platform/Locale.roc @@ -8,13 +8,13 @@ import Host ## Returns the most preferred locale for the system or application, or `NotAvailable` if the locale could not be obtained. ## ## The returned [Str] is a BCP 47 language tag, like `en-US` or `fr-CA`. -get! : {} => Result Str [NotAvailable] -get! = |{}| - Host.get_locale!({}) - |> Result.map_err(|{}| NotAvailable) +get! : () => Result Str [NotAvailable] +get! = || + Host.get_locale!() + |> Result.map_err(|_| NotAvailable) ## Returns the preferred locales for the system or application. ## ## The returned [Str] are BCP 47 language tags, like `en-US` or `fr-CA`. -all! : {} => List Str +all! : () => List Str all! = Host.get_locales! diff --git a/platform/Path.roc b/platform/Path.roc index 8096e06f..330da5c7 100644 --- a/platform/Path.roc +++ b/platform/Path.roc @@ -184,7 +184,7 @@ display = |path| is_dir! : Path => Result Bool [PathErr IOErr] is_dir! = |path| res = type!(path)? - Ok((res == IsDir)) + Ok(res == IsDir) ## Returns true if the path exists on disk and is pointing at a regular file. ## Returns `Ok false` if the path exists and it is not a file. If the path does not exist, @@ -196,7 +196,7 @@ is_dir! = |path| is_file! : Path => Result Bool [PathErr IOErr] is_file! = |path| res = type!(path)? - Ok((res == IsFile)) + Ok(res == IsFile) ## Returns true if the path exists on disk and is pointing at a symbolic link. ## Returns `Ok false` if the path exists and it is not a symbolic link. If the path does not exist, @@ -208,7 +208,7 @@ is_file! = |path| is_sym_link! : Path => Result Bool [PathErr IOErr] is_sym_link! = |path| res = type!(path)? - Ok((res == IsSymLink)) + Ok(res == IsSymLink) ## Return the type of the path if the path exists on disk. ## @@ -246,7 +246,7 @@ with_extension = |path, extension| Err(NotFound) -> bytes before_dot - |> List.reserve((Str.count_utf8_bytes(extension) |> Num.int_cast |> Num.add_saturated(1))) + |> List.reserve(Str.count_utf8_bytes(extension) |> Num.int_cast |> Num.add_saturated(1)) |> List.append(Num.to_u8('.')) |> List.concat(Str.to_utf8(extension)) |> ArbitraryBytes @@ -259,7 +259,7 @@ with_extension = |path, extension| Err(NotFound) -> str before_dot - |> Str.reserve((Str.count_utf8_bytes(extension) |> Num.add_saturated(1))) + |> Str.reserve(Str.count_utf8_bytes(extension) |> Num.add_saturated(1)) |> Str.concat(".") |> Str.concat(extension) |> FromStr diff --git a/platform/Sqlite.roc b/platform/Sqlite.roc index 661dd209..c2342dc6 100644 --- a/platform/Sqlite.roc +++ b/platform/Sqlite.roc @@ -670,7 +670,7 @@ internal_to_external_error = |{ code, message }| # internal use only code_from_i64 : I64 -> ErrCode code_from_i64 = |code| - if code == 1 || code == 0 then + if code == 1 or code == 0 then Error else if code == 2 then Internal diff --git a/platform/Stdin.roc b/platform/Stdin.roc index af29c2b8..2e664de6 100644 --- a/platform/Stdin.roc +++ b/platform/Stdin.roc @@ -53,9 +53,9 @@ handle_err = |{ tag, msg }| ## (e.g. because the user pressed Enter in the terminal), so using it can result in the appearance of the ## programming having gotten stuck. It's often helpful to print a prompt first, so ## the user knows it's necessary to enter something before the program will continue. -line! : {} => Result Str [EndOfFile, StdinErr IOErr] -line! = |{}| - Host.stdin_line!({}) +line! : () => Result Str [EndOfFile, StdinErr IOErr] +line! = || + Host.stdin_line!() |> Result.map_err(handle_err) ## Read bytes from [standard input](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)). @@ -64,15 +64,15 @@ line! = |{}| ## > This is typically used in combintation with [Tty.enable_raw_mode!], ## which disables defaults terminal bevahiour and allows reading input ## without buffering until Enter key is pressed. -bytes! : {} => Result (List U8) [EndOfFile, StdinErr IOErr] -bytes! = |{}| - Host.stdin_bytes!({}) +bytes! : () => Result (List U8) [EndOfFile, StdinErr IOErr] +bytes! = || + Host.stdin_bytes!() |> Result.map_err(handle_err) ## Read all bytes from [standard input](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)) until EOF in this source. -read_to_end! : {} => Result (List U8) [StdinErr IOErr] -read_to_end! = |{}| - Host.stdin_read_to_end!({}) +read_to_end! : () => Result (List U8) [StdinErr IOErr] +read_to_end! = || + Host.stdin_read_to_end!() |> Result.map_err( |{ tag, msg }| when tag is diff --git a/platform/Tty.roc b/platform/Tty.roc index 741ebe5c..8d6d33d4 100644 --- a/platform/Tty.roc +++ b/platform/Tty.roc @@ -19,14 +19,14 @@ import Host ## ## Note: we plan on moving this function away from basic-cli in the future, see github.com/roc-lang/basic-cli/issues/73 ## -enable_raw_mode! : {} => {} -enable_raw_mode! = |{}| - Host.tty_mode_raw!({}) +enable_raw_mode! : () => {} +enable_raw_mode! = || + Host.tty_mode_raw!() ## Revert terminal to default behaviour ## ## Note: we plan on moving this function away from basic-cli in the future, see github.com/roc-lang/basic-cli/issues/73 ## -disable_raw_mode! : {} => {} -disable_raw_mode! = |{}| - Host.tty_mode_canonical!({}) +disable_raw_mode! : () => {} +disable_raw_mode! = || + Host.tty_mode_canonical!() diff --git a/platform/Url.roc b/platform/Url.roc index dfa496d9..15a7720d 100644 --- a/platform/Url.roc +++ b/platform/Url.roc @@ -194,7 +194,7 @@ percent_encode : Str -> Str percent_encode = |input| # Optimistically assume we won't need any percent encoding, and can have # the same capacity as the input string. If we're wrong, it will get doubled. - initial_output = List.with_capacity((Str.count_utf8_bytes(input) |> Num.int_cast)) + initial_output = List.with_capacity(Str.count_utf8_bytes(input) |> Num.int_cast) answer = List.walk( @@ -204,8 +204,8 @@ percent_encode = |input| # Spec for percent-encoding: https://www.ietf.org/rfc/rfc3986.txt if (byte >= 97 && byte <= 122) # lowercase ASCII - || (byte >= 65 && byte <= 90) # uppercase ASCII - || (byte >= 48 && byte <= 57) # digit + or (byte >= 65 && byte <= 90) # uppercase ASCII + or (byte >= 48 && byte <= 57) # digit then # This is the most common case: an unreserved character, # which needs no encoding in a path @@ -228,8 +228,7 @@ percent_encode = |input| List.concat(output, suffix), ) - Str.from_utf8(answer) - |> Result.with_default("") # This should never fail + Str.from_utf8(answer) ?? "" # This should never fail ## Adds a [Str] query parameter to the end of the [Url]. ## @@ -275,7 +274,7 @@ append_param = |@Url(url_str), key, value| without_fragment |> Str.reserve(bytes) - |> Str.concat((if has_query(@Url(without_fragment)) then "&" else "?")) + |> Str.concat(if has_query(@Url(without_fragment)) then "&" else "?") |> Str.concat(encoded_key) |> Str.concat("=") |> Str.concat(encoded_value) @@ -456,7 +455,7 @@ query_params = |url| query(url) |> Str.split_on("&") |> List.walk( - Dict.empty({}), + Dict.empty(), |dict, pair| when Str.split_first(pair, "=") is Ok({ before, after }) -> Dict.insert(dict, before, after) diff --git a/platform/Utc.roc b/platform/Utc.roc index ae7da33f..99cc1962 100644 --- a/platform/Utc.roc +++ b/platform/Utc.roc @@ -17,9 +17,9 @@ import InternalDateTime Utc := I128 implements [Inspect] ## Duration since UNIX EPOCH -now! : {} => Utc -now! = |{}| - @Utc(Num.to_i128(Host.posix_time!({}))) +now! : () => Utc +now! = || + @Utc(Num.to_i128(Host.posix_time!())) # Constant number of nanoseconds in a millisecond nanos_per_milli = 1_000_000 @@ -32,7 +32,7 @@ to_millis_since_epoch = |@Utc(nanos)| ## Convert milliseconds to Utc timestamp from_millis_since_epoch : I128 -> Utc from_millis_since_epoch = |millis| - @Utc((millis * nanos_per_milli)) + @Utc(millis * nanos_per_milli) ## Convert Utc timestamp to nanoseconds to_nanos_since_epoch : Utc -> I128 @@ -46,7 +46,7 @@ from_nanos_since_epoch = @Utc ## Calculate milliseconds between two Utc timestamps delta_as_millis : Utc, Utc -> U128 delta_as_millis = |utc_a, utc_b| - (delta_as_nanos(utc_a, utc_b)) // nanos_per_milli + delta_as_nanos(utc_a, utc_b) // nanos_per_milli ## Calculate nanoseconds between two Utc timestamps delta_as_nanos : Utc, Utc -> U128 diff --git a/platform/libapp.roc b/platform/libapp.roc index 41c2a21e..e31f288c 100644 --- a/platform/libapp.roc +++ b/platform/libapp.roc @@ -4,4 +4,4 @@ app [main!] { pf: platform "main.roc" } # executable built correctly just by running it. main! : _ => Result {} [Exit I32 Str]_ main! = |_args| - Err(JustAStub) + Err(Stub)