diff options
author | Louis Pilfold <louis@lpil.uk> | 2024-03-26 11:36:11 +0000 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2024-03-26 11:36:11 +0000 |
commit | 04ec0d86c8b43d1cca48adc937b3e596a10577a1 (patch) | |
tree | 8624097a135e0e879588279eed82c4c2f82bfbab /src/content/chapter0_basics/lesson02_modules/en.html | |
parent | 9250d4324073874d393282c941f9981ce2686680 (diff) | |
download | tour-04ec0d86c8b43d1cca48adc937b3e596a10577a1.tar.gz tour-04ec0d86c8b43d1cca48adc937b3e596a10577a1.zip |
Improve introduction of modules and imports
Thanks @RyanBrewer317!
Diffstat (limited to 'src/content/chapter0_basics/lesson02_modules/en.html')
-rw-r--r-- | src/content/chapter0_basics/lesson02_modules/en.html | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/content/chapter0_basics/lesson02_modules/en.html b/src/content/chapter0_basics/lesson02_modules/en.html new file mode 100644 index 0000000..ebfd8bc --- /dev/null +++ b/src/content/chapter0_basics/lesson02_modules/en.html @@ -0,0 +1,26 @@ +<p> + Gleam code is organized into units called <em>modules</em>. A module is a + bunch of definitions (of types, functions, etc.) that seem to belong together. + For example, the + <a href="https://hexdocs.pm/gleam_stdlib/gleam/io.html"> + <code>gleam/io</code> + </a> + module contains a variety of functions for printing, like + <code>println</code>. +</p> +<p> + All gleam code is in <i>some</i> module or other, whose name comes from the + name of the file it's in. For example, <code>gleam/io</code> is in a file + called <code>io.gleam</code> in a directory called <code>gleam</code>. +</p> +<p> + For code in one module to access code in another module, we import it using + the <code>import</code> keyword, and the name used to refer to it is the last + part of the module name. For example, to import the + <code>gleam/io</code> module is referred to as <code>io</code> once imported. +</p> +<p> + The <code>as</code> keyword can be used to refer to a module by a different + name. See how the <code>gleam/string</code> module is be referred to as + <code>text</code> here. +</p> |