From f70130322cd306268c5da12c1517dc5725615ae8 Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Thu, 15 Feb 2024 12:18:17 +0000 Subject: text -> en --- .../chapter0_basics/lesson01_hello_world/en.html | 18 ++++++++++ .../chapter0_basics/lesson01_hello_world/text.html | 18 ---------- .../lesson02_unqualified_imports/en.html | 15 ++++++++ .../lesson02_unqualified_imports/text.html | 15 -------- .../chapter0_basics/lesson03_type_checking/en.html | 18 ++++++++++ .../lesson03_type_checking/text.html | 18 ---------- src/content/chapter0_basics/lesson04_ints/en.html | 17 +++++++++ .../chapter0_basics/lesson04_ints/text.html | 17 --------- .../chapter0_basics/lesson05_floats/en.html | 32 +++++++++++++++++ .../chapter0_basics/lesson05_floats/text.html | 32 ----------------- .../lesson06_number_formats/en.html | 13 +++++++ .../lesson06_number_formats/text.html | 13 ------- .../chapter0_basics/lesson07_equality/en.html | 13 +++++++ .../chapter0_basics/lesson07_equality/text.html | 13 ------- .../chapter0_basics/lesson08_strings/en.html | 23 ++++++++++++ .../chapter0_basics/lesson08_strings/text.html | 23 ------------ src/content/chapter0_basics/lesson09_bools/en.html | 17 +++++++++ .../chapter0_basics/lesson09_bools/text.html | 17 --------- .../chapter0_basics/lesson10_assignments/en.html | 8 +++++ .../chapter0_basics/lesson10_assignments/text.html | 8 ----- .../lesson11_discard_patterns/en.html | 10 ++++++ .../lesson11_discard_patterns/text.html | 10 ------ .../lesson12_type_annotations/en.html | 15 ++++++++ .../lesson12_type_annotations/text.html | 15 -------- .../chapter0_basics/lesson13_type_aliases/en.html | 8 +++++ .../lesson13_type_aliases/text.html | 8 ----- .../chapter0_basics/lesson14_blocks/en.html | 23 ++++++++++++ .../chapter0_basics/lesson14_blocks/text.html | 23 ------------ src/content/chapter0_basics/lesson15_lists/en.html | 19 ++++++++++ .../chapter0_basics/lesson15_lists/text.html | 19 ---------- .../chapter0_basics/lesson16_constants/en.html | 18 ++++++++++ .../chapter0_basics/lesson16_constants/text.html | 18 ---------- .../chapter1_functions/lesson00_functions/en.html | 14 ++++++++ .../lesson00_functions/text.html | 14 -------- .../lesson03_higher_order_functions/en.html | 12 +++++++ .../lesson03_higher_order_functions/text.html | 12 ------- .../lesson04_anonymous_functions/en.html | 5 +++ .../lesson04_anonymous_functions/text.html | 5 --- .../lesson05_function_captures/en.html | 11 ++++++ .../lesson05_function_captures/text.html | 11 ------ .../lesson06_generic_functions/en.html | 25 +++++++++++++ .../lesson06_generic_functions/text.html | 25 ------------- .../chapter1_functions/lesson07_pipelines/en.html | 25 +++++++++++++ .../lesson07_pipelines/text.html | 25 ------------- .../lesson08_labelled_arguments/en.html | 23 ++++++++++++ .../lesson08_labelled_arguments/text.html | 23 ------------ .../lesson09_documentation_comments/en.html | 16 +++++++++ .../lesson09_documentation_comments/text.html | 16 --------- .../lesson10_deprecations/en.html | 14 ++++++++ .../lesson10_deprecations/text.html | 14 -------- .../lesson01_case_expressions/en.html | 18 ++++++++++ .../lesson01_case_expressions/text.html | 18 ---------- .../lesson02_variable_patterns/en.html | 7 ++++ .../lesson02_variable_patterns/text.html | 7 ---- .../lesson03_string_patterns/en.html | 9 +++++ .../lesson03_string_patterns/text.html | 9 ----- .../lesson04_list_patterns/en.html | 15 ++++++++ .../lesson04_list_patterns/text.html | 15 -------- .../lesson05_recursion/en.html | 20 +++++++++++ .../lesson05_recursion/text.html | 20 ----------- .../lesson06_tail_calls/en.html | 23 ++++++++++++ .../lesson06_tail_calls/text.html | 23 ------------ .../lesson07_list_recursion/en.html | 19 ++++++++++ .../lesson07_list_recursion/text.html | 19 ---------- .../lesson08_multiple_subjects/en.html | 13 +++++++ .../lesson08_multiple_subjects/text.html | 13 ------- .../lesson09_alternative_patterns/en.html | 12 +++++++ .../lesson09_alternative_patterns/text.html | 12 ------- .../lesson10_pattern_aliases/en.html | 7 ++++ .../lesson10_pattern_aliases/text.html | 7 ---- .../chapter2_flow_control/lesson11_guards/en.html | 9 +++++ .../lesson11_guards/text.html | 9 ----- .../chapter3_data_types/lesson00_tuples/en.html | 20 +++++++++++ .../chapter3_data_types/lesson00_tuples/text.html | 20 ----------- .../lesson01_custom_types/en.html | 9 +++++ .../lesson01_custom_types/text.html | 9 ----- .../chapter3_data_types/lesson02_records/en.html | 10 ++++++ .../chapter3_data_types/lesson02_records/text.html | 10 ------ .../lesson03_record_accessors/en.html | 18 ++++++++++ .../lesson03_record_accessors/text.html | 18 ---------- .../lesson04_record_updates/en.html | 8 +++++ .../lesson04_record_updates/text.html | 8 ----- .../chapter3_data_types/lesson05_nil/en.html | 15 ++++++++ .../chapter3_data_types/lesson05_nil/text.html | 15 -------- .../chapter3_data_types/lesson06_results/en.html | 37 +++++++++++++++++++ .../chapter3_data_types/lesson06_results/text.html | 37 ------------------- .../lesson07_bit_arrays/en.html | 26 ++++++++++++++ .../lesson07_bit_arrays/text.html | 26 -------------- .../lesson00_standard_library_package/en.html | 14 ++++++++ .../lesson00_standard_library_package/text.html | 14 -------- .../lesson01_list_module/en.html | 42 ++++++++++++++++++++++ .../lesson01_list_module/text.html | 42 ---------------------- .../lesson02_result_module/en.html | 40 +++++++++++++++++++++ .../lesson02_result_module/text.html | 40 --------------------- .../lesson03_dict_module/en.html | 40 +++++++++++++++++++++ .../lesson03_dict_module/text.html | 40 --------------------- .../lesson04_option_module/en.html | 16 +++++++++ .../lesson04_option_module/text.html | 16 --------- .../lesson00_use/en.html | 31 ++++++++++++++++ .../lesson00_use/text.html | 31 ---------------- .../lesson01_use_sugar/en.html | 30 ++++++++++++++++ .../lesson01_use_sugar/text.html | 30 ---------------- .../lesson02_todo/en.html | 14 ++++++++ .../lesson02_todo/text.html | 14 -------- .../lesson03_panic/en.html | 11 ++++++ .../lesson03_panic/text.html | 11 ------ .../lesson04_externals/en.html | 25 +++++++++++++ .../lesson04_externals/text.html | 25 ------------- .../lesson05_multi_target_externals/en.html | 22 ++++++++++++ .../lesson05_multi_target_externals/text.html | 22 ------------ .../lesson06_external_gleam_fallbacks/en.html | 13 +++++++ .../lesson06_external_gleam_fallbacks/text.html | 13 ------- 112 files changed, 1005 insertions(+), 1005 deletions(-) create mode 100644 src/content/chapter0_basics/lesson01_hello_world/en.html delete mode 100644 src/content/chapter0_basics/lesson01_hello_world/text.html create mode 100644 src/content/chapter0_basics/lesson02_unqualified_imports/en.html delete mode 100644 src/content/chapter0_basics/lesson02_unqualified_imports/text.html create mode 100644 src/content/chapter0_basics/lesson03_type_checking/en.html delete mode 100644 src/content/chapter0_basics/lesson03_type_checking/text.html create mode 100644 src/content/chapter0_basics/lesson04_ints/en.html delete mode 100644 src/content/chapter0_basics/lesson04_ints/text.html create mode 100644 src/content/chapter0_basics/lesson05_floats/en.html delete mode 100644 src/content/chapter0_basics/lesson05_floats/text.html create mode 100644 src/content/chapter0_basics/lesson06_number_formats/en.html delete mode 100644 src/content/chapter0_basics/lesson06_number_formats/text.html create mode 100644 src/content/chapter0_basics/lesson07_equality/en.html delete mode 100644 src/content/chapter0_basics/lesson07_equality/text.html create mode 100644 src/content/chapter0_basics/lesson08_strings/en.html delete mode 100644 src/content/chapter0_basics/lesson08_strings/text.html create mode 100644 src/content/chapter0_basics/lesson09_bools/en.html delete mode 100644 src/content/chapter0_basics/lesson09_bools/text.html create mode 100644 src/content/chapter0_basics/lesson10_assignments/en.html delete mode 100644 src/content/chapter0_basics/lesson10_assignments/text.html create mode 100644 src/content/chapter0_basics/lesson11_discard_patterns/en.html delete mode 100644 src/content/chapter0_basics/lesson11_discard_patterns/text.html create mode 100644 src/content/chapter0_basics/lesson12_type_annotations/en.html delete mode 100644 src/content/chapter0_basics/lesson12_type_annotations/text.html create mode 100644 src/content/chapter0_basics/lesson13_type_aliases/en.html delete mode 100644 src/content/chapter0_basics/lesson13_type_aliases/text.html create mode 100644 src/content/chapter0_basics/lesson14_blocks/en.html delete mode 100644 src/content/chapter0_basics/lesson14_blocks/text.html create mode 100644 src/content/chapter0_basics/lesson15_lists/en.html delete mode 100644 src/content/chapter0_basics/lesson15_lists/text.html create mode 100644 src/content/chapter0_basics/lesson16_constants/en.html delete mode 100644 src/content/chapter0_basics/lesson16_constants/text.html create mode 100644 src/content/chapter1_functions/lesson00_functions/en.html delete mode 100644 src/content/chapter1_functions/lesson00_functions/text.html create mode 100644 src/content/chapter1_functions/lesson03_higher_order_functions/en.html delete mode 100644 src/content/chapter1_functions/lesson03_higher_order_functions/text.html create mode 100644 src/content/chapter1_functions/lesson04_anonymous_functions/en.html delete mode 100644 src/content/chapter1_functions/lesson04_anonymous_functions/text.html create mode 100644 src/content/chapter1_functions/lesson05_function_captures/en.html delete mode 100644 src/content/chapter1_functions/lesson05_function_captures/text.html create mode 100644 src/content/chapter1_functions/lesson06_generic_functions/en.html delete mode 100644 src/content/chapter1_functions/lesson06_generic_functions/text.html create mode 100644 src/content/chapter1_functions/lesson07_pipelines/en.html delete mode 100644 src/content/chapter1_functions/lesson07_pipelines/text.html create mode 100644 src/content/chapter1_functions/lesson08_labelled_arguments/en.html delete mode 100644 src/content/chapter1_functions/lesson08_labelled_arguments/text.html create mode 100644 src/content/chapter1_functions/lesson09_documentation_comments/en.html delete mode 100644 src/content/chapter1_functions/lesson09_documentation_comments/text.html create mode 100644 src/content/chapter1_functions/lesson10_deprecations/en.html delete mode 100644 src/content/chapter1_functions/lesson10_deprecations/text.html create mode 100644 src/content/chapter2_flow_control/lesson01_case_expressions/en.html delete mode 100644 src/content/chapter2_flow_control/lesson01_case_expressions/text.html create mode 100644 src/content/chapter2_flow_control/lesson02_variable_patterns/en.html delete mode 100644 src/content/chapter2_flow_control/lesson02_variable_patterns/text.html create mode 100644 src/content/chapter2_flow_control/lesson03_string_patterns/en.html delete mode 100644 src/content/chapter2_flow_control/lesson03_string_patterns/text.html create mode 100644 src/content/chapter2_flow_control/lesson04_list_patterns/en.html delete mode 100644 src/content/chapter2_flow_control/lesson04_list_patterns/text.html create mode 100644 src/content/chapter2_flow_control/lesson05_recursion/en.html delete mode 100644 src/content/chapter2_flow_control/lesson05_recursion/text.html create mode 100644 src/content/chapter2_flow_control/lesson06_tail_calls/en.html delete mode 100644 src/content/chapter2_flow_control/lesson06_tail_calls/text.html create mode 100644 src/content/chapter2_flow_control/lesson07_list_recursion/en.html delete mode 100644 src/content/chapter2_flow_control/lesson07_list_recursion/text.html create mode 100644 src/content/chapter2_flow_control/lesson08_multiple_subjects/en.html delete mode 100644 src/content/chapter2_flow_control/lesson08_multiple_subjects/text.html create mode 100644 src/content/chapter2_flow_control/lesson09_alternative_patterns/en.html delete mode 100644 src/content/chapter2_flow_control/lesson09_alternative_patterns/text.html create mode 100644 src/content/chapter2_flow_control/lesson10_pattern_aliases/en.html delete mode 100644 src/content/chapter2_flow_control/lesson10_pattern_aliases/text.html create mode 100644 src/content/chapter2_flow_control/lesson11_guards/en.html delete mode 100644 src/content/chapter2_flow_control/lesson11_guards/text.html create mode 100644 src/content/chapter3_data_types/lesson00_tuples/en.html delete mode 100644 src/content/chapter3_data_types/lesson00_tuples/text.html create mode 100644 src/content/chapter3_data_types/lesson01_custom_types/en.html delete mode 100644 src/content/chapter3_data_types/lesson01_custom_types/text.html create mode 100644 src/content/chapter3_data_types/lesson02_records/en.html delete mode 100644 src/content/chapter3_data_types/lesson02_records/text.html create mode 100644 src/content/chapter3_data_types/lesson03_record_accessors/en.html delete mode 100644 src/content/chapter3_data_types/lesson03_record_accessors/text.html create mode 100644 src/content/chapter3_data_types/lesson04_record_updates/en.html delete mode 100644 src/content/chapter3_data_types/lesson04_record_updates/text.html create mode 100644 src/content/chapter3_data_types/lesson05_nil/en.html delete mode 100644 src/content/chapter3_data_types/lesson05_nil/text.html create mode 100644 src/content/chapter3_data_types/lesson06_results/en.html delete mode 100644 src/content/chapter3_data_types/lesson06_results/text.html create mode 100644 src/content/chapter3_data_types/lesson07_bit_arrays/en.html delete mode 100644 src/content/chapter3_data_types/lesson07_bit_arrays/text.html create mode 100644 src/content/chapter4_standard_library/lesson00_standard_library_package/en.html delete mode 100644 src/content/chapter4_standard_library/lesson00_standard_library_package/text.html create mode 100644 src/content/chapter4_standard_library/lesson01_list_module/en.html delete mode 100644 src/content/chapter4_standard_library/lesson01_list_module/text.html create mode 100644 src/content/chapter4_standard_library/lesson02_result_module/en.html delete mode 100644 src/content/chapter4_standard_library/lesson02_result_module/text.html create mode 100644 src/content/chapter4_standard_library/lesson03_dict_module/en.html delete mode 100644 src/content/chapter4_standard_library/lesson03_dict_module/text.html create mode 100644 src/content/chapter4_standard_library/lesson04_option_module/en.html delete mode 100644 src/content/chapter4_standard_library/lesson04_option_module/text.html create mode 100644 src/content/chapter5_advanced_features/lesson00_use/en.html delete mode 100644 src/content/chapter5_advanced_features/lesson00_use/text.html create mode 100644 src/content/chapter5_advanced_features/lesson01_use_sugar/en.html delete mode 100644 src/content/chapter5_advanced_features/lesson01_use_sugar/text.html create mode 100644 src/content/chapter5_advanced_features/lesson02_todo/en.html delete mode 100644 src/content/chapter5_advanced_features/lesson02_todo/text.html create mode 100644 src/content/chapter5_advanced_features/lesson03_panic/en.html delete mode 100644 src/content/chapter5_advanced_features/lesson03_panic/text.html create mode 100644 src/content/chapter5_advanced_features/lesson04_externals/en.html delete mode 100644 src/content/chapter5_advanced_features/lesson04_externals/text.html create mode 100644 src/content/chapter5_advanced_features/lesson05_multi_target_externals/en.html delete mode 100644 src/content/chapter5_advanced_features/lesson05_multi_target_externals/text.html create mode 100644 src/content/chapter5_advanced_features/lesson06_external_gleam_fallbacks/en.html delete mode 100644 src/content/chapter5_advanced_features/lesson06_external_gleam_fallbacks/text.html (limited to 'src/content') diff --git a/src/content/chapter0_basics/lesson01_hello_world/en.html b/src/content/chapter0_basics/lesson01_hello_world/en.html new file mode 100644 index 0000000..a7dfc25 --- /dev/null +++ b/src/content/chapter0_basics/lesson01_hello_world/en.html @@ -0,0 +1,18 @@ +

Here is a program that prints out the text "Hello, Joe!".

+

+ It does this by using the println function which has been + imported from the + gleam/io + module, which is part of the Gleam standard library. +

+

+ In a normal Gleam program this program would be run using the command + gleam run on the command line, but here in this tour the program + is automatically compiled and run as the code is edited. +

+

+ Try changing the text being printed to Hello, Mike! and see what + happens. +

diff --git a/src/content/chapter0_basics/lesson01_hello_world/text.html b/src/content/chapter0_basics/lesson01_hello_world/text.html deleted file mode 100644 index a7dfc25..0000000 --- a/src/content/chapter0_basics/lesson01_hello_world/text.html +++ /dev/null @@ -1,18 +0,0 @@ -

Here is a program that prints out the text "Hello, Joe!".

-

- It does this by using the println function which has been - imported from the - gleam/io - module, which is part of the Gleam standard library. -

-

- In a normal Gleam program this program would be run using the command - gleam run on the command line, but here in this tour the program - is automatically compiled and run as the code is edited. -

-

- Try changing the text being printed to Hello, Mike! and see what - happens. -

diff --git a/src/content/chapter0_basics/lesson02_unqualified_imports/en.html b/src/content/chapter0_basics/lesson02_unqualified_imports/en.html new file mode 100644 index 0000000..8fda45e --- /dev/null +++ b/src/content/chapter0_basics/lesson02_unqualified_imports/en.html @@ -0,0 +1,15 @@ +

+ Normally functions from other modules are used in a qualified fashion, with + the module qualifier before function name. For example, + io.println("Hello!"). +

+

+ It is also possible to specify a list of functions to import from a module in + an unqualified fashion, such as the println function in the code + editor. Because it has been imported like this it can be referred to as just + println. +

+

+ Generally it is best to use qualified imports, as this makes it clear where + the function is defined, making the code easier to read. +

diff --git a/src/content/chapter0_basics/lesson02_unqualified_imports/text.html b/src/content/chapter0_basics/lesson02_unqualified_imports/text.html deleted file mode 100644 index 8fda45e..0000000 --- a/src/content/chapter0_basics/lesson02_unqualified_imports/text.html +++ /dev/null @@ -1,15 +0,0 @@ -

- Normally functions from other modules are used in a qualified fashion, with - the module qualifier before function name. For example, - io.println("Hello!"). -

-

- It is also possible to specify a list of functions to import from a module in - an unqualified fashion, such as the println function in the code - editor. Because it has been imported like this it can be referred to as just - println. -

-

- Generally it is best to use qualified imports, as this makes it clear where - the function is defined, making the code easier to read. -

diff --git a/src/content/chapter0_basics/lesson03_type_checking/en.html b/src/content/chapter0_basics/lesson03_type_checking/en.html new file mode 100644 index 0000000..a9316c4 --- /dev/null +++ b/src/content/chapter0_basics/lesson03_type_checking/en.html @@ -0,0 +1,18 @@ +

+ Gleam has a robust static type system that helps you as you write and edit + code, catching mistakes and showing you where to make changes. +

+

+ Uncomment the line io.println(4) and see how a compile time error + is reported as the io.println 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. +

+

+ Gleam has no null, no implicit conversions, no exceptions, and + always performs full type checking. If the code compiles you can be reasonably + confident it does not have any inconsistencies that may cause bugs or crashes. +

diff --git a/src/content/chapter0_basics/lesson03_type_checking/text.html b/src/content/chapter0_basics/lesson03_type_checking/text.html deleted file mode 100644 index a9316c4..0000000 --- a/src/content/chapter0_basics/lesson03_type_checking/text.html +++ /dev/null @@ -1,18 +0,0 @@ -

- Gleam has a robust static type system that helps you as you write and edit - code, catching mistakes and showing you where to make changes. -

-

- Uncomment the line io.println(4) and see how a compile time error - is reported as the io.println 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. -

-

- Gleam has no null, no implicit conversions, no exceptions, and - always performs full type checking. If the code compiles you can be reasonably - confident it does not have any inconsistencies that may cause bugs or crashes. -

diff --git a/src/content/chapter0_basics/lesson04_ints/en.html b/src/content/chapter0_basics/lesson04_ints/en.html new file mode 100644 index 0000000..252496a --- /dev/null +++ b/src/content/chapter0_basics/lesson04_ints/en.html @@ -0,0 +1,17 @@ +

Gleam's Int type represents whole numbers.

+

+ There are arithmetic and comparison operators for ints, as well as the + equality operator which works on all types. +

+

+ When running on the Erlang virtual machine ints have no maximum and minimum + size. When running on JavaScript runtimes ints are represented using + JavaScript's 64 bit floating point numbers, +

+

+ The + gleam/int + standard library module contains functions for working with ints. +

diff --git a/src/content/chapter0_basics/lesson04_ints/text.html b/src/content/chapter0_basics/lesson04_ints/text.html deleted file mode 100644 index 252496a..0000000 --- a/src/content/chapter0_basics/lesson04_ints/text.html +++ /dev/null @@ -1,17 +0,0 @@ -

Gleam's Int type represents whole numbers.

-

- There are arithmetic and comparison operators for ints, as well as the - equality operator which works on all types. -

-

- When running on the Erlang virtual machine ints have no maximum and minimum - size. When running on JavaScript runtimes ints are represented using - JavaScript's 64 bit floating point numbers, -

-

- The - gleam/int - standard library module contains functions for working with ints. -

diff --git a/src/content/chapter0_basics/lesson05_floats/en.html b/src/content/chapter0_basics/lesson05_floats/en.html new file mode 100644 index 0000000..7175628 --- /dev/null +++ b/src/content/chapter0_basics/lesson05_floats/en.html @@ -0,0 +1,32 @@ +

Gleam's Float type represents numbers that are not integers.

+

+ Gleam's numerical operators are not overloaded, so there are dedicated + operators for working with floats. +

+

+ Floats are represented as 64 bit floating point numbers on both the Erlang and + JavaScript runtimes. The floating point behaviour is native to their + respective runtimes, so their exact behaviour will be slightly different + on the two runtimes. +

+

+ Under the JavaScript runtime, exceeding the maximum (or minimum) representable + value for a floating point value will result in Infinity (or + -Infinity). Should you try to divide two infinities you will + get NaN as a result. +

+

+ When running on the BEAM any overflow will raise an error. So there is + no NaN or Infinity float value in the Erlang + runtime. +

+

+ Division by zero will not overflow, but is instead defined to be zero. +

+

+ The + gleam/float + standard library module contains functions for working with floats. +

diff --git a/src/content/chapter0_basics/lesson05_floats/text.html b/src/content/chapter0_basics/lesson05_floats/text.html deleted file mode 100644 index 7175628..0000000 --- a/src/content/chapter0_basics/lesson05_floats/text.html +++ /dev/null @@ -1,32 +0,0 @@ -

Gleam's Float type represents numbers that are not integers.

-

- Gleam's numerical operators are not overloaded, so there are dedicated - operators for working with floats. -

-

- Floats are represented as 64 bit floating point numbers on both the Erlang and - JavaScript runtimes. The floating point behaviour is native to their - respective runtimes, so their exact behaviour will be slightly different - on the two runtimes. -

-

- Under the JavaScript runtime, exceeding the maximum (or minimum) representable - value for a floating point value will result in Infinity (or - -Infinity). Should you try to divide two infinities you will - get NaN as a result. -

-

- When running on the BEAM any overflow will raise an error. So there is - no NaN or Infinity float value in the Erlang - runtime. -

-

- Division by zero will not overflow, but is instead defined to be zero. -

-

- The - gleam/float - standard library module contains functions for working with floats. -

diff --git a/src/content/chapter0_basics/lesson06_number_formats/en.html b/src/content/chapter0_basics/lesson06_number_formats/en.html new file mode 100644 index 0000000..308219a --- /dev/null +++ b/src/content/chapter0_basics/lesson06_number_formats/en.html @@ -0,0 +1,13 @@ +

+ Underscores can be added to numbers for clarity. For example, + 1000000 can be tricky to read quickly, while + 1_000_000 can be easier. +

+

+ Ints can be written in binary, octal, or hexadecimal formats using the + 0b, 0o, and 0x prefixes respectively. +

+

+ Floats can be written in a scientific notation. +

+ diff --git a/src/content/chapter0_basics/lesson06_number_formats/text.html b/src/content/chapter0_basics/lesson06_number_formats/text.html deleted file mode 100644 index 308219a..0000000 --- a/src/content/chapter0_basics/lesson06_number_formats/text.html +++ /dev/null @@ -1,13 +0,0 @@ -

- Underscores can be added to numbers for clarity. For example, - 1000000 can be tricky to read quickly, while - 1_000_000 can be easier. -

-

- Ints can be written in binary, octal, or hexadecimal formats using the - 0b, 0o, and 0x prefixes respectively. -

-

- Floats can be written in a scientific notation. -

- diff --git a/src/content/chapter0_basics/lesson07_equality/en.html b/src/content/chapter0_basics/lesson07_equality/en.html new file mode 100644 index 0000000..e8c2169 --- /dev/null +++ b/src/content/chapter0_basics/lesson07_equality/en.html @@ -0,0 +1,13 @@ +

+ Gleam has the == and != operators for checking + equality. +

+

+ The operators can be used with values of any type, but both sides of the + operator must be of the same type. +

+

+ Equality is checked structurally, meaning that two values are equal + if they have the same structure rather than if they are at the same memory + location. +

diff --git a/src/content/chapter0_basics/lesson07_equality/text.html b/src/content/chapter0_basics/lesson07_equality/text.html deleted file mode 100644 index e8c2169..0000000 --- a/src/content/chapter0_basics/lesson07_equality/text.html +++ /dev/null @@ -1,13 +0,0 @@ -

- Gleam has the == and != operators for checking - equality. -

-

- The operators can be used with values of any type, but both sides of the - operator must be of the same type. -

-

- Equality is checked structurally, meaning that two values are equal - if they have the same structure rather than if they are at the same memory - location. -

diff --git a/src/content/chapter0_basics/lesson08_strings/en.html b/src/content/chapter0_basics/lesson08_strings/en.html new file mode 100644 index 0000000..e5400ca --- /dev/null +++ b/src/content/chapter0_basics/lesson08_strings/en.html @@ -0,0 +1,23 @@ +

+ In Gleam strings are written as text surrounded by double quotes, and + can span multiple lines and contain unicode characters. +

+

+ The <> operator can be used to concatenate strings. +

+

+ Several escape sequences are supported: +

+ +

+ The gleam/string + standard library module contains functions for working with strings. +

diff --git a/src/content/chapter0_basics/lesson08_strings/text.html b/src/content/chapter0_basics/lesson08_strings/text.html deleted file mode 100644 index e5400ca..0000000 --- a/src/content/chapter0_basics/lesson08_strings/text.html +++ /dev/null @@ -1,23 +0,0 @@ -

- In Gleam strings are written as text surrounded by double quotes, and - can span multiple lines and contain unicode characters. -

-

- The <> operator can be used to concatenate strings. -

-

- Several escape sequences are supported: -

- -

- The gleam/string - standard library module contains functions for working with strings. -

diff --git a/src/content/chapter0_basics/lesson09_bools/en.html b/src/content/chapter0_basics/lesson09_bools/en.html new file mode 100644 index 0000000..3f60743 --- /dev/null +++ b/src/content/chapter0_basics/lesson09_bools/en.html @@ -0,0 +1,17 @@ +

+ A Bool is a either True or False. +

+

+ The ||, &&, and ! operators can be used + to manipulate bools. +

+

+ The || and && operators are short-circuiting, + meaning that if the left hand side of the operator is True for + || or False for && then the right hand + side of the operator will not be evaluated. +

+

+ The gleam/bool + standard library module contains functions for working with bools. +

diff --git a/src/content/chapter0_basics/lesson09_bools/text.html b/src/content/chapter0_basics/lesson09_bools/text.html deleted file mode 100644 index 3f60743..0000000 --- a/src/content/chapter0_basics/lesson09_bools/text.html +++ /dev/null @@ -1,17 +0,0 @@ -

- A Bool is a either True or False. -

-

- The ||, &&, and ! operators can be used - to manipulate bools. -

-

- The || and && operators are short-circuiting, - meaning that if the left hand side of the operator is True for - || or False for && then the right hand - side of the operator will not be evaluated. -

-

- The gleam/bool - standard library module contains functions for working with bools. -

diff --git a/src/content/chapter0_basics/lesson10_assignments/en.html b/src/content/chapter0_basics/lesson10_assignments/en.html new file mode 100644 index 0000000..6d535de --- /dev/null +++ b/src/content/chapter0_basics/lesson10_assignments/en.html @@ -0,0 +1,8 @@ +

+ A value can be assigned to a variable using let. +

+

+ Variable names can be reused by later let bindings, but the values they + reference are immutable, so the values themselves are not changed or mutated + in any way. +

diff --git a/src/content/chapter0_basics/lesson10_assignments/text.html b/src/content/chapter0_basics/lesson10_assignments/text.html deleted file mode 100644 index 6d535de..0000000 --- a/src/content/chapter0_basics/lesson10_assignments/text.html +++ /dev/null @@ -1,8 +0,0 @@ -

- A value can be assigned to a variable using let. -

-

- Variable names can be reused by later let bindings, but the values they - reference are immutable, so the values themselves are not changed or mutated - in any way. -

diff --git a/src/content/chapter0_basics/lesson11_discard_patterns/en.html b/src/content/chapter0_basics/lesson11_discard_patterns/en.html new file mode 100644 index 0000000..46dc79b --- /dev/null +++ b/src/content/chapter0_basics/lesson11_discard_patterns/en.html @@ -0,0 +1,10 @@ +

+ If a variable is assigned but not used then Gleam will emit a warning. +

+

+ If a variable is intended not to be use then the name can be prefixed with an + underscore, silencing the warning. +

+

+ Try changing the variable name to score to see the warning. +

diff --git a/src/content/chapter0_basics/lesson11_discard_patterns/text.html b/src/content/chapter0_basics/lesson11_discard_patterns/text.html deleted file mode 100644 index 46dc79b..0000000 --- a/src/content/chapter0_basics/lesson11_discard_patterns/text.html +++ /dev/null @@ -1,10 +0,0 @@ -

- If a variable is assigned but not used then Gleam will emit a warning. -

-

- If a variable is intended not to be use then the name can be prefixed with an - underscore, silencing the warning. -

-

- Try changing the variable name to score to see the warning. -

diff --git a/src/content/chapter0_basics/lesson12_type_annotations/en.html b/src/content/chapter0_basics/lesson12_type_annotations/en.html new file mode 100644 index 0000000..8738a15 --- /dev/null +++ b/src/content/chapter0_basics/lesson12_type_annotations/en.html @@ -0,0 +1,15 @@ +

+ Let assignments can be written with a type annotation after the name. +

+

+ Type annotations may be useful for documentation purposes, but they do not + change how Gleam type checks the code beyond ensuring that the annotation is + correct. +

+

+ Typically Gleam code will not have type annotations for assignments. +

+

+ Try changing a type annotation to something incorrect to see the compile + error. +

diff --git a/src/content/chapter0_basics/lesson12_type_annotations/text.html b/src/content/chapter0_basics/lesson12_type_annotations/text.html deleted file mode 100644 index 8738a15..0000000 --- a/src/content/chapter0_basics/lesson12_type_annotations/text.html +++ /dev/null @@ -1,15 +0,0 @@ -

- Let assignments can be written with a type annotation after the name. -

-

- Type annotations may be useful for documentation purposes, but they do not - change how Gleam type checks the code beyond ensuring that the annotation is - correct. -

-

- Typically Gleam code will not have type annotations for assignments. -

-

- Try changing a type annotation to something incorrect to see the compile - error. -

diff --git a/src/content/chapter0_basics/lesson13_type_aliases/en.html b/src/content/chapter0_basics/lesson13_type_aliases/en.html new file mode 100644 index 0000000..6767faf --- /dev/null +++ b/src/content/chapter0_basics/lesson13_type_aliases/en.html @@ -0,0 +1,8 @@ +

+ A type alias can be used to refer to a type by a different name. Giving a type + an alias doesn't make a new type, it is still the same type. +

+

+ When the pub keyword is used the type alias is public and can be + referred to by other modules. +

diff --git a/src/content/chapter0_basics/lesson13_type_aliases/text.html b/src/content/chapter0_basics/lesson13_type_aliases/text.html deleted file mode 100644 index 6767faf..0000000 --- a/src/content/chapter0_basics/lesson13_type_aliases/text.html +++ /dev/null @@ -1,8 +0,0 @@ -

- A type alias can be used to refer to a type by a different name. Giving a type - an alias doesn't make a new type, it is still the same type. -

-

- When the pub keyword is used the type alias is public and can be - referred to by other modules. -

diff --git a/src/content/chapter0_basics/lesson14_blocks/en.html b/src/content/chapter0_basics/lesson14_blocks/en.html new file mode 100644 index 0000000..bc82e39 --- /dev/null +++ b/src/content/chapter0_basics/lesson14_blocks/en.html @@ -0,0 +1,23 @@ +

+ Blocks are one or more expressions grouped together with curly braces. Each + expression is evaluated in order and the value of the last expression is + returned. +

+

+ 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. +

+

+ Blocks can also be used to change the order of evaluation of binary operators + expressions. +

+

+ * binds more tightly than + so the expression + 1 + 2 * 3 evaluates to 7. If the 1 + 2 should be + evaluated first to make the expression evaluate to 9 then the expression can be + wrapped in a block: { 1 + 2 } * 3. This is similar to grouping + with parentheses in some other languages. +

diff --git a/src/content/chapter0_basics/lesson14_blocks/text.html b/src/content/chapter0_basics/lesson14_blocks/text.html deleted file mode 100644 index bc82e39..0000000 --- a/src/content/chapter0_basics/lesson14_blocks/text.html +++ /dev/null @@ -1,23 +0,0 @@ -

- Blocks are one or more expressions grouped together with curly braces. Each - expression is evaluated in order and the value of the last expression is - returned. -

-

- 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. -

-

- Blocks can also be used to change the order of evaluation of binary operators - expressions. -

-

- * binds more tightly than + so the expression - 1 + 2 * 3 evaluates to 7. If the 1 + 2 should be - evaluated first to make the expression evaluate to 9 then the expression can be - wrapped in a block: { 1 + 2 } * 3. This is similar to grouping - with parentheses in some other languages. -

diff --git a/src/content/chapter0_basics/lesson15_lists/en.html b/src/content/chapter0_basics/lesson15_lists/en.html new file mode 100644 index 0000000..c29758a --- /dev/null +++ b/src/content/chapter0_basics/lesson15_lists/en.html @@ -0,0 +1,19 @@ +

+ Lists are ordered collections of values. +

+

+ List is a generic type, having a type parameter + for the type of values it contains. A list of ints has the type + List(Int), and a list of strings has the type + List(String). +

+

+ Lists are immutable single-linked lists, meaning they are very efficient to + add and remove elements from the front of the list. +

+

+ Counting the length of a list or getting elements from other positions in the + list is expensive and rarely done. It is rare to write algorithms that index + into sequences in Gleam, but when they are written a list is not the right + choice of data structure. +

diff --git a/src/content/chapter0_basics/lesson15_lists/text.html b/src/content/chapter0_basics/lesson15_lists/text.html deleted file mode 100644 index c29758a..0000000 --- a/src/content/chapter0_basics/lesson15_lists/text.html +++ /dev/null @@ -1,19 +0,0 @@ -

- Lists are ordered collections of values. -

-

- List is a generic type, having a type parameter - for the type of values it contains. A list of ints has the type - List(Int), and a list of strings has the type - List(String). -

-

- Lists are immutable single-linked lists, meaning they are very efficient to - add and remove elements from the front of the list. -

-

- Counting the length of a list or getting elements from other positions in the - list is expensive and rarely done. It is rare to write algorithms that index - into sequences in Gleam, but when they are written a list is not the right - choice of data structure. -

diff --git a/src/content/chapter0_basics/lesson16_constants/en.html b/src/content/chapter0_basics/lesson16_constants/en.html new file mode 100644 index 0000000..f610dcd --- /dev/null +++ b/src/content/chapter0_basics/lesson16_constants/en.html @@ -0,0 +1,18 @@ +

+ As well as let assignments Gleam also has constants, which are defined at the + top level of a module. +

+

+ Constants must be literal values, functions cannot be used in their + definitions. +

+

+ Constants may be useful for values that are used throughout your program, + permitting them to be named and to ensure there are no differences in the + definition between each use. +

+

+ Using a constant may be more efficient than creating the same value in + multiple functions, though the exact performance characteristics will depend + on the runtime and whether compiling to Erlang or JavaScript. +

diff --git a/src/content/chapter0_basics/lesson16_constants/text.html b/src/content/chapter0_basics/lesson16_constants/text.html deleted file mode 100644 index f610dcd..0000000 --- a/src/content/chapter0_basics/lesson16_constants/text.html +++ /dev/null @@ -1,18 +0,0 @@ -

- As well as let assignments Gleam also has constants, which are defined at the - top level of a module. -

-

- Constants must be literal values, functions cannot be used in their - definitions. -

-

- Constants may be useful for values that are used throughout your program, - permitting them to be named and to ensure there are no differences in the - definition between each use. -

-

- Using a constant may be more efficient than creating the same value in - multiple functions, though the exact performance characteristics will depend - on the runtime and whether compiling to Erlang or JavaScript. -

diff --git a/src/content/chapter1_functions/lesson00_functions/en.html b/src/content/chapter1_functions/lesson00_functions/en.html new file mode 100644 index 0000000..32d5bed --- /dev/null +++ b/src/content/chapter1_functions/lesson00_functions/en.html @@ -0,0 +1,14 @@ +

+ The fn keyword is used to define new functions. +

+

+ The double and multiply functions are defined + without the pub keyword. This makes them private + functions, they can only be used within this module. If another module + attempted to use them it would result in a compiler error. +

+

+ Like with assignments, type annotations are optional for function arguments + and return values. It is considered good practice to use type annotations for + functions, for clarity and to encourage intentional and thoughtful design. +

diff --git a/src/content/chapter1_functions/lesson00_functions/text.html b/src/content/chapter1_functions/lesson00_functions/text.html deleted file mode 100644 index 32d5bed..0000000 --- a/src/content/chapter1_functions/lesson00_functions/text.html +++ /dev/null @@ -1,14 +0,0 @@ -

- The fn keyword is used to define new functions. -

-

- The double and multiply functions are defined - without the pub keyword. This makes them private - functions, they can only be used within this module. If another module - attempted to use them it would result in a compiler error. -

-

- Like with assignments, type annotations are optional for function arguments - and return values. It is considered good practice to use type annotations for - functions, for clarity and to encourage intentional and thoughtful design. -

diff --git a/src/content/chapter1_functions/lesson03_higher_order_functions/en.html b/src/content/chapter1_functions/lesson03_higher_order_functions/en.html new file mode 100644 index 0000000..3343e4d --- /dev/null +++ b/src/content/chapter1_functions/lesson03_higher_order_functions/en.html @@ -0,0 +1,12 @@ +

+ In Gleam functions are values. They can be assigned to variables, passed to + other functions, and anything else you can do with values. +

+

+ Here the function add_one is being passed as an argument to the + twice function. +

+

+ Notice the fn keyword is also used to describe the type of the + function that twice takes as its second argument. +

diff --git a/src/content/chapter1_functions/lesson03_higher_order_functions/text.html b/src/content/chapter1_functions/lesson03_higher_order_functions/text.html deleted file mode 100644 index 3343e4d..0000000 --- a/src/content/chapter1_functions/lesson03_higher_order_functions/text.html +++ /dev/null @@ -1,12 +0,0 @@ -

- In Gleam functions are values. They can be assigned to variables, passed to - other functions, and anything else you can do with values. -

-

- Here the function add_one is being passed as an argument to the - twice function. -

-

- Notice the fn keyword is also used to describe the type of the - function that twice takes as its second argument. -

diff --git a/src/content/chapter1_functions/lesson04_anonymous_functions/en.html b/src/content/chapter1_functions/lesson04_anonymous_functions/en.html new file mode 100644 index 0000000..6c6d47d --- /dev/null +++ b/src/content/chapter1_functions/lesson04_anonymous_functions/en.html @@ -0,0 +1,5 @@ +

+ As well as module-level named functions, Gleam has anonymous function + literals, written with the fn() { ... } syntax. +

+

Anonymous functions can be used interchangeably with named functions.

diff --git a/src/content/chapter1_functions/lesson04_anonymous_functions/text.html b/src/content/chapter1_functions/lesson04_anonymous_functions/text.html deleted file mode 100644 index 6c6d47d..0000000 --- a/src/content/chapter1_functions/lesson04_anonymous_functions/text.html +++ /dev/null @@ -1,5 +0,0 @@ -

- As well as module-level named functions, Gleam has anonymous function - literals, written with the fn() { ... } syntax. -

-

Anonymous functions can be used interchangeably with named functions.

diff --git a/src/content/chapter1_functions/lesson05_function_captures/en.html b/src/content/chapter1_functions/lesson05_function_captures/en.html new file mode 100644 index 0000000..afa87a3 --- /dev/null +++ b/src/content/chapter1_functions/lesson05_function_captures/en.html @@ -0,0 +1,11 @@ +

+ Gleam has a shorthand syntax for creating anonymous functions that take one + argument and immediately call another function with that argument: the + function capture syntax. +

+

+ The anonymous function fn(a) { some_function(..., a, ...) } can + be written as some_function(..., _, ...), with any number of + other arguments passed to the inner function. The underscore _ is + a placeholder for the final argument. +

diff --git a/src/content/chapter1_functions/lesson05_function_captures/text.html b/src/content/chapter1_functions/lesson05_function_captures/text.html deleted file mode 100644 index afa87a3..0000000 --- a/src/content/chapter1_functions/lesson05_function_captures/text.html +++ /dev/null @@ -1,11 +0,0 @@ -

- Gleam has a shorthand syntax for creating anonymous functions that take one - argument and immediately call another function with that argument: the - function capture syntax. -

-

- The anonymous function fn(a) { some_function(..., a, ...) } can - be written as some_function(..., _, ...), with any number of - other arguments passed to the inner function. The underscore _ is - a placeholder for the final argument. -

diff --git a/src/content/chapter1_functions/lesson06_generic_functions/en.html b/src/content/chapter1_functions/lesson06_generic_functions/en.html new file mode 100644 index 0000000..fcd9bec --- /dev/null +++ b/src/content/chapter1_functions/lesson06_generic_functions/en.html @@ -0,0 +1,25 @@ +

+ Up until now each function has accepted precisely one type for each of its + arguments. +

+

+ The twice function for example only worked with functions that + would take and return ints. This is overly restrictive, it should be possible + to use this function with any type, so long as the function and the initial + value are compatible. +

+

+ To enable this Gleam support generics, also known as + parametric polymorphism. +

+

+ This works by instead of specifying a concrete type, a type variable is used + which stands in for whatever specific type is being used when the function is + called. These type variables are written with a lowercase name. +

+

+ Type variables are not like an any type, they get replaced with a + specific type each time the function is called. Try uncommenting + twice(10, exclaim) to see the compiler error from trying to use a + type variable as an int and a string at the same time. +

diff --git a/src/content/chapter1_functions/lesson06_generic_functions/text.html b/src/content/chapter1_functions/lesson06_generic_functions/text.html deleted file mode 100644 index fcd9bec..0000000 --- a/src/content/chapter1_functions/lesson06_generic_functions/text.html +++ /dev/null @@ -1,25 +0,0 @@ -

- Up until now each function has accepted precisely one type for each of its - arguments. -

-

- The twice function for example only worked with functions that - would take and return ints. This is overly restrictive, it should be possible - to use this function with any type, so long as the function and the initial - value are compatible. -

-

- To enable this Gleam support generics, also known as - parametric polymorphism. -

-

- This works by instead of specifying a concrete type, a type variable is used - which stands in for whatever specific type is being used when the function is - called. These type variables are written with a lowercase name. -

-

- Type variables are not like an any type, they get replaced with a - specific type each time the function is called. Try uncommenting - twice(10, exclaim) to see the compiler error from trying to use a - type variable as an int and a string at the same time. -

diff --git a/src/content/chapter1_functions/lesson07_pipelines/en.html b/src/content/chapter1_functions/lesson07_pipelines/en.html new file mode 100644 index 0000000..783ade9 --- /dev/null +++ b/src/content/chapter1_functions/lesson07_pipelines/en.html @@ -0,0 +1,25 @@ +

+ It's common to want to call a series of functions, passing the result of one + to the next. With the regular function call syntax this can be a little + difficult to read as you have to read the code from the inside out. +

+

+ Gleam's pipe operator |> helps with this problem by allowing you + to write code top-to-bottom. +

+

+ The pipe operator takes the result of the expression on its left and passes it + as an argument to the function on its right. +

+

+ It will first check to see if the left-hand value could be used as the first + argument to the call. For example, a |> b(1, 2) would become + b(a, 1, 2). If not, it falls back to calling the result of the + right-hand side as a function, e.g., b(1, 2)(a) +

+

+ Gleam code is typically written with the "subject" of the function as the + first argument, to make it easier to pipe. If you wish to pipe to a different + position then a function capture can be used to insert the argument to the + desired position. +

diff --git a/src/content/chapter1_functions/lesson07_pipelines/text.html b/src/content/chapter1_functions/lesson07_pipelines/text.html deleted file mode 100644 index 783ade9..0000000 --- a/src/content/chapter1_functions/lesson07_pipelines/text.html +++ /dev/null @@ -1,25 +0,0 @@ -

- It's common to want to call a series of functions, passing the result of one - to the next. With the regular function call syntax this can be a little - difficult to read as you have to read the code from the inside out. -

-

- Gleam's pipe operator |> helps with this problem by allowing you - to write code top-to-bottom. -

-

- The pipe operator takes the result of the expression on its left and passes it - as an argument to the function on its right. -

-

- It will first check to see if the left-hand value could be used as the first - argument to the call. For example, a |> b(1, 2) would become - b(a, 1, 2). If not, it falls back to calling the result of the - right-hand side as a function, e.g., b(1, 2)(a) -

-

- Gleam code is typically written with the "subject" of the function as the - first argument, to make it easier to pipe. If you wish to pipe to a different - position then a function capture can be used to insert the argument to the - desired position. -

diff --git a/src/content/chapter1_functions/lesson08_labelled_arguments/en.html b/src/content/chapter1_functions/lesson08_labelled_arguments/en.html new file mode 100644 index 0000000..b1d771c --- /dev/null +++ b/src/content/chapter1_functions/lesson08_labelled_arguments/en.html @@ -0,0 +1,23 @@ +

+ When functions take several arguments it can be difficult to remember what the + arguments are, and what order they are expected in. +

+

+ To help with this Gleam supports labelled arguments, where function arguments + are given an external label in addition to their internal name. These labels + are written before the argument name in the function definition. +

+

+ When labelled arguments are used the order of the arguments does not matter, + but all unlabelled arguments must come before labelled arguments. +

+

+ There is no performance cost to using labelled arguments, it does not allocate + a dictionary or perform any other runtime work. +

+

+ Labels are optional when calling a function, it is up to the programmer to + decide what is clearest in their code. +

+ + diff --git a/src/content/chapter1_functions/lesson08_labelled_arguments/text.html b/src/content/chapter1_functions/lesson08_labelled_arguments/text.html deleted file mode 100644 index b1d771c..0000000 --- a/src/content/chapter1_functions/lesson08_labelled_arguments/text.html +++ /dev/null @@ -1,23 +0,0 @@ -

- When functions take several arguments it can be difficult to remember what the - arguments are, and what order they are expected in. -

-

- To help with this Gleam supports labelled arguments, where function arguments - are given an external label in addition to their internal name. These labels - are written before the argument name in the function definition. -

-

- When labelled arguments are used the order of the arguments does not matter, - but all unlabelled arguments must come before labelled arguments. -

-

- There is no performance cost to using labelled arguments, it does not allocate - a dictionary or perform any other runtime work. -

-

- Labels are optional when calling a function, it is up to the programmer to - decide what is clearest in their code. -

- - diff --git a/src/content/chapter1_functions/lesson09_documentation_comments/en.html b/src/content/chapter1_functions/lesson09_documentation_comments/en.html new file mode 100644 index 0000000..c27bac6 --- /dev/null +++ b/src/content/chapter1_functions/lesson09_documentation_comments/en.html @@ -0,0 +1,16 @@ +

+ Documentation and comments are important tools for making your code easier to + work with and understand. +

+

+ As well as regular // comments Gleam has /// and + //// comments which are used for attaching documentation to code. +

+

+ /// is used for documenting types and functions, and should be + placed immediately before the type or function it is documenting. +

+

+ //// is used for documenting modules, and should be placed + at the top of the module. +

diff --git a/src/content/chapter1_functions/lesson09_documentation_comments/text.html b/src/content/chapter1_functions/lesson09_documentation_comments/text.html deleted file mode 100644 index c27bac6..0000000 --- a/src/content/chapter1_functions/lesson09_documentation_comments/text.html +++ /dev/null @@ -1,16 +0,0 @@ -

- Documentation and comments are important tools for making your code easier to - work with and understand. -

-

- As well as regular // comments Gleam has /// and - //// comments which are used for attaching documentation to code. -

-

- /// is used for documenting types and functions, and should be - placed immediately before the type or function it is documenting. -

-

- //// is used for documenting modules, and should be placed - at the top of the module. -

diff --git a/src/content/chapter1_functions/lesson10_deprecations/en.html b/src/content/chapter1_functions/lesson10_deprecations/en.html new file mode 100644 index 0000000..8fe260f --- /dev/null +++ b/src/content/chapter1_functions/lesson10_deprecations/en.html @@ -0,0 +1,14 @@ +

+ Functions and other definitions can be marked as deprecated using the + @deprecated + attribute. +

+

+ If a deprecated function is reference the compiler will emit a warning, + letting the programmer know they ought to update their code. +

+

+ The deprecation attribute takes a message and this will be displayed to the + user in the warning. In the message explain to the user the new approach or + replacement function, or direct them on documentation on how to upgrade. +

diff --git a/src/content/chapter1_functions/lesson10_deprecations/text.html b/src/content/chapter1_functions/lesson10_deprecations/text.html deleted file mode 100644 index 8fe260f..0000000 --- a/src/content/chapter1_functions/lesson10_deprecations/text.html +++ /dev/null @@ -1,14 +0,0 @@ -

- Functions and other definitions can be marked as deprecated using the - @deprecated - attribute. -

-

- If a deprecated function is reference the compiler will emit a warning, - letting the programmer know they ought to update their code. -

-

- The deprecation attribute takes a message and this will be displayed to the - user in the warning. In the message explain to the user the new approach or - replacement function, or direct them on documentation on how to upgrade. -

diff --git a/src/content/chapter2_flow_control/lesson01_case_expressions/en.html b/src/content/chapter2_flow_control/lesson01_case_expressions/en.html new file mode 100644 index 0000000..07ff421 --- /dev/null +++ b/src/content/chapter2_flow_control/lesson01_case_expressions/en.html @@ -0,0 +1,18 @@ +

+ The case expression is the most common kind of flow control in Gleam code. It + is similar to switch in some other languages, but more powerful + than most. +

+

+ It allows the programmer to say "if the data has this shape then run this + code", a process called pattern matching. +

+

+ Gleam performs exhaustiveness checking to ensure that the patterns in + a case expression cover all possible values. With this you can have confidence + that your logic is up-to-date for the design of the data you are working with. +

+

+ Try commenting out patterns or adding new redundant ones, and see what + problems the compiler reports. +

diff --git a/src/content/chapter2_flow_control/lesson01_case_expressions/text.html b/src/content/chapter2_flow_control/lesson01_case_expressions/text.html deleted file mode 100644 index 07ff421..0000000 --- a/src/content/chapter2_flow_control/lesson01_case_expressions/text.html +++ /dev/null @@ -1,18 +0,0 @@ -

- The case expression is the most common kind of flow control in Gleam code. It - is similar to switch in some other languages, but more powerful - than most. -

-

- It allows the programmer to say "if the data has this shape then run this - code", a process called pattern matching. -

-

- Gleam performs exhaustiveness checking to ensure that the patterns in - a case expression cover all possible values. With this you can have confidence - that your logic is up-to-date for the design of the data you are working with. -

-

- Try commenting out patterns or adding new redundant ones, and see what - problems the compiler reports. -

diff --git a/src/content/chapter2_flow_control/lesson02_variable_patterns/en.html b/src/content/chapter2_flow_control/lesson02_variable_patterns/en.html new file mode 100644 index 0000000..7e9ac11 --- /dev/null +++ b/src/content/chapter2_flow_control/lesson02_variable_patterns/en.html @@ -0,0 +1,7 @@ +

+ Patterns in case expressions can also assign variables. +

+

+ When a variable name is used in a pattern the value that is matched against is + assigned to that name, and can be used in the body of that clause. +

diff --git a/src/content/chapter2_flow_control/lesson02_variable_patterns/text.html b/src/content/chapter2_flow_control/lesson02_variable_patterns/text.html deleted file mode 100644 index 7e9ac11..0000000 --- a/src/content/chapter2_flow_control/lesson02_variable_patterns/text.html +++ /dev/null @@ -1,7 +0,0 @@ -

- Patterns in case expressions can also assign variables. -

-

- When a variable name is used in a pattern the value that is matched against is - assigned to that name, and can be used in the body of that clause. -

diff --git a/src/content/chapter2_flow_control/lesson03_string_patterns/en.html b/src/content/chapter2_flow_control/lesson03_string_patterns/en.html new file mode 100644 index 0000000..11e4c35 --- /dev/null +++ b/src/content/chapter2_flow_control/lesson03_string_patterns/en.html @@ -0,0 +1,9 @@ +

+ When pattern matching on strings the <> operator can be + used to match on strings with a specific prefix. +

+

+ The pattern "hello " <> name matches any string that starts with + "hello " and assigns the rest of the string to the variable + name. +

diff --git a/src/content/chapter2_flow_control/lesson03_string_patterns/text.html b/src/content/chapter2_flow_control/lesson03_string_patterns/text.html deleted file mode 100644 index 11e4c35..0000000 --- a/src/content/chapter2_flow_control/lesson03_string_patterns/text.html +++ /dev/null @@ -1,9 +0,0 @@ -

- When pattern matching on strings the <> operator can be - used to match on strings with a specific prefix. -

-

- The pattern "hello " <> name matches any string that starts with - "hello " and assigns the rest of the string to the variable - name. -

diff --git a/src/content/chapter2_flow_control/lesson04_list_patterns/en.html b/src/content/chapter2_flow_control/lesson04_list_patterns/en.html new file mode 100644 index 0000000..de55eef --- /dev/null +++ b/src/content/chapter2_flow_control/lesson04_list_patterns/en.html @@ -0,0 +1,15 @@ +

+ Lists and the values they contain can be pattern matched on in case + expressions. +

+

+ List patterns match on specific lengths of lists. The pattern [] + matches an empty list, and the pattern [_] matches a list with + one element. They will not match on lists with other lengths. +

+

+ The spread pattern .. can be used to match the rest of the list. + The pattern [1, ..] matches any list that starts with + 1. The pattern [_, _, ..] matches any list that has + at least two elements. +

diff --git a/src/content/chapter2_flow_control/lesson04_list_patterns/text.html b/src/content/chapter2_flow_control/lesson04_list_patterns/text.html deleted file mode 100644 index de55eef..0000000 --- a/src/content/chapter2_flow_control/lesson04_list_patterns/text.html +++ /dev/null @@ -1,15 +0,0 @@ -

- Lists and the values they contain can be pattern matched on in case - expressions. -

-

- List patterns match on specific lengths of lists. The pattern [] - matches an empty list, and the pattern [_] matches a list with - one element. They will not match on lists with other lengths. -

-

- The spread pattern .. can be used to match the rest of the list. - The pattern [1, ..] matches any list that starts with - 1. The pattern [_, _, ..] matches any list that has - at least two elements. -

diff --git a/src/content/chapter2_flow_control/lesson05_recursion/en.html b/src/content/chapter2_flow_control/lesson05_recursion/en.html new file mode 100644 index 0000000..f1585bb --- /dev/null +++ b/src/content/chapter2_flow_control/lesson05_recursion/en.html @@ -0,0 +1,20 @@ +

+ Gleam doesn't have loops, instead iteration is done through recursion, that is + through top-level functions calling themselves with different arguments. +

+

+ A recursive function needs to have at least one base case and at + least one recursive case. A base case returns a value without calling + the function again. A recursive case calls the function again with different + inputs, looping again. +

+

+ The Gleam standard library has functions for various common looping patterns, + some of which will be introduced in later lessons, however for more complex + loops manual recursion is often the clearest way to write it. +

+

+ Recursion can seem daunting or unclear at first if you are more familiar with + languages that have special looping features, but stick with it! With time + it'll become just as familiar and comfortable as any other way of iterating. +

diff --git a/src/content/chapter2_flow_control/lesson05_recursion/text.html b/src/content/chapter2_flow_control/lesson05_recursion/text.html deleted file mode 100644 index f1585bb..0000000 --- a/src/content/chapter2_flow_control/lesson05_recursion/text.html +++ /dev/null @@ -1,20 +0,0 @@ -

- Gleam doesn't have loops, instead iteration is done through recursion, that is - through top-level functions calling themselves with different arguments. -

-

- A recursive function needs to have at least one base case and at - least one recursive case. A base case returns a value without calling - the function again. A recursive case calls the function again with different - inputs, looping again. -

-

- The Gleam standard library has functions for various common looping patterns, - some of which will be introduced in later lessons, however for more complex - loops manual recursion is often the clearest way to write it. -

-

- Recursion can seem daunting or unclear at first if you are more familiar with - languages that have special looping features, but stick with it! With time - it'll become just as familiar and comfortable as any other way of iterating. -

diff --git a/src/content/chapter2_flow_control/lesson06_tail_calls/en.html b/src/content/chapter2_flow_control/lesson06_tail_calls/en.html new file mode 100644 index 0000000..ec39cda --- /dev/null +++ b/src/content/chapter2_flow_control/lesson06_tail_calls/en.html @@ -0,0 +1,23 @@ +

+ When a function is called a new stack frame is created in memory to store the + arguments and local variables of the function. If lots of these frames are + created during recursion then the program would use a large amount of memory, + or even crash the program if some limit is hit. +

+

+ To avoid this problem Gleam supports tail call optimisation, which + allows the compiler to reuse the stack frame for the current function if a + function call is the last thing the function does, removing the memory cost. +

+ +

+ Unoptimised recursive functions can often be rewritten into tail call + optimised functions by using an accumulator. An accumulator is a variable that + is passed along in addition to the data, similar to a mutable variable in a + language with while loops. +

+

+ Accumulators should be hidden away from the users of your code, they are + internal implementation details. To do this write a public function that calls + a recursive private function with the initial accumulator value. +

diff --git a/src/content/chapter2_flow_control/lesson06_tail_calls/text.html b/src/content/chapter2_flow_control/lesson06_tail_calls/text.html deleted file mode 100644 index ec39cda..0000000 --- a/src/content/chapter2_flow_control/lesson06_tail_calls/text.html +++ /dev/null @@ -1,23 +0,0 @@ -

- When a function is called a new stack frame is created in memory to store the - arguments and local variables of the function. If lots of these frames are - created during recursion then the program would use a large amount of memory, - or even crash the program if some limit is hit. -

-

- To avoid this problem Gleam supports tail call optimisation, which - allows the compiler to reuse the stack frame for the current function if a - function call is the last thing the function does, removing the memory cost. -

- -

- Unoptimised recursive functions can often be rewritten into tail call - optimised functions by using an accumulator. An accumulator is a variable that - is passed along in addition to the data, similar to a mutable variable in a - language with while loops. -

-

- Accumulators should be hidden away from the users of your code, they are - internal implementation details. To do this write a public function that calls - a recursive private function with the initial accumulator value. -

diff --git a/src/content/chapter2_flow_control/lesson07_list_recursion/en.html b/src/content/chapter2_flow_control/lesson07_list_recursion/en.html new file mode 100644 index 0000000..94e8152 --- /dev/null +++ b/src/content/chapter2_flow_control/lesson07_list_recursion/en.html @@ -0,0 +1,19 @@ +

+ Most commonly functions in the + gleam/list + module are used to iterate across a list, but at times you may prefer to work + with the list directly. +

+

+ The [first, ..rest] pattern matches on a list with at least one + element, assigning the first element to the variable first and + the rest of the list to the variable rest. By using this pattern + and a pattern for the empty list [] a function can run code on + each element of a list until the end is reached. +

+

+ This code sums a list by recursing over the list and adding each int to a + total argument, returning it when the end is reached. +

diff --git a/src/content/chapter2_flow_control/lesson07_list_recursion/text.html b/src/content/chapter2_flow_control/lesson07_list_recursion/text.html deleted file mode 100644 index 94e8152..0000000 --- a/src/content/chapter2_flow_control/lesson07_list_recursion/text.html +++ /dev/null @@ -1,19 +0,0 @@ -

- Most commonly functions in the - gleam/list - module are used to iterate across a list, but at times you may prefer to work - with the list directly. -

-

- The [first, ..rest] pattern matches on a list with at least one - element, assigning the first element to the variable first and - the rest of the list to the variable rest. By using this pattern - and a pattern for the empty list [] a function can run code on - each element of a list until the end is reached. -

-

- This code sums a list by recursing over the list and adding each int to a - total argument, returning it when the end is reached. -

diff --git a/src/content/chapter2_flow_control/lesson08_multiple_subjects/en.html b/src/content/chapter2_flow_control/lesson08_multiple_subjects/en.html new file mode 100644 index 0000000..23e3722 --- /dev/null +++ b/src/content/chapter2_flow_control/lesson08_multiple_subjects/en.html @@ -0,0 +1,13 @@ +

+ Sometimes it is useful to pattern match on multiple values at the same time in + one case expression. +

+

+ To do this you can give multiple subjects and multiple patterns, separated by + commas. +

+

+ When matching on multiple subjects there must be the same number of patterns + as there are subjects. Try removing one of the _, sub-patterns to + see the compile time error that is returned. +

diff --git a/src/content/chapter2_flow_control/lesson08_multiple_subjects/text.html b/src/content/chapter2_flow_control/lesson08_multiple_subjects/text.html deleted file mode 100644 index 23e3722..0000000 --- a/src/content/chapter2_flow_control/lesson08_multiple_subjects/text.html +++ /dev/null @@ -1,13 +0,0 @@ -

- Sometimes it is useful to pattern match on multiple values at the same time in - one case expression. -

-

- To do this you can give multiple subjects and multiple patterns, separated by - commas. -

-

- When matching on multiple subjects there must be the same number of patterns - as there are subjects. Try removing one of the _, sub-patterns to - see the compile time error that is returned. -

diff --git a/src/content/chapter2_flow_control/lesson09_alternative_patterns/en.html b/src/content/chapter2_flow_control/lesson09_alternative_patterns/en.html new file mode 100644 index 0000000..25421f4 --- /dev/null +++ b/src/content/chapter2_flow_control/lesson09_alternative_patterns/en.html @@ -0,0 +1,12 @@ +

+ Alternative patterns can be given for a case clause using the + | operator. If any of the patterns match then the clause matches. +

+

+ If a pattern defines a variable then all of the alternative patterns for that + clause must also define a variable with the same name and same type. +

+

+ Currently it is not possible to have nested alternative patterns, so the + pattern [1 | 2 | 3] is not valid. +

diff --git a/src/content/chapter2_flow_control/lesson09_alternative_patterns/text.html b/src/content/chapter2_flow_control/lesson09_alternative_patterns/text.html deleted file mode 100644 index 25421f4..0000000 --- a/src/content/chapter2_flow_control/lesson09_alternative_patterns/text.html +++ /dev/null @@ -1,12 +0,0 @@ -

- Alternative patterns can be given for a case clause using the - | operator. If any of the patterns match then the clause matches. -

-

- If a pattern defines a variable then all of the alternative patterns for that - clause must also define a variable with the same name and same type. -

-

- Currently it is not possible to have nested alternative patterns, so the - pattern [1 | 2 | 3] is not valid. -

diff --git a/src/content/chapter2_flow_control/lesson10_pattern_aliases/en.html b/src/content/chapter2_flow_control/lesson10_pattern_aliases/en.html new file mode 100644 index 0000000..b737eb8 --- /dev/null +++ b/src/content/chapter2_flow_control/lesson10_pattern_aliases/en.html @@ -0,0 +1,7 @@ +

+ The as operator can be used to assign sub patterns to variables. +

+

+ The pattern [_, ..] as it will match any non-empty list and + assign that list to the variable it. +

diff --git a/src/content/chapter2_flow_control/lesson10_pattern_aliases/text.html b/src/content/chapter2_flow_control/lesson10_pattern_aliases/text.html deleted file mode 100644 index b737eb8..0000000 --- a/src/content/chapter2_flow_control/lesson10_pattern_aliases/text.html +++ /dev/null @@ -1,7 +0,0 @@ -

- The as operator can be used to assign sub patterns to variables. -

-

- The pattern [_, ..] as it will match any non-empty list and - assign that list to the variable it. -

diff --git a/src/content/chapter2_flow_control/lesson11_guards/en.html b/src/content/chapter2_flow_control/lesson11_guards/en.html new file mode 100644 index 0000000..3ea9cc5 --- /dev/null +++ b/src/content/chapter2_flow_control/lesson11_guards/en.html @@ -0,0 +1,9 @@ +

+ The if keyword can be used with case expressions to add a + guard to a pattern. A guard is an expression that must evaluate to + True for the pattern to match. +

+

+ Only a limited set of operators can be used in guards, and functions cannot be + called at all. +

diff --git a/src/content/chapter2_flow_control/lesson11_guards/text.html b/src/content/chapter2_flow_control/lesson11_guards/text.html deleted file mode 100644 index 3ea9cc5..0000000 --- a/src/content/chapter2_flow_control/lesson11_guards/text.html +++ /dev/null @@ -1,9 +0,0 @@ -

- The if keyword can be used with case expressions to add a - guard to a pattern. A guard is an expression that must evaluate to - True for the pattern to match. -

-

- Only a limited set of operators can be used in guards, and functions cannot be - called at all. -

diff --git a/src/content/chapter3_data_types/lesson00_tuples/en.html b/src/content/chapter3_data_types/lesson00_tuples/en.html new file mode 100644 index 0000000..f121a9d --- /dev/null +++ b/src/content/chapter3_data_types/lesson00_tuples/en.html @@ -0,0 +1,20 @@ +

+ Lists are good for when we want a collection of one type, but sometimes we + want to combine multiple values of different types. In this case tuples are a + quick and convenient option. +

+

+ The tuple access syntax can be used to get elements from a tuple without + pattern matching. some_tuple.0 gets the first element, + some_tuple.1 gets the second element, etc. +

+

+ Tuples are generic types, they have type parameters for the types they + contain. #(1, "Hi!") has the type #(Int, String), + and #(1.4, 10, 48) has the type #(Float, Int, Int). +

+

+ Tuples are most commonly used to return 2 or 3 values from a function. Other + times it is often is clearer to use a custom type, which we will + cover next. +

diff --git a/src/content/chapter3_data_types/lesson00_tuples/text.html b/src/content/chapter3_data_types/lesson00_tuples/text.html deleted file mode 100644 index f121a9d..0000000 --- a/src/content/chapter3_data_types/lesson00_tuples/text.html +++ /dev/null @@ -1,20 +0,0 @@ -

- Lists are good for when we want a collection of one type, but sometimes we - want to combine multiple values of different types. In this case tuples are a - quick and convenient option. -

-

- The tuple access syntax can be used to get elements from a tuple without - pattern matching. some_tuple.0 gets the first element, - some_tuple.1 gets the second element, etc. -

-

- Tuples are generic types, they have type parameters for the types they - contain. #(1, "Hi!") has the type #(Int, String), - and #(1.4, 10, 48) has the type #(Float, Int, Int). -

-

- Tuples are most commonly used to return 2 or 3 values from a function. Other - times it is often is clearer to use a custom type, which we will - cover next. -

diff --git a/src/content/chapter3_data_types/lesson01_custom_types/en.html b/src/content/chapter3_data_types/lesson01_custom_types/en.html new file mode 100644 index 0000000..3a95f9f --- /dev/null +++ b/src/content/chapter3_data_types/lesson01_custom_types/en.html @@ -0,0 +1,9 @@ +

+ Gleam has a few built in types such as Int, String, + but custom types allow the creation of entirely new types. +

+

+ A custom type is defined with the type keyword followed by the + name of the type and a constructor for each variant of the type. +

+

Custom type variants can be pattern matched on using a case expression.

diff --git a/src/content/chapter3_data_types/lesson01_custom_types/text.html b/src/content/chapter3_data_types/lesson01_custom_types/text.html deleted file mode 100644 index 3a95f9f..0000000 --- a/src/content/chapter3_data_types/lesson01_custom_types/text.html +++ /dev/null @@ -1,9 +0,0 @@ -

- Gleam has a few built in types such as Int, String, - but custom types allow the creation of entirely new types. -

-

- A custom type is defined with the type keyword followed by the - name of the type and a constructor for each variant of the type. -

-

Custom type variants can be pattern matched on using a case expression.

diff --git a/src/content/chapter3_data_types/lesson02_records/en.html b/src/content/chapter3_data_types/lesson02_records/en.html new file mode 100644 index 0000000..f515ccd --- /dev/null +++ b/src/content/chapter3_data_types/lesson02_records/en.html @@ -0,0 +1,10 @@ +

Variants of a record can hold other data within them.

+

+ These fields can be given labels, and like function argument labels they can + be optionally used when calling the record constructor. Typically labels will + be used for variants that define them. +

+

+ It is common to have a custom type with one variant that holds data, this is + the Gleam equivalent of a struct or object in other languages. +

diff --git a/src/content/chapter3_data_types/lesson02_records/text.html b/src/content/chapter3_data_types/lesson02_records/text.html deleted file mode 100644 index f515ccd..0000000 --- a/src/content/chapter3_data_types/lesson02_records/text.html +++ /dev/null @@ -1,10 +0,0 @@ -

Variants of a record can hold other data within them.

-

- These fields can be given labels, and like function argument labels they can - be optionally used when calling the record constructor. Typically labels will - be used for variants that define them. -

-

- It is common to have a custom type with one variant that holds data, this is - the Gleam equivalent of a struct or object in other languages. -

diff --git a/src/content/chapter3_data_types/lesson03_record_accessors/en.html b/src/content/chapter3_data_types/lesson03_record_accessors/en.html new file mode 100644 index 0000000..bb2473b --- /dev/null +++ b/src/content/chapter3_data_types/lesson03_record_accessors/en.html @@ -0,0 +1,18 @@ +

+ The record accessor syntax record.field_label can be used to get + contained values from a custom type record. +

+

+ The accessor syntax can only be used for fields with the same name that are in + the same position and have the same type for all variants of the custom type. +

+

+ The name field is in the first position and has type + String for all variants, so it can be accessed. +

+

+ The subject field is absent on the Student variant, + so it cannot be used on any variant of type SchoolPerson. + Uncomment the teacher.subject line to see the compile error from + trying to use this accessor. +

diff --git a/src/content/chapter3_data_types/lesson03_record_accessors/text.html b/src/content/chapter3_data_types/lesson03_record_accessors/text.html deleted file mode 100644 index bb2473b..0000000 --- a/src/content/chapter3_data_types/lesson03_record_accessors/text.html +++ /dev/null @@ -1,18 +0,0 @@ -

- The record accessor syntax record.field_label can be used to get - contained values from a custom type record. -

-

- The accessor syntax can only be used for fields with the same name that are in - the same position and have the same type for all variants of the custom type. -

-

- The name field is in the first position and has type - String for all variants, so it can be accessed. -

-

- The subject field is absent on the Student variant, - so it cannot be used on any variant of type SchoolPerson. - Uncomment the teacher.subject line to see the compile error from - trying to use this accessor. -

diff --git a/src/content/chapter3_data_types/lesson04_record_updates/en.html b/src/content/chapter3_data_types/lesson04_record_updates/en.html new file mode 100644 index 0000000..4a5cd3a --- /dev/null +++ b/src/content/chapter3_data_types/lesson04_record_updates/en.html @@ -0,0 +1,8 @@ +

+ The record update syntax can be used to create a new record from an existing + one of the same type, but with some fields changed. +

+

+ Gleam is an immutable language, so using the record update syntax does not + mutate or otherwise change the original record. +

diff --git a/src/content/chapter3_data_types/lesson04_record_updates/text.html b/src/content/chapter3_data_types/lesson04_record_updates/text.html deleted file mode 100644 index 4a5cd3a..0000000 --- a/src/content/chapter3_data_types/lesson04_record_updates/text.html +++ /dev/null @@ -1,8 +0,0 @@ -

- The record update syntax can be used to create a new record from an existing - one of the same type, but with some fields changed. -

-

- Gleam is an immutable language, so using the record update syntax does not - mutate or otherwise change the original record. -

diff --git a/src/content/chapter3_data_types/lesson05_nil/en.html b/src/content/chapter3_data_types/lesson05_nil/en.html new file mode 100644 index 0000000..00a082e --- /dev/null +++ b/src/content/chapter3_data_types/lesson05_nil/en.html @@ -0,0 +1,15 @@ +

+ Nil is Gleam's unit type. It is a value that is returned by + functions that have nothing else to return, as all functions must return + something. +

+

+ Nil is not a valid value of any other types, that is values in + Gleam are not nullable. If the type of a value is Nil then it is + the value Nil. If it is some other type then the value is not + Nil. +

+

+ Uncomment the line that assigns Nil to a variable with an + incompatible type annotation to see the compile time error it produces. +

diff --git a/src/content/chapter3_data_types/lesson05_nil/text.html b/src/content/chapter3_data_types/lesson05_nil/text.html deleted file mode 100644 index 00a082e..0000000 --- a/src/content/chapter3_data_types/lesson05_nil/text.html +++ /dev/null @@ -1,15 +0,0 @@ -

- Nil is Gleam's unit type. It is a value that is returned by - functions that have nothing else to return, as all functions must return - something. -

-

- Nil is not a valid value of any other types, that is values in - Gleam are not nullable. If the type of a value is Nil then it is - the value Nil. If it is some other type then the value is not - Nil. -

-

- Uncomment the line that assigns Nil to a variable with an - incompatible type annotation to see the compile time error it produces. -

diff --git a/src/content/chapter3_data_types/lesson06_results/en.html b/src/content/chapter3_data_types/lesson06_results/en.html new file mode 100644 index 0000000..2e1b16b --- /dev/null +++ b/src/content/chapter3_data_types/lesson06_results/en.html @@ -0,0 +1,37 @@ +

+ Gleam doesn't use exceptions, instead computations that can either succeed or + fail return a value of the built-in Result(value, error) type. It + has two variants: +

+ +

+ The type is generic with two type parameters, one for the success value and + one for the error. With these the result can hold any type for success and + failure. +

+

+ Commonly Gleam programs and library will define custom types with a variant + for each possible problem that can arise, along with any error information + that would be useful to the programmer. +

+

+ This is advantageous over exceptions as you can immediately see what if any + errors a function can return, and the compiler will ensure they are handled. + No nasty surprises with unexpected exceptions! +

+

+ A result value can be handled by pattern matching with a + case expression, but given how frequently results are returned + this can become unwieldy. Gleam code commonly uses the + gleam/result standard library module and + use expressions when working with results, both of which will be + covered in later chapters. +

diff --git a/src/content/chapter3_data_types/lesson06_results/text.html b/src/content/chapter3_data_types/lesson06_results/text.html deleted file mode 100644 index 2e1b16b..0000000 --- a/src/content/chapter3_data_types/lesson06_results/text.html +++ /dev/null @@ -1,37 +0,0 @@ -

- Gleam doesn't use exceptions, instead computations that can either succeed or - fail return a value of the built-in Result(value, error) type. It - has two variants: -

- -

- The type is generic with two type parameters, one for the success value and - one for the error. With these the result can hold any type for success and - failure. -

-

- Commonly Gleam programs and library will define custom types with a variant - for each possible problem that can arise, along with any error information - that would be useful to the programmer. -

-

- This is advantageous over exceptions as you can immediately see what if any - errors a function can return, and the compiler will ensure they are handled. - No nasty surprises with unexpected exceptions! -

-

- A result value can be handled by pattern matching with a - case expression, but given how frequently results are returned - this can become unwieldy. Gleam code commonly uses the - gleam/result standard library module and - use expressions when working with results, both of which will be - covered in later chapters. -

diff --git a/src/content/chapter3_data_types/lesson07_bit_arrays/en.html b/src/content/chapter3_data_types/lesson07_bit_arrays/en.html new file mode 100644 index 0000000..3214db1 --- /dev/null +++ b/src/content/chapter3_data_types/lesson07_bit_arrays/en.html @@ -0,0 +1,26 @@ +

+ Bit arrays represent a sequence of 1s and 0s, and are a convenient syntax for + constructing and manipulating binary data. +

+

+ Each segment of a bit array can be given options to specify the representation + used for that segment. +

+ +

+ Bit arrays have limited support when compiling to JavaScript, not all options + can be used. Full bit array support will be implemented in future. +

diff --git a/src/content/chapter3_data_types/lesson07_bit_arrays/text.html b/src/content/chapter3_data_types/lesson07_bit_arrays/text.html deleted file mode 100644 index 3214db1..0000000 --- a/src/content/chapter3_data_types/lesson07_bit_arrays/text.html +++ /dev/null @@ -1,26 +0,0 @@ -

- Bit arrays represent a sequence of 1s and 0s, and are a convenient syntax for - constructing and manipulating binary data. -

-

- Each segment of a bit array can be given options to specify the representation - used for that segment. -

- -

- Bit arrays have limited support when compiling to JavaScript, not all options - can be used. Full bit array support will be implemented in future. -

diff --git a/src/content/chapter4_standard_library/lesson00_standard_library_package/en.html b/src/content/chapter4_standard_library/lesson00_standard_library_package/en.html new file mode 100644 index 0000000..f5d7505 --- /dev/null +++ b/src/content/chapter4_standard_library/lesson00_standard_library_package/en.html @@ -0,0 +1,14 @@ +

+ The Gleam standard library is a regular Gleam package that has been published + to the Hex package repository. You could opt to + not use if you wish, though almost all Gleam projects depend on it. +

+

+ All of the modules imported so far in this guide, such as + gleam/io, are from the standard library. +

+

+ All of the documentation for the standard library is available on + HexDocs. We will go over some + of the most commonly used modules now. +

diff --git a/src/content/chapter4_standard_library/lesson00_standard_library_package/text.html b/src/content/chapter4_standard_library/lesson00_standard_library_package/text.html deleted file mode 100644 index f5d7505..0000000 --- a/src/content/chapter4_standard_library/lesson00_standard_library_package/text.html +++ /dev/null @@ -1,14 +0,0 @@ -

- The Gleam standard library is a regular Gleam package that has been published - to the Hex package repository. You could opt to - not use if you wish, though almost all Gleam projects depend on it. -

-

- All of the modules imported so far in this guide, such as - gleam/io, are from the standard library. -

-

- All of the documentation for the standard library is available on - HexDocs. We will go over some - of the most commonly used modules now. -

diff --git a/src/content/chapter4_standard_library/lesson01_list_module/en.html b/src/content/chapter4_standard_library/lesson01_list_module/en.html new file mode 100644 index 0000000..7451b10 --- /dev/null +++ b/src/content/chapter4_standard_library/lesson01_list_module/en.html @@ -0,0 +1,42 @@ +

+ The + gleam/list + standard library module contains functions for working with lists. A Gleam + program will likely make heavy use of this module, the various functions + serving as different types of loops over lists. +

+ +

+ map + makes a new list by running a function on each element in a list. +

+

+ filter + makes a new list containing only the elements for which a function returns + true. +

+

+ fold + combines all the elements in a list into a single value by running a function + left-to-right on each element, passing the result of the previous call to the + next call. +

+

+ find + returns the first element in a list for which a function returns + True. +

+

+ It's worth getting familiar with all the functions in this module when writing + Gleam code, you'll be using them a lot! +

diff --git a/src/content/chapter4_standard_library/lesson01_list_module/text.html b/src/content/chapter4_standard_library/lesson01_list_module/text.html deleted file mode 100644 index 7451b10..0000000 --- a/src/content/chapter4_standard_library/lesson01_list_module/text.html +++ /dev/null @@ -1,42 +0,0 @@ -

- The - gleam/list - standard library module contains functions for working with lists. A Gleam - program will likely make heavy use of this module, the various functions - serving as different types of loops over lists. -

- -

- map - makes a new list by running a function on each element in a list. -

-

- filter - makes a new list containing only the elements for which a function returns - true. -

-

- fold - combines all the elements in a list into a single value by running a function - left-to-right on each element, passing the result of the previous call to the - next call. -

-

- find - returns the first element in a list for which a function returns - True. -

-

- It's worth getting familiar with all the functions in this module when writing - Gleam code, you'll be using them a lot! -

diff --git a/src/content/chapter4_standard_library/lesson02_result_module/en.html b/src/content/chapter4_standard_library/lesson02_result_module/en.html new file mode 100644 index 0000000..4901afd --- /dev/null +++ b/src/content/chapter4_standard_library/lesson02_result_module/en.html @@ -0,0 +1,40 @@ +

+ The + gleam/result + standard library module contains functions for working with results. Gleam + programs will make heavy use of this module to avoid excessive nested case + expressions when calling multiple functions that can fail. +

+ +

+ map + updates a value held within the Ok of a result by calling a given function on + it. If the result is an error then the function is not called. +

+ +

+ try + runs a result returning function on the value held within an Ok of a result. + If the result is an error then the function is not called. This is useful for + chaining together multiple function calls that can fail, one after the other, + stopping at the first error. +

+ +

+ unwrap + extracts the success value from a result, or returning a default value if the + result is an error. +

+ +

+ Result functions are often used with pipelines to chain together multiple + calls to result returning functions. +

diff --git a/src/content/chapter4_standard_library/lesson02_result_module/text.html b/src/content/chapter4_standard_library/lesson02_result_module/text.html deleted file mode 100644 index 4901afd..0000000 --- a/src/content/chapter4_standard_library/lesson02_result_module/text.html +++ /dev/null @@ -1,40 +0,0 @@ -

- The - gleam/result - standard library module contains functions for working with results. Gleam - programs will make heavy use of this module to avoid excessive nested case - expressions when calling multiple functions that can fail. -

- -

- map - updates a value held within the Ok of a result by calling a given function on - it. If the result is an error then the function is not called. -

- -

- try - runs a result returning function on the value held within an Ok of a result. - If the result is an error then the function is not called. This is useful for - chaining together multiple function calls that can fail, one after the other, - stopping at the first error. -

- -

- unwrap - extracts the success value from a result, or returning a default value if the - result is an error. -

- -

- Result functions are often used with pipelines to chain together multiple - calls to result returning functions. -

diff --git a/src/content/chapter4_standard_library/lesson03_dict_module/en.html b/src/content/chapter4_standard_library/lesson03_dict_module/en.html new file mode 100644 index 0000000..f7eb879 --- /dev/null +++ b/src/content/chapter4_standard_library/lesson03_dict_module/en.html @@ -0,0 +1,40 @@ +

+ The + gleam/dict + standard library module defines Gleam's Dict type and functions + for working with it. A dict is a collection of keys and values which other + languages may call a hashmap or table. +

+ +

+ new + and + from_list + can be used to create new dicts. +

+ +

+ insert + and + delete + are used to add and remove items from a dict. +

+

+ Like lists, dicts are immutable. Inserting or deleting an item from a dict + will return a new dict with the item added or removed. +

+

+ Dicts are unordered! If it appears that the items in a dict are in a certain + order this is incidental and should not be relied upon. Any ordering may + change without warning in future versions or on different runtimes. +

diff --git a/src/content/chapter4_standard_library/lesson03_dict_module/text.html b/src/content/chapter4_standard_library/lesson03_dict_module/text.html deleted file mode 100644 index f7eb879..0000000 --- a/src/content/chapter4_standard_library/lesson03_dict_module/text.html +++ /dev/null @@ -1,40 +0,0 @@ -

- The - gleam/dict - standard library module defines Gleam's Dict type and functions - for working with it. A dict is a collection of keys and values which other - languages may call a hashmap or table. -

- -

- new - and - from_list - can be used to create new dicts. -

- -

- insert - and - delete - are used to add and remove items from a dict. -

-

- Like lists, dicts are immutable. Inserting or deleting an item from a dict - will return a new dict with the item added or removed. -

-

- Dicts are unordered! If it appears that the items in a dict are in a certain - order this is incidental and should not be relied upon. Any ordering may - change without warning in future versions or on different runtimes. -

diff --git a/src/content/chapter4_standard_library/lesson04_option_module/en.html b/src/content/chapter4_standard_library/lesson04_option_module/en.html new file mode 100644 index 0000000..0c66b25 --- /dev/null +++ b/src/content/chapter4_standard_library/lesson04_option_module/en.html @@ -0,0 +1,16 @@ +

+ Values in Gleam are not nullable, so the + gleam/option + standard library module defines Gleam's Option type, which can be + used to represent a value that is either present or absent. +

+ +

+ The option type is very similar to the result type, but it does not have an + error value. Some languages have functions return an option when there is no + extra error detail to give, but Gleam always uses result. This makes all + fallible functions consistent and removes any boilerplate that would be + required when mixing functions that use each type. +

diff --git a/src/content/chapter4_standard_library/lesson04_option_module/text.html b/src/content/chapter4_standard_library/lesson04_option_module/text.html deleted file mode 100644 index 0c66b25..0000000 --- a/src/content/chapter4_standard_library/lesson04_option_module/text.html +++ /dev/null @@ -1,16 +0,0 @@ -

- Values in Gleam are not nullable, so the - gleam/option - standard library module defines Gleam's Option type, which can be - used to represent a value that is either present or absent. -

- -

- The option type is very similar to the result type, but it does not have an - error value. Some languages have functions return an option when there is no - extra error detail to give, but Gleam always uses result. This makes all - fallible functions consistent and removes any boilerplate that would be - required when mixing functions that use each type. -

diff --git a/src/content/chapter5_advanced_features/lesson00_use/en.html b/src/content/chapter5_advanced_features/lesson00_use/en.html new file mode 100644 index 0000000..e295dda --- /dev/null +++ b/src/content/chapter5_advanced_features/lesson00_use/en.html @@ -0,0 +1,31 @@ +

+ Gleam lacks exceptions, macros, type classes, early returns, and a variety of + other features, instead going all-in with just first-class-functions and + pattern matching. This makes Gleam code easier to understand, but it can + sometimes result in excessive indentation. +

+

+ Gleam's use expression helps out here by enabling us to write code that uses + callbacks in an unindented style, as shown in the code window. +

+ +

+ The higher order function being called goes on the right hand side of the + <- operator. It must take a callback function as its final + argument. +

+

+ The argument names for the callback function go on the left hand side of the + <- operator. The function can take any number of arguments, + including zero. +

+

+ All the following code in the {} block becomes the + body of the callback function. +

+

+ This is a very capable and useful feature, but excessive application of + use may result in code that is unclear otherwise, especially to + beginners. Often using the regular function call syntax will result in more + approachable code! +

diff --git a/src/content/chapter5_advanced_features/lesson00_use/text.html b/src/content/chapter5_advanced_features/lesson00_use/text.html deleted file mode 100644 index e295dda..0000000 --- a/src/content/chapter5_advanced_features/lesson00_use/text.html +++ /dev/null @@ -1,31 +0,0 @@ -

- Gleam lacks exceptions, macros, type classes, early returns, and a variety of - other features, instead going all-in with just first-class-functions and - pattern matching. This makes Gleam code easier to understand, but it can - sometimes result in excessive indentation. -

-

- Gleam's use expression helps out here by enabling us to write code that uses - callbacks in an unindented style, as shown in the code window. -

- -

- The higher order function being called goes on the right hand side of the - <- operator. It must take a callback function as its final - argument. -

-

- The argument names for the callback function go on the left hand side of the - <- operator. The function can take any number of arguments, - including zero. -

-

- All the following code in the {} block becomes the - body of the callback function. -

-

- This is a very capable and useful feature, but excessive application of - use may result in code that is unclear otherwise, especially to - beginners. Often using the regular function call syntax will result in more - approachable code! -

diff --git a/src/content/chapter5_advanced_features/lesson01_use_sugar/en.html b/src/content/chapter5_advanced_features/lesson01_use_sugar/en.html new file mode 100644 index 0000000..e28c843 --- /dev/null +++ b/src/content/chapter5_advanced_features/lesson01_use_sugar/en.html @@ -0,0 +1,30 @@ +

+ The use expression is syntactic sugar for a regular function call + and an anonymous function. +

+ +

This code:

+
+use a, b <- my_function
+next(a)
+next(b)
+
+ +

Expands into this code:

+
+my_function(fn(a, b) {
+  next(a)
+  next(b)
+})
+
+ +

+ To ensure that your use code works and is as understandable as + possible, the right-hand-side ideally should be a function call rather than a + pipeline or other expression, which is typically more difficult to read. +

+ +

+ use is an expression like everything else in Gleam, so it can be + placed within blocks. +

diff --git a/src/content/chapter5_advanced_features/lesson01_use_sugar/text.html b/src/content/chapter5_advanced_features/lesson01_use_sugar/text.html deleted file mode 100644 index e28c843..0000000 --- a/src/content/chapter5_advanced_features/lesson01_use_sugar/text.html +++ /dev/null @@ -1,30 +0,0 @@ -

- The use expression is syntactic sugar for a regular function call - and an anonymous function. -

- -

This code:

-
-use a, b <- my_function
-next(a)
-next(b)
-
- -

Expands into this code:

-
-my_function(fn(a, b) {
-  next(a)
-  next(b)
-})
-
- -

- To ensure that your use code works and is as understandable as - possible, the right-hand-side ideally should be a function call rather than a - pipeline or other expression, which is typically more difficult to read. -

- -

- use is an expression like everything else in Gleam, so it can be - placed within blocks. -

diff --git a/src/content/chapter5_advanced_features/lesson02_todo/en.html b/src/content/chapter5_advanced_features/lesson02_todo/en.html new file mode 100644 index 0000000..4a2c433 --- /dev/null +++ b/src/content/chapter5_advanced_features/lesson02_todo/en.html @@ -0,0 +1,14 @@ +

+ The todo keyword is used to specify that some code is not yet + implemented. +

+

+ The as "some string" is optional, though you may wish to include + the message if you have more than one code block marked as + todo in your code. +

+

+ When used the Gleam compiler will print a warning to remind you the code is + unfinished, and if the code is run then the program will crash with the given + message. +

diff --git a/src/content/chapter5_advanced_features/lesson02_todo/text.html b/src/content/chapter5_advanced_features/lesson02_todo/text.html deleted file mode 100644 index 4a2c433..0000000 --- a/src/content/chapter5_advanced_features/lesson02_todo/text.html +++ /dev/null @@ -1,14 +0,0 @@ -

- The todo keyword is used to specify that some code is not yet - implemented. -

-

- The as "some string" is optional, though you may wish to include - the message if you have more than one code block marked as - todo in your code. -

-

- When used the Gleam compiler will print a warning to remind you the code is - unfinished, and if the code is run then the program will crash with the given - message. -

diff --git a/src/content/chapter5_advanced_features/lesson03_panic/en.html b/src/content/chapter5_advanced_features/lesson03_panic/en.html new file mode 100644 index 0000000..c54c217 --- /dev/null +++ b/src/content/chapter5_advanced_features/lesson03_panic/en.html @@ -0,0 +1,11 @@ +

+ The panic keyword is similar to the todo keyword, + but it is used to crash the program when the program has reached a point that + should never be reached. +

+

+ This keyword should almost never be used! It may be useful in initial + prototypes and scripts, but its use in a library or production application is + a sign that the design could be improved. With well designed types the type + system can typically be used to make these invalid states unrepresentable. +

diff --git a/src/content/chapter5_advanced_features/lesson03_panic/text.html b/src/content/chapter5_advanced_features/lesson03_panic/text.html deleted file mode 100644 index c54c217..0000000 --- a/src/content/chapter5_advanced_features/lesson03_panic/text.html +++ /dev/null @@ -1,11 +0,0 @@ -

- The panic keyword is similar to the todo keyword, - but it is used to crash the program when the program has reached a point that - should never be reached. -

-

- This keyword should almost never be used! It may be useful in initial - prototypes and scripts, but its use in a library or production application is - a sign that the design could be improved. With well designed types the type - system can typically be used to make these invalid states unrepresentable. -

diff --git a/src/content/chapter5_advanced_features/lesson04_externals/en.html b/src/content/chapter5_advanced_features/lesson04_externals/en.html new file mode 100644 index 0000000..8815fa7 --- /dev/null +++ b/src/content/chapter5_advanced_features/lesson04_externals/en.html @@ -0,0 +1,25 @@ +

+ Sometimes in our projects we want to use code written in other languages, most + commonly Erlang and JavaScript, depending on which runtime is being used. + Gleam's external functions and external types allow us to + import and use this non-Gleam code. +

+

+ An external type is one that has no constructors. Gleam doesn't know what + shape it has or how to create one, it only knows that it exists. +

+

+ An external function is one that has the @external attribute on + it, directing the compiler to use the specified module function as the + implementation, instead of Gleam code. +

+

+ The compiler can't tell the types of functions written in other languages, so + when the external attribute is given type annotations must be provided. Gleam + trusts that the type given is correct so an inaccurate type annotation can + result in unexpected behaviour and crashes at runtime. Be careful! +

+

+ External functions are useful but should be used sparingly. Prefer to write + Gleam code where possible. +

diff --git a/src/content/chapter5_advanced_features/lesson04_externals/text.html b/src/content/chapter5_advanced_features/lesson04_externals/text.html deleted file mode 100644 index 8815fa7..0000000 --- a/src/content/chapter5_advanced_features/lesson04_externals/text.html +++ /dev/null @@ -1,25 +0,0 @@ -

- Sometimes in our projects we want to use code written in other languages, most - commonly Erlang and JavaScript, depending on which runtime is being used. - Gleam's external functions and external types allow us to - import and use this non-Gleam code. -

-

- An external type is one that has no constructors. Gleam doesn't know what - shape it has or how to create one, it only knows that it exists. -

-

- An external function is one that has the @external attribute on - it, directing the compiler to use the specified module function as the - implementation, instead of Gleam code. -

-

- The compiler can't tell the types of functions written in other languages, so - when the external attribute is given type annotations must be provided. Gleam - trusts that the type given is correct so an inaccurate type annotation can - result in unexpected behaviour and crashes at runtime. Be careful! -

-

- External functions are useful but should be used sparingly. Prefer to write - Gleam code where possible. -

diff --git a/src/content/chapter5_advanced_features/lesson05_multi_target_externals/en.html b/src/content/chapter5_advanced_features/lesson05_multi_target_externals/en.html new file mode 100644 index 0000000..6e02d36 --- /dev/null +++ b/src/content/chapter5_advanced_features/lesson05_multi_target_externals/en.html @@ -0,0 +1,22 @@ +

+ Multiple external implementations can be specified for the same function, + enabling the function to work on both Erlang and JavaScript. +

+

+ If a function doesn't have an implementation for the currently compiled-for + target then the compiler will return an error. +

+

+ You should try to implement functions for all targets, but this isn't always + possible due to incompatibilities in how IO and concurreny works in Erlang and + JavaScript. With Erlang concurrent IO is handled transparently by the runtime, + while in JavaScript concurrent IO requires the use of promises or callbacks. + If your code uses the Erlang style it is typically not possible to implement + in JavaScript, while if callbacks are used then it won't be compatible with + most Gleam and Erlang code as it forces any code that calls the function to + also use callbacks. +

+

+ Libraries that make use of concurrent IO will typically have to decide whether + they support Erlang or JavaScript, and document this in their README. +

diff --git a/src/content/chapter5_advanced_features/lesson05_multi_target_externals/text.html b/src/content/chapter5_advanced_features/lesson05_multi_target_externals/text.html deleted file mode 100644 index 6e02d36..0000000 --- a/src/content/chapter5_advanced_features/lesson05_multi_target_externals/text.html +++ /dev/null @@ -1,22 +0,0 @@ -

- Multiple external implementations can be specified for the same function, - enabling the function to work on both Erlang and JavaScript. -

-

- If a function doesn't have an implementation for the currently compiled-for - target then the compiler will return an error. -

-

- You should try to implement functions for all targets, but this isn't always - possible due to incompatibilities in how IO and concurreny works in Erlang and - JavaScript. With Erlang concurrent IO is handled transparently by the runtime, - while in JavaScript concurrent IO requires the use of promises or callbacks. - If your code uses the Erlang style it is typically not possible to implement - in JavaScript, while if callbacks are used then it won't be compatible with - most Gleam and Erlang code as it forces any code that calls the function to - also use callbacks. -

-

- Libraries that make use of concurrent IO will typically have to decide whether - they support Erlang or JavaScript, and document this in their README. -

diff --git a/src/content/chapter5_advanced_features/lesson06_external_gleam_fallbacks/en.html b/src/content/chapter5_advanced_features/lesson06_external_gleam_fallbacks/en.html new file mode 100644 index 0000000..243c7ea --- /dev/null +++ b/src/content/chapter5_advanced_features/lesson06_external_gleam_fallbacks/en.html @@ -0,0 +1,13 @@ +

+ It's possible for a function to have both a Gleam implementation and an + external implementation. If there exists an external implementation for the + currently compiled-for target then it will be used, otherwise the Gleam + implementation is used. +

+

+ This may be useful if you have a function that can be implemented in Gleam, + but there is an optimised implementation that can be used for one target. For + example, the Erlang virtual machine has a built-in list reverse function that + is implemented in native code. The code here uses this implementation when + running on Erlang, as it is then available. +

diff --git a/src/content/chapter5_advanced_features/lesson06_external_gleam_fallbacks/text.html b/src/content/chapter5_advanced_features/lesson06_external_gleam_fallbacks/text.html deleted file mode 100644 index 243c7ea..0000000 --- a/src/content/chapter5_advanced_features/lesson06_external_gleam_fallbacks/text.html +++ /dev/null @@ -1,13 +0,0 @@ -

- It's possible for a function to have both a Gleam implementation and an - external implementation. If there exists an external implementation for the - currently compiled-for target then it will be used, otherwise the Gleam - implementation is used. -

-

- This may be useful if you have a function that can be implemented in Gleam, - but there is an optimised implementation that can be used for one target. For - example, the Erlang virtual machine has a built-in list reverse function that - is implemented in native code. The code here uses this implementation when - running on Erlang, as it is then available. -

-- cgit v1.2.3