From f205e1e8032fb4fd24af64166adc1180eaf8dd4c Mon Sep 17 00:00:00 2001
From: Giacomo Cavalieri
Date: Mon, 21 Oct 2024 16:22:17 +0200
Subject: [PATCH 1/4] replace io.debug with echo
---
.../chapter0_basics/lesson05_ints/code.gleam | 27 +++++++++----------
.../lesson06_floats/code.gleam | 27 +++++++++----------
.../lesson07_number_formats/code.gleam | 16 +++++------
.../lesson08_equality/code.gleam | 6 ++---
.../lesson09_strings/code.gleam | 12 ++++-----
.../chapter0_basics/lesson10_bools/code.gleam | 13 +++++----
.../lesson11_assignments/code.gleam | 8 +++---
.../lesson15_type_aliases/code.gleam | 4 +--
.../lesson16_blocks/code.gleam | 6 ++---
.../chapter0_basics/lesson17_lists/code.gleam | 10 +++----
.../lesson18_constants/code.gleam | 10 +++----
.../lesson00_functions/code.gleam | 4 +--
.../code.gleam | 6 ++---
.../lesson04_anonymous_functions/code.gleam | 8 +++---
.../lesson05_function_captures/code.gleam | 6 ++---
.../lesson06_generic_functions/code.gleam | 6 ++---
.../lesson07_pipelines/code.gleam | 6 ++---
.../lesson08_labelled_arguments/code.gleam | 8 +++---
.../lesson01_case_expressions/code.gleam | 5 ++--
.../lesson02_variable_patterns/code.gleam | 3 +--
.../lesson03_string_patterns/code.gleam | 8 +++---
.../lesson04_list_patterns/code.gleam | 5 ++--
.../lesson05_recursion/code.gleam | 6 ++---
.../lesson06_tail_calls/code.gleam | 6 ++---
.../lesson07_list_recursion/code.gleam | 4 +--
.../lesson08_multiple_subjects/code.gleam | 7 +++--
.../lesson09_alternative_patterns/code.gleam | 5 ++--
.../lesson10_pattern_aliases/code.gleam | 8 +++---
.../lesson11_guards/code.gleam | 4 +--
.../lesson00_tuples/code.gleam | 8 +++---
.../lesson01_custom_types/code.gleam | 6 ++---
.../lesson02_records/code.gleam | 4 +--
.../lesson03_record_accessors/code.gleam | 8 +++---
.../code.gleam | 2 +-
.../lesson05_record_updates/code.gleam | 6 ++---
.../lesson07_nil/code.gleam | 4 +--
.../lesson08_results/code.gleam | 9 +++----
.../lesson09_bit_arrays/code.gleam | 12 ++++-----
.../lesson01_list_module/code.gleam | 10 +++----
.../lesson02_result_module/code.gleam | 16 +++++------
.../lesson03_dict_module/code.gleam | 5 ++--
.../lesson04_option_module/code.gleam | 5 ++--
.../lesson00_opaque_types/code.gleam | 8 +++---
.../lesson01_use/code.gleam | 5 ++--
.../lesson05_let_assert/code.gleam | 6 ++---
.../lesson06_externals/code.gleam | 4 +--
.../code.gleam | 4 +--
.../code.gleam | 6 ++---
48 files changed, 152 insertions(+), 220 deletions(-)
diff --git a/src/content/chapter0_basics/lesson05_ints/code.gleam b/src/content/chapter0_basics/lesson05_ints/code.gleam
index 120b342..708a444 100644
--- a/src/content/chapter0_basics/lesson05_ints/code.gleam
+++ b/src/content/chapter0_basics/lesson05_ints/code.gleam
@@ -1,25 +1,24 @@
import gleam/int
-import gleam/io
pub fn main() {
// Int arithmetic
- io.debug(1 + 1)
- io.debug(5 - 1)
- io.debug(5 / 2)
- io.debug(3 * 3)
- io.debug(5 % 2)
+ echo { 1 + 1 }
+ echo { 5 - 1 }
+ echo { 5 / 2 }
+ echo { 3 * 3 }
+ echo { 5 % 2 }
// Int comparisons
- io.debug(2 > 1)
- io.debug(2 < 1)
- io.debug(2 >= 1)
- io.debug(2 <= 1)
+ echo { 2 > 1 }
+ echo { 2 < 1 }
+ echo { 2 >= 1 }
+ echo { 2 <= 1 }
// Equality works for any type
- io.debug(1 == 1)
- io.debug(2 == 1)
+ echo { 1 == 1 }
+ echo { 2 == 1 }
// Standard library int functions
- io.debug(int.max(42, 77))
- io.debug(int.clamp(5, 10, 20))
+ echo int.max(42, 77)
+ echo int.clamp(5, 10, 20)
}
diff --git a/src/content/chapter0_basics/lesson06_floats/code.gleam b/src/content/chapter0_basics/lesson06_floats/code.gleam
index b56eb3a..1a65b6a 100644
--- a/src/content/chapter0_basics/lesson06_floats/code.gleam
+++ b/src/content/chapter0_basics/lesson06_floats/code.gleam
@@ -1,27 +1,26 @@
import gleam/float
-import gleam/io
pub fn main() {
// Float arithmetic
- io.debug(1.0 +. 1.5)
- io.debug(5.0 -. 1.5)
- io.debug(5.0 /. 2.5)
- io.debug(3.0 *. 3.5)
+ echo { 1.0 +. 1.5 }
+ echo { 5.0 -. 1.5 }
+ echo { 5.0 /. 2.5 }
+ echo { 3.0 *. 3.5 }
// Float comparisons
- io.debug(2.2 >. 1.3)
- io.debug(2.2 <. 1.3)
- io.debug(2.2 >=. 1.3)
- io.debug(2.2 <=. 1.3)
+ echo { 2.2 >. 1.3 }
+ echo { 2.2 <. 1.3 }
+ echo { 2.2 >=. 1.3 }
+ echo { 2.2 <=. 1.3 }
// Equality works for any type
- io.debug(1.1 == 1.1)
- io.debug(2.1 == 1.2)
+ echo { 1.1 == 1.1 }
+ echo { 2.1 == 1.2 }
// Division by zero is not an error
- io.debug(3.14 /. 0.0)
+ echo { 3.14 /. 0.0 }
// Standard library float functions
- io.debug(float.max(2.0, 9.5))
- io.debug(float.ceiling(5.4))
+ echo float.max(2.0, 9.5)
+ echo float.ceiling(5.4)
}
diff --git a/src/content/chapter0_basics/lesson07_number_formats/code.gleam b/src/content/chapter0_basics/lesson07_number_formats/code.gleam
index 7307185..4d2939e 100644
--- a/src/content/chapter0_basics/lesson07_number_formats/code.gleam
+++ b/src/content/chapter0_basics/lesson07_number_formats/code.gleam
@@ -1,16 +1,14 @@
-import gleam/io
-
pub fn main() {
// Underscores
- io.debug(1_000_000)
- io.debug(10_000.01)
+ echo 1_000_000
+ echo 10_000.01
// Binary, octal, and hex Int literals
- io.debug(0b00001111)
- io.debug(0o17)
- io.debug(0xF)
+ echo 0b00001111
+ echo 0o17
+ echo 0xF
// Scientific notation Float literals
- io.debug(7.0e7)
- io.debug(3.0e-4)
+ echo 7.0e7
+ echo 3.0e-4
}
diff --git a/src/content/chapter0_basics/lesson08_equality/code.gleam b/src/content/chapter0_basics/lesson08_equality/code.gleam
index 70a2b89..ae65e81 100644
--- a/src/content/chapter0_basics/lesson08_equality/code.gleam
+++ b/src/content/chapter0_basics/lesson08_equality/code.gleam
@@ -1,6 +1,4 @@
-import gleam/io
-
pub fn main() {
- io.debug(100 == 100)
- io.debug(1.5 != 0.1)
+ echo { 100 == 100 }
+ echo { 1.5 != 0.1 }
}
diff --git a/src/content/chapter0_basics/lesson09_strings/code.gleam b/src/content/chapter0_basics/lesson09_strings/code.gleam
index ea47e0f..96756be 100644
--- a/src/content/chapter0_basics/lesson09_strings/code.gleam
+++ b/src/content/chapter0_basics/lesson09_strings/code.gleam
@@ -3,21 +3,21 @@ import gleam/string
pub fn main() {
// String literals
- io.debug("๐ฉโ๐ป ใใใซใกใฏ Gleam ๐ณ๏ธโ๐")
- io.debug(
+ io.println("๐ฉโ๐ป ใใใซใกใฏ Gleam ๐ณ๏ธโ๐")
+ io.println(
"multi
line
string",
)
- io.debug("\u{1F600}")
+ io.println("\u{1F600}")
// Double quote can be escaped
io.println("\"X\" marks the spot")
// String concatenation
- io.debug("One " <> "Two")
+ io.println("One " <> "Two")
// String functions
- io.debug(string.reverse("1 2 3 4 5"))
- io.debug(string.append("abc", "def"))
+ io.println(string.reverse("1 2 3 4 5"))
+ io.println(string.append("abc", "def"))
}
diff --git a/src/content/chapter0_basics/lesson10_bools/code.gleam b/src/content/chapter0_basics/lesson10_bools/code.gleam
index aa25ba2..e084863 100644
--- a/src/content/chapter0_basics/lesson10_bools/code.gleam
+++ b/src/content/chapter0_basics/lesson10_bools/code.gleam
@@ -1,14 +1,13 @@
import gleam/bool
-import gleam/io
pub fn main() {
// Bool operators
- io.debug(True && False)
- io.debug(True && True)
- io.debug(False || False)
- io.debug(False || True)
+ echo { True && False }
+ echo { True && True }
+ echo { False || False }
+ echo { False || True }
// Bool functions
- io.debug(bool.to_string(True))
- io.debug(bool.to_int(False))
+ echo bool.to_string(True)
+ echo bool.to_int(False)
}
diff --git a/src/content/chapter0_basics/lesson11_assignments/code.gleam b/src/content/chapter0_basics/lesson11_assignments/code.gleam
index a030e43..dfb092b 100644
--- a/src/content/chapter0_basics/lesson11_assignments/code.gleam
+++ b/src/content/chapter0_basics/lesson11_assignments/code.gleam
@@ -2,16 +2,16 @@ import gleam/io
pub fn main() {
let x = "Original"
- io.debug(x)
+ io.println(x)
// Assign `y` to the value of `x`
let y = x
- io.debug(y)
+ io.println(y)
// Assign `x` to a new value
let x = "New"
- io.debug(x)
+ io.println(x)
// The `y` still refers to the original value
- io.debug(y)
+ io.println(y)
}
diff --git a/src/content/chapter0_basics/lesson15_type_aliases/code.gleam b/src/content/chapter0_basics/lesson15_type_aliases/code.gleam
index 6125ffe..5eecedf 100644
--- a/src/content/chapter0_basics/lesson15_type_aliases/code.gleam
+++ b/src/content/chapter0_basics/lesson15_type_aliases/code.gleam
@@ -1,5 +1,3 @@
-import gleam/io
-
pub type UserId =
Int
@@ -8,5 +6,5 @@ pub fn main() {
let two: Int = 2
// UserId and Int are the same type
- io.debug(one == two)
+ echo { one == two }
}
diff --git a/src/content/chapter0_basics/lesson16_blocks/code.gleam b/src/content/chapter0_basics/lesson16_blocks/code.gleam
index 31e4729..0d429df 100644
--- a/src/content/chapter0_basics/lesson16_blocks/code.gleam
+++ b/src/content/chapter0_basics/lesson16_blocks/code.gleam
@@ -1,13 +1,11 @@
-import gleam/io
-
pub fn main() {
let fahrenheit = {
let degrees = 64
degrees
}
- // io.debug(degrees) // <- This will not compile
+ // echo degrees // <- This will not compile
// Changing order of evaluation
let celsius = { fahrenheit - 32 } * 5 / 9
- io.debug(celsius)
+ echo celsius
}
diff --git a/src/content/chapter0_basics/lesson17_lists/code.gleam b/src/content/chapter0_basics/lesson17_lists/code.gleam
index 646ad6e..b6f2f0a 100644
--- a/src/content/chapter0_basics/lesson17_lists/code.gleam
+++ b/src/content/chapter0_basics/lesson17_lists/code.gleam
@@ -1,16 +1,14 @@
-import gleam/io
-
pub fn main() {
let ints = [1, 2, 3]
- io.debug(ints)
+ echo ints
// Immutably prepend
- io.debug([-1, 0, ..ints])
+ echo [-1, 0, ..ints]
// Uncomment this to see the error
- // io.debug(["zero", ..ints])
+ // echo ["zero", ..ints]
// The original lists are unchanged
- io.debug(ints)
+ echo ints
}
diff --git a/src/content/chapter0_basics/lesson18_constants/code.gleam b/src/content/chapter0_basics/lesson18_constants/code.gleam
index aed6fb0..7a43abc 100644
--- a/src/content/chapter0_basics/lesson18_constants/code.gleam
+++ b/src/content/chapter0_basics/lesson18_constants/code.gleam
@@ -1,13 +1,11 @@
-import gleam/io
-
const ints: List(Int) = [1, 2, 3]
const floats = [1.0, 2.0, 3.0]
pub fn main() {
- io.debug(ints)
- io.debug(ints == [1, 2, 3])
+ echo ints
+ echo { ints == [1, 2, 3] }
- io.debug(floats)
- io.debug(floats == [1.0, 2.0, 3.0])
+ echo floats
+ echo { floats == [1.0, 2.0, 3.0] }
}
diff --git a/src/content/chapter1_functions/lesson00_functions/code.gleam b/src/content/chapter1_functions/lesson00_functions/code.gleam
index 220e58d..34e561e 100644
--- a/src/content/chapter1_functions/lesson00_functions/code.gleam
+++ b/src/content/chapter1_functions/lesson00_functions/code.gleam
@@ -1,7 +1,5 @@
-import gleam/io
-
pub fn main() {
- io.debug(double(10))
+ echo double(10)
}
fn double(a: Int) -> Int {
diff --git a/src/content/chapter1_functions/lesson03_higher_order_functions/code.gleam b/src/content/chapter1_functions/lesson03_higher_order_functions/code.gleam
index 43b6ca4..71e7fbf 100644
--- a/src/content/chapter1_functions/lesson03_higher_order_functions/code.gleam
+++ b/src/content/chapter1_functions/lesson03_higher_order_functions/code.gleam
@@ -1,12 +1,10 @@
-import gleam/io
-
pub fn main() {
// Call a function with another function
- io.debug(twice(1, add_one))
+ echo twice(1, add_one)
// Functions can be assigned to variables
let my_function = add_one
- io.debug(my_function(100))
+ echo my_function(100)
}
fn twice(argument: Int, passed_function: fn(Int) -> Int) -> Int {
diff --git a/src/content/chapter1_functions/lesson04_anonymous_functions/code.gleam b/src/content/chapter1_functions/lesson04_anonymous_functions/code.gleam
index df7a6f9..6a2ebb0 100644
--- a/src/content/chapter1_functions/lesson04_anonymous_functions/code.gleam
+++ b/src/content/chapter1_functions/lesson04_anonymous_functions/code.gleam
@@ -1,17 +1,15 @@
-import gleam/io
-
pub fn main() {
// Assign an anonymous function to a variable
let add_one = fn(a) { a + 1 }
- io.debug(twice(1, add_one))
+ echo twice(1, add_one)
// Pass an anonymous function as an argument
- io.debug(twice(1, fn(a) { a * 2 }))
+ echo twice(1, fn(a) { a * 2 })
let secret_number = 42
// This anonymous function always returns 42
let secret = fn() { secret_number }
- io.debug(secret())
+ echo secret()
}
fn twice(argument: Int, my_function: fn(Int) -> Int) -> Int {
diff --git a/src/content/chapter1_functions/lesson05_function_captures/code.gleam b/src/content/chapter1_functions/lesson05_function_captures/code.gleam
index 35f3412..0fd90fc 100644
--- a/src/content/chapter1_functions/lesson05_function_captures/code.gleam
+++ b/src/content/chapter1_functions/lesson05_function_captures/code.gleam
@@ -1,12 +1,10 @@
-import gleam/io
-
pub fn main() {
// These two statements are equivalent
let add_one_v1 = fn(x) { add(1, x) }
let add_one_v2 = add(1, _)
- io.debug(add_one_v1(10))
- io.debug(add_one_v2(10))
+ echo add_one_v1(10)
+ echo add_one_v2(10)
}
fn add(a: Int, b: Int) -> Int {
diff --git a/src/content/chapter1_functions/lesson06_generic_functions/code.gleam b/src/content/chapter1_functions/lesson06_generic_functions/code.gleam
index db53efe..128ae2e 100644
--- a/src/content/chapter1_functions/lesson06_generic_functions/code.gleam
+++ b/src/content/chapter1_functions/lesson06_generic_functions/code.gleam
@@ -1,5 +1,3 @@
-import gleam/io
-
pub fn main() {
let add_one = fn(x) { x + 1 }
let exclaim = fn(x) { x <> "!" }
@@ -8,10 +6,10 @@ pub fn main() {
// twice(10, exclaim)
// Here the type variable is replaced by the type Int
- io.debug(twice(10, add_one))
+ echo twice(10, add_one)
// Here the type variable is replaced by the type String
- io.debug(twice("Hello", exclaim))
+ echo twice("Hello", exclaim)
}
// The name `value` refers to the same type multiple times
diff --git a/src/content/chapter1_functions/lesson07_pipelines/code.gleam b/src/content/chapter1_functions/lesson07_pipelines/code.gleam
index ec9b805..5156cb1 100644
--- a/src/content/chapter1_functions/lesson07_pipelines/code.gleam
+++ b/src/content/chapter1_functions/lesson07_pipelines/code.gleam
@@ -3,17 +3,17 @@ import gleam/string
pub fn main() {
// Without the pipe operator
- io.debug(string.drop_left(string.drop_right("Hello, Joe!", 1), 7))
+ io.println(string.drop_left(string.drop_right("Hello, Joe!", 1), 7))
// With the pipe operator
"Hello, Mike!"
|> string.drop_right(1)
|> string.drop_left(7)
- |> io.debug
+ |> io.println
// Changing order with function capturing
"1"
|> string.append("2")
|> string.append("3", _)
- |> io.debug
+ |> io.println
}
diff --git a/src/content/chapter1_functions/lesson08_labelled_arguments/code.gleam b/src/content/chapter1_functions/lesson08_labelled_arguments/code.gleam
index 25bb8c1..0a23890 100644
--- a/src/content/chapter1_functions/lesson08_labelled_arguments/code.gleam
+++ b/src/content/chapter1_functions/lesson08_labelled_arguments/code.gleam
@@ -1,14 +1,12 @@
-import gleam/io
-
pub fn main() {
// Without using labels
- io.debug(calculate(1, 2, 3))
+ echo calculate(1, 2, 3)
// Using the labels
- io.debug(calculate(1, add: 2, multiply: 3))
+ echo calculate(1, add: 2, multiply: 3)
// Using the labels in a different order
- io.debug(calculate(1, multiply: 3, add: 2))
+ echo calculate(1, multiply: 3, add: 2)
}
fn calculate(value: Int, add addend: Int, multiply multiplier: Int) {
diff --git a/src/content/chapter2_flow_control/lesson01_case_expressions/code.gleam b/src/content/chapter2_flow_control/lesson01_case_expressions/code.gleam
index d198832..f951588 100644
--- a/src/content/chapter2_flow_control/lesson01_case_expressions/code.gleam
+++ b/src/content/chapter2_flow_control/lesson01_case_expressions/code.gleam
@@ -1,9 +1,8 @@
import gleam/int
-import gleam/io
pub fn main() {
let x = int.random(5)
- io.debug(x)
+ echo x
let result = case x {
// Match specific values
@@ -13,5 +12,5 @@ pub fn main() {
// Match any other value
_ -> "Other"
}
- io.debug(result)
+ echo result
}
diff --git a/src/content/chapter2_flow_control/lesson02_variable_patterns/code.gleam b/src/content/chapter2_flow_control/lesson02_variable_patterns/code.gleam
index 5bce937..eb2a5a2 100644
--- a/src/content/chapter2_flow_control/lesson02_variable_patterns/code.gleam
+++ b/src/content/chapter2_flow_control/lesson02_variable_patterns/code.gleam
@@ -1,5 +1,4 @@
import gleam/int
-import gleam/io
pub fn main() {
let result = case int.random(5) {
@@ -10,5 +9,5 @@ pub fn main() {
// Match any other value and assign it to a variable
other -> "It is " <> int.to_string(other)
}
- io.debug(result)
+ echo result
}
diff --git a/src/content/chapter2_flow_control/lesson03_string_patterns/code.gleam b/src/content/chapter2_flow_control/lesson03_string_patterns/code.gleam
index d1441a0..788c04a 100644
--- a/src/content/chapter2_flow_control/lesson03_string_patterns/code.gleam
+++ b/src/content/chapter2_flow_control/lesson03_string_patterns/code.gleam
@@ -1,9 +1,7 @@
-import gleam/io
-
pub fn main() {
- io.debug(get_name("Hello, Joe"))
- io.debug(get_name("Hello, Mike"))
- io.debug(get_name("System still working?"))
+ echo get_name("Hello, Joe")
+ echo get_name("Hello, Mike")
+ echo get_name("System still working?")
}
fn get_name(x: String) -> String {
diff --git a/src/content/chapter2_flow_control/lesson04_list_patterns/code.gleam b/src/content/chapter2_flow_control/lesson04_list_patterns/code.gleam
index 1b71feb..1b8cbd4 100644
--- a/src/content/chapter2_flow_control/lesson04_list_patterns/code.gleam
+++ b/src/content/chapter2_flow_control/lesson04_list_patterns/code.gleam
@@ -1,10 +1,9 @@
import gleam/int
-import gleam/io
import gleam/list
pub fn main() {
let x = list.repeat(int.random(5), times: int.random(3))
- io.debug(x)
+ echo x
let result = case x {
[] -> "Empty list"
@@ -13,5 +12,5 @@ pub fn main() {
[_, _] -> "List of 2 elements"
_ -> "Some other list"
}
- io.debug(result)
+ echo result
}
diff --git a/src/content/chapter2_flow_control/lesson05_recursion/code.gleam b/src/content/chapter2_flow_control/lesson05_recursion/code.gleam
index 10d45ab..f0068b8 100644
--- a/src/content/chapter2_flow_control/lesson05_recursion/code.gleam
+++ b/src/content/chapter2_flow_control/lesson05_recursion/code.gleam
@@ -1,8 +1,6 @@
-import gleam/io
-
pub fn main() {
- io.debug(factorial(5))
- io.debug(factorial(7))
+ echo factorial(5)
+ echo factorial(7)
}
// A recursive functions that calculates factorial
diff --git a/src/content/chapter2_flow_control/lesson06_tail_calls/code.gleam b/src/content/chapter2_flow_control/lesson06_tail_calls/code.gleam
index b0a416c..6a005bc 100644
--- a/src/content/chapter2_flow_control/lesson06_tail_calls/code.gleam
+++ b/src/content/chapter2_flow_control/lesson06_tail_calls/code.gleam
@@ -1,8 +1,6 @@
-import gleam/io
-
pub fn main() {
- io.debug(factorial(5))
- io.debug(factorial(7))
+ echo factorial(5)
+ echo factorial(7)
}
pub fn factorial(x: Int) -> Int {
diff --git a/src/content/chapter2_flow_control/lesson07_list_recursion/code.gleam b/src/content/chapter2_flow_control/lesson07_list_recursion/code.gleam
index 370675a..d0561f0 100644
--- a/src/content/chapter2_flow_control/lesson07_list_recursion/code.gleam
+++ b/src/content/chapter2_flow_control/lesson07_list_recursion/code.gleam
@@ -1,8 +1,6 @@
-import gleam/io
-
pub fn main() {
let sum = sum_list([18, 56, 35, 85, 91], 0)
- io.debug(sum)
+ echo sum
}
fn sum_list(list: List(Int), total: Int) -> Int {
diff --git a/src/content/chapter2_flow_control/lesson08_multiple_subjects/code.gleam b/src/content/chapter2_flow_control/lesson08_multiple_subjects/code.gleam
index 38885b6..fd41ba1 100644
--- a/src/content/chapter2_flow_control/lesson08_multiple_subjects/code.gleam
+++ b/src/content/chapter2_flow_control/lesson08_multiple_subjects/code.gleam
@@ -1,11 +1,10 @@
import gleam/int
-import gleam/io
pub fn main() {
let x = int.random(2)
let y = int.random(2)
- io.debug(x)
- io.debug(y)
+ echo x
+ echo y
let result = case x, y {
0, 0 -> "Both are zero"
@@ -13,5 +12,5 @@ pub fn main() {
_, 0 -> "Second is zero"
_, _ -> "Neither are zero"
}
- io.debug(result)
+ echo result
}
diff --git a/src/content/chapter2_flow_control/lesson09_alternative_patterns/code.gleam b/src/content/chapter2_flow_control/lesson09_alternative_patterns/code.gleam
index e916a03..8545530 100644
--- a/src/content/chapter2_flow_control/lesson09_alternative_patterns/code.gleam
+++ b/src/content/chapter2_flow_control/lesson09_alternative_patterns/code.gleam
@@ -1,14 +1,13 @@
import gleam/int
-import gleam/io
pub fn main() {
let number = int.random(10)
- io.debug(number)
+ echo number
let result = case number {
2 | 4 | 6 | 8 -> "This is an even number"
1 | 3 | 5 | 7 -> "This is an odd number"
_ -> "I'm not sure"
}
- io.debug(result)
+ echo result
}
diff --git a/src/content/chapter2_flow_control/lesson10_pattern_aliases/code.gleam b/src/content/chapter2_flow_control/lesson10_pattern_aliases/code.gleam
index ee40a26..134db5b 100644
--- a/src/content/chapter2_flow_control/lesson10_pattern_aliases/code.gleam
+++ b/src/content/chapter2_flow_control/lesson10_pattern_aliases/code.gleam
@@ -1,9 +1,7 @@
-import gleam/io
-
pub fn main() {
- io.debug(get_first_non_empty([[], [1, 2, 3], [4, 5]]))
- io.debug(get_first_non_empty([[1, 2], [3, 4, 5], []]))
- io.debug(get_first_non_empty([[], [], []]))
+ echo get_first_non_empty([[], [1, 2, 3], [4, 5]])
+ echo get_first_non_empty([[1, 2], [3, 4, 5], []])
+ echo get_first_non_empty([[], [], []])
}
fn get_first_non_empty(lists: List(List(t))) -> List(t) {
diff --git a/src/content/chapter2_flow_control/lesson11_guards/code.gleam b/src/content/chapter2_flow_control/lesson11_guards/code.gleam
index e655aef..86a6854 100644
--- a/src/content/chapter2_flow_control/lesson11_guards/code.gleam
+++ b/src/content/chapter2_flow_control/lesson11_guards/code.gleam
@@ -2,8 +2,8 @@ import gleam/io
pub fn main() {
let numbers = [1, 2, 3, 4, 5]
- io.debug(get_first_larger(numbers, 3))
- io.debug(get_first_larger(numbers, 5))
+ echo get_first_larger(numbers, 3)
+ echo get_first_larger(numbers, 5)
}
fn get_first_larger(numbers: List(Int), limit: Int) -> Int {
diff --git a/src/content/chapter3_data_types/lesson00_tuples/code.gleam b/src/content/chapter3_data_types/lesson00_tuples/code.gleam
index d5c6313..dab4513 100644
--- a/src/content/chapter3_data_types/lesson00_tuples/code.gleam
+++ b/src/content/chapter3_data_types/lesson00_tuples/code.gleam
@@ -1,10 +1,8 @@
-import gleam/io
-
pub fn main() {
let triple = #(1, 2.2, "three")
- io.debug(triple)
+ echo triple
let #(a, _, _) = triple
- io.debug(a)
- io.debug(triple.1)
+ echo a
+ echo triple.1
}
diff --git a/src/content/chapter3_data_types/lesson01_custom_types/code.gleam b/src/content/chapter3_data_types/lesson01_custom_types/code.gleam
index 35629bf..91fb60b 100644
--- a/src/content/chapter3_data_types/lesson01_custom_types/code.gleam
+++ b/src/content/chapter3_data_types/lesson01_custom_types/code.gleam
@@ -1,5 +1,3 @@
-import gleam/io
-
pub type Season {
Spring
Summer
@@ -8,8 +6,8 @@ pub type Season {
}
pub fn main() {
- io.debug(weather(Spring))
- io.debug(weather(Autumn))
+ echo weather(Spring)
+ echo weather(Autumn)
}
fn weather(season: Season) -> String {
diff --git a/src/content/chapter3_data_types/lesson02_records/code.gleam b/src/content/chapter3_data_types/lesson02_records/code.gleam
index bd6da3c..64ed7be 100644
--- a/src/content/chapter3_data_types/lesson02_records/code.gleam
+++ b/src/content/chapter3_data_types/lesson02_records/code.gleam
@@ -1,5 +1,3 @@
-import gleam/io
-
pub type SchoolPerson {
Teacher(name: String, subject: String)
Student(String)
@@ -13,5 +11,5 @@ pub fn main() {
let student3 = Student("Shaheer")
let school = [teacher1, teacher2, student1, student2, student3]
- io.debug(school)
+ echo school
}
diff --git a/src/content/chapter3_data_types/lesson03_record_accessors/code.gleam b/src/content/chapter3_data_types/lesson03_record_accessors/code.gleam
index 13d6d16..bb9d847 100644
--- a/src/content/chapter3_data_types/lesson03_record_accessors/code.gleam
+++ b/src/content/chapter3_data_types/lesson03_record_accessors/code.gleam
@@ -1,5 +1,3 @@
-import gleam/io
-
pub type SchoolPerson {
Teacher(name: String, subject: String)
Student(name: String)
@@ -9,7 +7,7 @@ pub fn main() {
let teacher = Teacher("Mr Schofield", "Physics")
let student = Student("Koushiar")
- io.debug(teacher.name)
- io.debug(student.name)
- // io.debug(student.subject)
+ echo teacher.name
+ echo student.name
+ // echo teacher.subject
}
diff --git a/src/content/chapter3_data_types/lesson04_record_pattern_matching/code.gleam b/src/content/chapter3_data_types/lesson04_record_pattern_matching/code.gleam
index 6852d04..68bc7ef 100644
--- a/src/content/chapter3_data_types/lesson04_record_pattern_matching/code.gleam
+++ b/src/content/chapter3_data_types/lesson04_record_pattern_matching/code.gleam
@@ -25,5 +25,5 @@ fn handle_ice_cream(ice_cream: IceCream) {
// if the custom type has a single variant you can
// destructure it using `let` instead of a case expression!
let IceCream(flavour) = ice_cream
- io.debug(flavour)
+ echo flavour
}
diff --git a/src/content/chapter3_data_types/lesson05_record_updates/code.gleam b/src/content/chapter3_data_types/lesson05_record_updates/code.gleam
index ed7b45b..2237723 100644
--- a/src/content/chapter3_data_types/lesson05_record_updates/code.gleam
+++ b/src/content/chapter3_data_types/lesson05_record_updates/code.gleam
@@ -1,5 +1,3 @@
-import gleam/io
-
pub type SchoolPerson {
Teacher(name: String, subject: String, floor: Int, room: Int)
}
@@ -10,6 +8,6 @@ pub fn main() {
// Use the update syntax
let teacher2 = Teacher(..teacher1, subject: "PE", room: 6)
- io.debug(teacher1)
- io.debug(teacher2)
+ echo teacher1
+ echo teacher2
}
diff --git a/src/content/chapter3_data_types/lesson07_nil/code.gleam b/src/content/chapter3_data_types/lesson07_nil/code.gleam
index c28080b..b69d654 100644
--- a/src/content/chapter3_data_types/lesson07_nil/code.gleam
+++ b/src/content/chapter3_data_types/lesson07_nil/code.gleam
@@ -2,10 +2,10 @@ import gleam/io
pub fn main() {
let x = Nil
- io.debug(x)
+ echo x
// let y: List(String) = Nil
let result = io.println("Hello!")
- io.debug(result == Nil)
+ echo { result == Nil }
}
diff --git a/src/content/chapter3_data_types/lesson08_results/code.gleam b/src/content/chapter3_data_types/lesson08_results/code.gleam
index 67a2559..3938e54 100644
--- a/src/content/chapter3_data_types/lesson08_results/code.gleam
+++ b/src/content/chapter3_data_types/lesson08_results/code.gleam
@@ -1,11 +1,10 @@
import gleam/int
-import gleam/io
pub fn main() {
- let _ = io.debug(buy_pastry(10))
- let _ = io.debug(buy_pastry(8))
- let _ = io.debug(buy_pastry(5))
- let _ = io.debug(buy_pastry(3))
+ let _ = echo buy_pastry(10)
+ let _ = echo buy_pastry(8)
+ let _ = echo buy_pastry(5)
+ let _ = echo buy_pastry(3)
}
pub type PurchaseError {
diff --git a/src/content/chapter3_data_types/lesson09_bit_arrays/code.gleam b/src/content/chapter3_data_types/lesson09_bit_arrays/code.gleam
index 52d7b8c..d437c3c 100644
--- a/src/content/chapter3_data_types/lesson09_bit_arrays/code.gleam
+++ b/src/content/chapter3_data_types/lesson09_bit_arrays/code.gleam
@@ -1,18 +1,16 @@
-import gleam/io
-
pub fn main() {
// 8 bit int. In binary: 00000011
- io.debug(<<3>>)
- io.debug(<<3>> == <<3:size(8)>>)
+ echo <<3>>
+ echo { <<3>> == <<3:size(8)>> }
// 16 bit int. In binary: 0001100000000011
- io.debug(<<6147:size(16)>>)
+ echo <<6147:size(16)>>
// A bit array of UTF8 data
- io.debug(<<"Hello, Joe!":utf8>>)
+ echo <<"Hello, Joe!":utf8>>
// Concatenation
let first = <<4>>
let second = <<2>>
- io.debug(<>)
+ echo <>
}
diff --git a/src/content/chapter4_standard_library/lesson01_list_module/code.gleam b/src/content/chapter4_standard_library/lesson01_list_module/code.gleam
index ab08ab1..ac90487 100644
--- a/src/content/chapter4_standard_library/lesson01_list_module/code.gleam
+++ b/src/content/chapter4_standard_library/lesson01_list_module/code.gleam
@@ -5,15 +5,15 @@ pub fn main() {
let ints = [0, 1, 2, 3, 4, 5]
io.println("=== map ===")
- io.debug(list.map(ints, fn(x) { x * 2 }))
+ echo list.map(ints, fn(x) { x * 2 })
io.println("=== filter ===")
- io.debug(list.filter(ints, fn(x) { x % 2 == 0 }))
+ echo list.filter(ints, fn(x) { x % 2 == 0 })
io.println("=== fold ===")
- io.debug(list.fold(ints, 0, fn(count, e) { count + e }))
+ echo list.fold(ints, 0, fn(count, e) { count + e })
io.println("=== find ===")
- let _ = io.debug(list.find(ints, fn(x) { x > 3 }))
- io.debug(list.find(ints, fn(x) { x > 13 }))
+ let _ = echo list.find(ints, fn(x) { x > 3 })
+ echo list.find(ints, fn(x) { x > 13 })
}
diff --git a/src/content/chapter4_standard_library/lesson02_result_module/code.gleam b/src/content/chapter4_standard_library/lesson02_result_module/code.gleam
index 423938a..083a7ff 100644
--- a/src/content/chapter4_standard_library/lesson02_result_module/code.gleam
+++ b/src/content/chapter4_standard_library/lesson02_result_module/code.gleam
@@ -4,21 +4,21 @@ import gleam/result
pub fn main() {
io.println("=== map ===")
- let _ = io.debug(result.map(Ok(1), fn(x) { x * 2 }))
- let _ = io.debug(result.map(Error(1), fn(x) { x * 2 }))
+ let _ = echo result.map(Ok(1), fn(x) { x * 2 })
+ let _ = echo result.map(Error(1), fn(x) { x * 2 })
io.println("=== try ===")
- let _ = io.debug(result.try(Ok("1"), int.parse))
- let _ = io.debug(result.try(Ok("no"), int.parse))
- let _ = io.debug(result.try(Error(Nil), int.parse))
+ let _ = echo result.try(Ok("1"), int.parse)
+ let _ = echo result.try(Ok("no"), int.parse)
+ let _ = echo result.try(Error(Nil), int.parse)
io.println("=== unwrap ===")
- io.debug(result.unwrap(Ok("1234"), "default"))
- io.debug(result.unwrap(Error(Nil), "default"))
+ echo result.unwrap(Ok("1234"), "default")
+ echo result.unwrap(Error(Nil), "default")
io.println("=== pipeline ===")
int.parse("-1234")
|> result.map(int.absolute_value)
|> result.try(int.remainder(_, 42))
- |> io.debug
+ |> echo
}
diff --git a/src/content/chapter4_standard_library/lesson03_dict_module/code.gleam b/src/content/chapter4_standard_library/lesson03_dict_module/code.gleam
index e7b3a59..ef4f775 100644
--- a/src/content/chapter4_standard_library/lesson03_dict_module/code.gleam
+++ b/src/content/chapter4_standard_library/lesson03_dict_module/code.gleam
@@ -1,14 +1,13 @@
import gleam/dict
-import gleam/io
pub fn main() {
let scores = dict.from_list([#("Lucy", 13), #("Drew", 15)])
- io.debug(scores)
+ echo scores
let scores =
scores
|> dict.insert("Bushra", 16)
|> dict.insert("Darius", 14)
|> dict.delete("Drew")
- io.debug(scores)
+ echo scores
}
diff --git a/src/content/chapter4_standard_library/lesson04_option_module/code.gleam b/src/content/chapter4_standard_library/lesson04_option_module/code.gleam
index eb60001..1a19c62 100644
--- a/src/content/chapter4_standard_library/lesson04_option_module/code.gleam
+++ b/src/content/chapter4_standard_library/lesson04_option_module/code.gleam
@@ -1,4 +1,3 @@
-import gleam/io
import gleam/option.{type Option, None, Some}
pub type Person {
@@ -9,6 +8,6 @@ pub fn main() {
let person_with_pet = Person("Al", Some("Nubi"))
let person_without_pet = Person("Maria", None)
- io.debug(person_with_pet)
- io.debug(person_without_pet)
+ echo person_with_pet
+ echo person_without_pet
}
diff --git a/src/content/chapter5_advanced_features/lesson00_opaque_types/code.gleam b/src/content/chapter5_advanced_features/lesson00_opaque_types/code.gleam
index d116b42..df8cda4 100644
--- a/src/content/chapter5_advanced_features/lesson00_opaque_types/code.gleam
+++ b/src/content/chapter5_advanced_features/lesson00_opaque_types/code.gleam
@@ -1,13 +1,11 @@
-import gleam/io
-
pub fn main() {
let positive = new(1)
let zero = new(0)
let negative = new(-1)
- io.debug(to_int(positive))
- io.debug(to_int(zero))
- io.debug(to_int(negative))
+ echo to_int(positive)
+ echo to_int(zero)
+ echo to_int(negative)
}
pub opaque type PositiveInt {
diff --git a/src/content/chapter5_advanced_features/lesson01_use/code.gleam b/src/content/chapter5_advanced_features/lesson01_use/code.gleam
index 110c154..2bb86bd 100644
--- a/src/content/chapter5_advanced_features/lesson01_use/code.gleam
+++ b/src/content/chapter5_advanced_features/lesson01_use/code.gleam
@@ -1,9 +1,8 @@
-import gleam/io
import gleam/result
pub fn main() {
- let _ = io.debug(without_use())
- let _ = io.debug(with_use())
+ let _ = echo without_use()
+ let _ = echo with_use()
}
pub fn without_use() {
diff --git a/src/content/chapter5_advanced_features/lesson05_let_assert/code.gleam b/src/content/chapter5_advanced_features/lesson05_let_assert/code.gleam
index 2ba907a..3ca86da 100644
--- a/src/content/chapter5_advanced_features/lesson05_let_assert/code.gleam
+++ b/src/content/chapter5_advanced_features/lesson05_let_assert/code.gleam
@@ -1,11 +1,9 @@
-import gleam/io
-
pub fn main() {
let a = unsafely_get_first_element([123])
- io.debug(a)
+ echo a
let b = unsafely_get_first_element([])
- io.debug(b)
+ echo b
}
pub fn unsafely_get_first_element(items: List(a)) -> a {
diff --git a/src/content/chapter5_advanced_features/lesson06_externals/code.gleam b/src/content/chapter5_advanced_features/lesson06_externals/code.gleam
index 1101b82..b761ca9 100644
--- a/src/content/chapter5_advanced_features/lesson06_externals/code.gleam
+++ b/src/content/chapter5_advanced_features/lesson06_externals/code.gleam
@@ -1,5 +1,3 @@
-import gleam/io
-
// A type with no Gleam constructors
pub type DateTime
@@ -13,5 +11,5 @@ pub fn now() -> DateTime
// }
pub fn main() {
- io.debug(now())
+ echo now()
}
diff --git a/src/content/chapter5_advanced_features/lesson07_multi_target_externals/code.gleam b/src/content/chapter5_advanced_features/lesson07_multi_target_externals/code.gleam
index b62a735..ae36154 100644
--- a/src/content/chapter5_advanced_features/lesson07_multi_target_externals/code.gleam
+++ b/src/content/chapter5_advanced_features/lesson07_multi_target_externals/code.gleam
@@ -1,5 +1,3 @@
-import gleam/io
-
pub type DateTime
@external(erlang, "calendar", "local_time")
@@ -7,5 +5,5 @@ pub type DateTime
pub fn now() -> DateTime
pub fn main() {
- io.debug(now())
+ echo now()
}
diff --git a/src/content/chapter5_advanced_features/lesson08_external_gleam_fallbacks/code.gleam b/src/content/chapter5_advanced_features/lesson08_external_gleam_fallbacks/code.gleam
index a97b8fc..ee2a86d 100644
--- a/src/content/chapter5_advanced_features/lesson08_external_gleam_fallbacks/code.gleam
+++ b/src/content/chapter5_advanced_features/lesson08_external_gleam_fallbacks/code.gleam
@@ -1,5 +1,3 @@
-import gleam/io
-
@external(erlang, "lists", "reverse")
pub fn reverse_list(items: List(e)) -> List(e) {
tail_recursive_reverse(items, [])
@@ -13,6 +11,6 @@ fn tail_recursive_reverse(items: List(e), reversed: List(e)) -> List(e) {
}
pub fn main() {
- io.debug(reverse_list([1, 2, 3, 4, 5]))
- io.debug(reverse_list(["a", "b", "c", "d", "e"]))
+ echo reverse_list([1, 2, 3, 4, 5])
+ echo reverse_list(["a", "b", "c", "d", "e"])
}
From 9fa6d02fc69e6b311ca1e6c0def1e0efa681a382 Mon Sep 17 00:00:00 2001
From: Giacomo Cavalieri
Date: Mon, 21 Oct 2024 16:35:04 +0200
Subject: [PATCH 2/4] add echo
---
.../chapter0_basics/lesson04_type_checking/code.gleam | 5 ++++-
src/content/chapter0_basics/lesson04_type_checking/en.html | 7 ++-----
src/content/chapter0_basics/lesson16_blocks/en.html | 7 ++-----
.../chapter1_functions/lesson07_pipelines/code.gleam | 2 ++
src/content/chapter1_functions/lesson07_pipelines/en.html | 4 ++++
.../lesson04_record_pattern_matching/code.gleam | 6 +++---
src/tour.gleam | 7 ++-----
7 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/src/content/chapter0_basics/lesson04_type_checking/code.gleam b/src/content/chapter0_basics/lesson04_type_checking/code.gleam
index e068f31..a724a6c 100644
--- a/src/content/chapter0_basics/lesson04_type_checking/code.gleam
+++ b/src/content/chapter0_basics/lesson04_type_checking/code.gleam
@@ -3,5 +3,8 @@ import gleam/io
pub fn main() {
io.println("My lucky number is:")
// io.println(4)
- // ๐๏ธ Uncomment this line
+ // ๐๏ธ Uncomment this line to see the error
+
+ // echo 4
+ // ๐๏ธ You can use `echo` to debug print a value of any type!
}
diff --git a/src/content/chapter0_basics/lesson04_type_checking/en.html b/src/content/chapter0_basics/lesson04_type_checking/en.html
index 0cffcbe..d23408f 100644
--- a/src/content/chapter0_basics/lesson04_type_checking/en.html
+++ b/src/content/chapter0_basics/lesson04_type_checking/en.html
@@ -15,11 +15,8 @@
function only works with strings, not ints.
- To fix the code change the code to call the
-
- io.debug
-
- function instead, as it will print a value of any type.
+ If you need to debug print something you can use the echo
+ keyword instead, as it will print a value of any type.
Gleam has no null
, no implicit conversions, no exceptions, and
diff --git a/src/content/chapter0_basics/lesson16_blocks/en.html b/src/content/chapter0_basics/lesson16_blocks/en.html
index b19c586..1541bb2 100644
--- a/src/content/chapter0_basics/lesson16_blocks/en.html
+++ b/src/content/chapter0_basics/lesson16_blocks/en.html
@@ -7,11 +7,8 @@
Any variables assigned within the block can only be used within the block.
- Try uncommenting
-
- io.debug(degrees)
-
- to see the compile error from trying to use a variable that is not in scope.
+ Try uncommenting echo degrees
to see the compile error from
+ trying to use a variable that is not in scope.
Blocks can also be used to change the order of evaluation of binary operators
diff --git a/src/content/chapter1_functions/lesson07_pipelines/code.gleam b/src/content/chapter1_functions/lesson07_pipelines/code.gleam
index 5156cb1..07ae4ef 100644
--- a/src/content/chapter1_functions/lesson07_pipelines/code.gleam
+++ b/src/content/chapter1_functions/lesson07_pipelines/code.gleam
@@ -8,12 +8,14 @@ pub fn main() {
// With the pipe operator
"Hello, Mike!"
|> string.drop_right(1)
+ |> echo
|> string.drop_left(7)
|> io.println
// Changing order with function capturing
"1"
|> string.append("2")
+ |> echo
|> string.append("3", _)
|> io.println
}
diff --git a/src/content/chapter1_functions/lesson07_pipelines/en.html b/src/content/chapter1_functions/lesson07_pipelines/en.html
index 783ade9..927f9a8 100644
--- a/src/content/chapter1_functions/lesson07_pipelines/en.html
+++ b/src/content/chapter1_functions/lesson07_pipelines/en.html
@@ -23,3 +23,7 @@
position then a function capture can be used to insert the argument to the
desired position.
+
+ If you need to debug print a value in the middle of a pipeline you can use
+ |> echo
to do it.
+
diff --git a/src/content/chapter3_data_types/lesson04_record_pattern_matching/code.gleam b/src/content/chapter3_data_types/lesson04_record_pattern_matching/code.gleam
index 68bc7ef..1870d75 100644
--- a/src/content/chapter3_data_types/lesson04_record_pattern_matching/code.gleam
+++ b/src/content/chapter3_data_types/lesson04_record_pattern_matching/code.gleam
@@ -16,8 +16,8 @@ pub fn main() {
fn handle_fish(fish: Fish) {
case fish {
- Starfish(_, favourite_color) -> io.debug(favourite_color)
- Jellyfish(name, ..) -> io.debug(name)
+ Starfish(_, favourite_color) -> io.println(favourite_color)
+ Jellyfish(name, ..) -> io.println(name)
}
}
@@ -25,5 +25,5 @@ fn handle_ice_cream(ice_cream: IceCream) {
// if the custom type has a single variant you can
// destructure it using `let` instead of a case expression!
let IceCream(flavour) = ice_cream
- echo flavour
+ io.println(flavour)
}
diff --git a/src/tour.gleam b/src/tour.gleam
index 57461cf..bd5ff6c 100644
--- a/src/tour.gleam
+++ b/src/tour.gleam
@@ -60,11 +60,8 @@ const home_html = "
io.println
- or
-
- io.debug
-
- will be shown in the bottom section, along with any compile errors and warnings.
+ or echo
will be shown in the bottom section, along with any compile
+ errors and warnings.
To evaluate Gleam code the tour compiles Gleam to JavaScript and runs it,
all entirely within your browser window.
From 62b2777f95b079f4bb9dfd1dfaefb43dfeeadeae Mon Sep 17 00:00:00 2001
From: Giacomo Cavalieri
Date: Thu, 21 Nov 2024 11:39:24 +0100
Subject: [PATCH 3/4] fix examples with new echo precedence
---
.../chapter0_basics/lesson05_ints/code.gleam | 22 +++++++++----------
.../lesson06_floats/code.gleam | 22 +++++++++----------
.../lesson08_equality/code.gleam | 4 ++--
.../chapter0_basics/lesson10_bools/code.gleam | 8 +++----
.../lesson15_type_aliases/code.gleam | 2 +-
.../lesson18_constants/code.gleam | 4 ++--
.../lesson07_nil/code.gleam | 2 +-
.../lesson09_bit_arrays/code.gleam | 2 +-
8 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/src/content/chapter0_basics/lesson05_ints/code.gleam b/src/content/chapter0_basics/lesson05_ints/code.gleam
index 708a444..4a9f94a 100644
--- a/src/content/chapter0_basics/lesson05_ints/code.gleam
+++ b/src/content/chapter0_basics/lesson05_ints/code.gleam
@@ -2,21 +2,21 @@ import gleam/int
pub fn main() {
// Int arithmetic
- echo { 1 + 1 }
- echo { 5 - 1 }
- echo { 5 / 2 }
- echo { 3 * 3 }
- echo { 5 % 2 }
+ echo 1 + 1
+ echo 5 - 1
+ echo 5 / 2
+ echo 3 * 3
+ echo 5 % 2
// Int comparisons
- echo { 2 > 1 }
- echo { 2 < 1 }
- echo { 2 >= 1 }
- echo { 2 <= 1 }
+ echo 2 > 1
+ echo 2 < 1
+ echo 2 >= 1
+ echo 2 <= 1
// Equality works for any type
- echo { 1 == 1 }
- echo { 2 == 1 }
+ echo 1 == 1
+ echo 2 == 1
// Standard library int functions
echo int.max(42, 77)
diff --git a/src/content/chapter0_basics/lesson06_floats/code.gleam b/src/content/chapter0_basics/lesson06_floats/code.gleam
index 1a65b6a..d94d1b8 100644
--- a/src/content/chapter0_basics/lesson06_floats/code.gleam
+++ b/src/content/chapter0_basics/lesson06_floats/code.gleam
@@ -2,23 +2,23 @@ import gleam/float
pub fn main() {
// Float arithmetic
- echo { 1.0 +. 1.5 }
- echo { 5.0 -. 1.5 }
- echo { 5.0 /. 2.5 }
- echo { 3.0 *. 3.5 }
+ echo 1.0 +. 1.5
+ echo 5.0 -. 1.5
+ echo 5.0 /. 2.5
+ echo 3.0 *. 3.5
// Float comparisons
- echo { 2.2 >. 1.3 }
- echo { 2.2 <. 1.3 }
- echo { 2.2 >=. 1.3 }
- echo { 2.2 <=. 1.3 }
+ echo 2.2 >. 1.3
+ echo 2.2 <. 1.3
+ echo 2.2 >=. 1.3
+ echo 2.2 <=. 1.3
// Equality works for any type
- echo { 1.1 == 1.1 }
- echo { 2.1 == 1.2 }
+ echo 1.1 == 1.1
+ echo 2.1 == 1.2
// Division by zero is not an error
- echo { 3.14 /. 0.0 }
+ echo 3.14 /. 0.0
// Standard library float functions
echo float.max(2.0, 9.5)
diff --git a/src/content/chapter0_basics/lesson08_equality/code.gleam b/src/content/chapter0_basics/lesson08_equality/code.gleam
index ae65e81..547b999 100644
--- a/src/content/chapter0_basics/lesson08_equality/code.gleam
+++ b/src/content/chapter0_basics/lesson08_equality/code.gleam
@@ -1,4 +1,4 @@
pub fn main() {
- echo { 100 == 100 }
- echo { 1.5 != 0.1 }
+ echo 100 == 100
+ echo 1.5 != 0.1
}
diff --git a/src/content/chapter0_basics/lesson10_bools/code.gleam b/src/content/chapter0_basics/lesson10_bools/code.gleam
index e084863..891c337 100644
--- a/src/content/chapter0_basics/lesson10_bools/code.gleam
+++ b/src/content/chapter0_basics/lesson10_bools/code.gleam
@@ -2,10 +2,10 @@ import gleam/bool
pub fn main() {
// Bool operators
- echo { True && False }
- echo { True && True }
- echo { False || False }
- echo { False || True }
+ echo True && False
+ echo True && True
+ echo False || False
+ echo False || True
// Bool functions
echo bool.to_string(True)
diff --git a/src/content/chapter0_basics/lesson15_type_aliases/code.gleam b/src/content/chapter0_basics/lesson15_type_aliases/code.gleam
index 5eecedf..cc3dd31 100644
--- a/src/content/chapter0_basics/lesson15_type_aliases/code.gleam
+++ b/src/content/chapter0_basics/lesson15_type_aliases/code.gleam
@@ -6,5 +6,5 @@ pub fn main() {
let two: Int = 2
// UserId and Int are the same type
- echo { one == two }
+ echo one == two
}
diff --git a/src/content/chapter0_basics/lesson18_constants/code.gleam b/src/content/chapter0_basics/lesson18_constants/code.gleam
index 7a43abc..3676904 100644
--- a/src/content/chapter0_basics/lesson18_constants/code.gleam
+++ b/src/content/chapter0_basics/lesson18_constants/code.gleam
@@ -4,8 +4,8 @@ const floats = [1.0, 2.0, 3.0]
pub fn main() {
echo ints
- echo { ints == [1, 2, 3] }
+ echo ints == [1, 2, 3]
echo floats
- echo { floats == [1.0, 2.0, 3.0] }
+ echo floats == [1.0, 2.0, 3.0]
}
diff --git a/src/content/chapter3_data_types/lesson07_nil/code.gleam b/src/content/chapter3_data_types/lesson07_nil/code.gleam
index b69d654..a11f58a 100644
--- a/src/content/chapter3_data_types/lesson07_nil/code.gleam
+++ b/src/content/chapter3_data_types/lesson07_nil/code.gleam
@@ -7,5 +7,5 @@ pub fn main() {
// let y: List(String) = Nil
let result = io.println("Hello!")
- echo { result == Nil }
+ echo result == Nil
}
diff --git a/src/content/chapter3_data_types/lesson09_bit_arrays/code.gleam b/src/content/chapter3_data_types/lesson09_bit_arrays/code.gleam
index d437c3c..c62d9bf 100644
--- a/src/content/chapter3_data_types/lesson09_bit_arrays/code.gleam
+++ b/src/content/chapter3_data_types/lesson09_bit_arrays/code.gleam
@@ -1,7 +1,7 @@
pub fn main() {
// 8 bit int. In binary: 00000011
echo <<3>>
- echo { <<3>> == <<3:size(8)>> }
+ echo <<3>> == <<3:size(8)>>
// 16 bit int. In binary: 0001100000000011
echo <<6147:size(16)>>
From da1b719f601c2f4c40331b2cd721958981f350d2 Mon Sep 17 00:00:00 2001
From: Giacomo Cavalieri
Date: Thu, 21 Nov 2024 11:40:26 +0100
Subject: [PATCH 4/4] update gleam version
---
.github/workflows/test.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index c0575e4..8b414f3 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -16,7 +16,7 @@ jobs:
with:
otp-version: false
# Ensure you update the bin/download-compiler Gleam version to match this
- gleam-version: "1.6.0"
+ gleam-version: "1.7.0"
- run: ./bin/download-compiler
- run: gleam deps download
- run: gleam format --check src test