blob: 50862ec5c611cf7ffbd8b6c08b59d413ac765880 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
<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" target="_blank">
<code>gleam/io</code>
</a>
module contains a variety of functions for printing, like
<a href="https://hexdocs.pm/gleam_stdlib/gleam/io.html#println" target="_blank">
<code>println</code>
</a>.
</p>
<p>
All gleam code is in <i>some</i> module or other, whose name comes from the
name of the file it is in. For example,
<a href="https://hexdocs.pm/gleam_stdlib/gleam/io.html" target="_blank">
<code>gleam/io</code>
</a>
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, the
<a href="https://hexdocs.pm/gleam_stdlib/gleam/io.html" target="_blank">
<code>gleam/io</code>
</a>
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
<a href="https://hexdocs.pm/gleam_stdlib/gleam/string.html" target="_blank">
<code>gleam/string</code>
</a>
module is referred to as <code>text</code> here.
</p>
|