blob: ebfd8bc3f67c566e8f648f43f898b4a9b1421db7 (
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
|
<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>
|