From a1c22e954299de5c823ec47cd2f633355764e3b2 Mon Sep 17 00:00:00 2001
From: Dimitrii Dulgher
Gleam code is organized into units called modules. A module is a
bunch of definitions (of types, functions, etc.) that seem to belong together.
- For example, the
All gleam code is in some module or other, whose name comes from the
- name of the file it's in. For example,
For code in one module to access code in another module, we import it using
the
The gleam/io
module contains a variety of functions
- for printing, like println
.
+ For example, the
+
+ gleam/io
+
+ module contains a variety of functions for printing, like
+
+ println
+ .
gleam/io
is in a file
- called io.gleam
in a directory called gleam
.
+ name of the file it's in. For example,
+
+ gleam/io
+
+ is in a file called io.gleam
in a directory called gleam
.
import
keyword, and the name used to refer to it is the last
- part of the module name. For example, the gleam/io
module is
- referred to as io
once imported.
+ part of the module name. For example, the
+
+ gleam/io
+
+ module is referred to as io
once imported.
as
keyword can be used to refer to a module by a different
- name. See how the gleam/string
module is referred to as
- text
here.
+ name. See how the
+
+ gleam/string
+
+ module is referred to as text
here.
io.println("Hello!")
.
+
+ io.println("Hello!")
+ .
It is also possible to specify a list of functions to import from a module in diff --git a/src/content/chapter0_basics/lesson04_type_checking/en.html b/src/content/chapter0_basics/lesson04_type_checking/en.html index a9316c4..0cffcbe 100644 --- a/src/content/chapter0_basics/lesson04_type_checking/en.html +++ b/src/content/chapter0_basics/lesson04_type_checking/en.html @@ -3,12 +3,22 @@ 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.
+ 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
+ To fix the code change the code to call the
+
+ io.debug
+
function instead, as it will print a value of any type.
diff --git a/src/content/chapter0_basics/lesson05_ints/en.html b/src/content/chapter0_basics/lesson05_ints/en.html index 252496a..41793d5 100644 --- a/src/content/chapter0_basics/lesson05_ints/en.html +++ b/src/content/chapter0_basics/lesson05_ints/en.html @@ -9,9 +9,9 @@ JavaScript's 64 bit floating point numbers,
- The
- gleam/int
+ The
+
+ gleam/int
+
standard library module contains functions for working with ints.
- The
- gleam/float
+ The
+
+ gleam/float
+
standard library module contains functions for working with floats.
\u{xxxxxx}
- unicode codepoint
- The gleam/string
+ The
+
+ gleam/string
+
standard library module contains functions for working with strings.
- The gleam/bool
+ The
+
+ gleam/bool
+
standard library module contains functions for working with bools.
Like functions types can be referred to in a qualified way by putting
- the imported module name and a dot before the type name. For example,
- bytes_builder.BytesBuilder
+ the imported module name and a dot before the type name. For example,
+
+ bytes_builder.BytesBuilder
+
Types can also be imported in an unqualified way by listing them in diff --git a/src/content/chapter0_basics/lesson16_blocks/en.html b/src/content/chapter0_basics/lesson16_blocks/en.html index bc82e39..b19c586 100644 --- a/src/content/chapter0_basics/lesson16_blocks/en.html +++ b/src/content/chapter0_basics/lesson16_blocks/en.html @@ -7,8 +7,11 @@ Any variables assigned within the block can only be used within the block.
- Try uncommenting io.debug(degrees)
to see the compile error from
- trying to use a variable that is not in scope.
+ Try uncommenting
+
+ 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 diff --git a/src/content/chapter0_basics/lesson17_lists/en.html b/src/content/chapter0_basics/lesson17_lists/en.html index c29758a..84f88f3 100644 --- a/src/content/chapter0_basics/lesson17_lists/en.html +++ b/src/content/chapter0_basics/lesson17_lists/en.html @@ -2,9 +2,11 @@ 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
+
+ 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)
.
diff --git a/src/content/chapter2_flow_control/lesson07_list_recursion/en.html b/src/content/chapter2_flow_control/lesson07_list_recursion/en.html index d2194e3..9f158d8 100644 --- a/src/content/chapter2_flow_control/lesson07_list_recursion/en.html +++ b/src/content/chapter2_flow_control/lesson07_list_recursion/en.html @@ -1,8 +1,8 @@
- While it is more common to use functions in the
- gleam/list
+ While it is more common to use functions in the
+
+ gleam/list
+
module to iterate across a list, at times you may prefer to work
with the list directly.
Here a generic Option
type is defined, which is used to represent
- a value that is either present or absent. This type is quite useful! The
- gleam/option
module defines it so you can use it in your Gleam
- projects.
+ a value that is either present or absent. This type is quite useful! The
+
+ gleam/option
+
+ module defines it so you can use it in your Gleam projects.
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.
+ 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.
- All of the modules imported so far in this guide, such as
- gleam/io
, are from the standard library.
+ 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 diff --git a/src/content/chapter4_standard_library/lesson01_list_module/en.html b/src/content/chapter4_standard_library/lesson01_list_module/en.html index 7451b10..9c6b953 100644 --- a/src/content/chapter4_standard_library/lesson01_list_module/en.html +++ b/src/content/chapter4_standard_library/lesson01_list_module/en.html @@ -1,38 +1,38 @@
The
- gleam/list
+
+ 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
+
+ map
+
makes a new list by running a function on each element in a list.
- filter
+
+ filter
+
makes a new list containing only the elements for which a function returns
true.
- fold
+
+ 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
+
+ find
+
returns the first element in a list for which a function returns
True
.
The
- gleam/result
+
+ 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
+
+ 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
+
+ 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,
@@ -27,9 +27,9 @@
- unwrap
+
+ unwrap
+
extracts the success value from a result, or returning a default value if the
result is an error.
- new
+
+ new
+
and
- from_list
+
+ from_list
+
can be used to create new dicts.
- insert
+
+ insert
+
and
- delete
+
+ delete
+
are used to add and remove items from a dict.
diff --git a/src/content/chapter4_standard_library/lesson04_option_module/en.html b/src/content/chapter4_standard_library/lesson04_option_module/en.html index 0c66b25..699b5bd 100644 --- a/src/content/chapter4_standard_library/lesson04_option_module/en.html +++ b/src/content/chapter4_standard_library/lesson04_option_module/en.html @@ -1,10 +1,13 @@
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.
+
+ gleam/option
+
+ standard library module defines Gleam's
+
+ Option
+
+ type, which can be used to represent a value that is either present or absent.
diff --git a/src/tour.gleam b/src/tour.gleam index 5dc662d..be26ffa 100644 --- a/src/tour.gleam +++ b/src/tour.gleam @@ -56,10 +56,17 @@ const home_html = "
The tour is interactive! The code shown is editable and will be compiled and
- evaluated as you type. Anything you print using io.println
or
- io.debug
will be shown in the bottom section, along with any
- compile errors and warnings. To evaluate Gleam code the tour compiles Gleam to
- JavaScript and runs it, all entirely within your browser window.
+ evaluated as you type. Anything you print using
+
+ io.println
+
+ or
+
+ io.debug
+
+ will be shown in the bottom section, along with any compile errors and warnings.
+ To evaluate Gleam code the tour compiles Gleam to JavaScript and runs it,
+ all entirely within your browser window.
If at any point you get stuck or have a question do not hesitate to ask in diff --git a/static/css/root.css b/static/css/root.css index 57e7b43..b65b5a8 100644 --- a/static/css/root.css +++ b/static/css/root.css @@ -48,10 +48,6 @@ a { text-decoration-color: var(--color-link-decoration); } -a code { - color: inherit; -} - /* * Nav bar & Nav links */ -- cgit v1.2.3