aboutsummaryrefslogtreecommitdiff
path: root/src/content/chapter0_basics/lesson02_modules/en.html
blob: d26977df81f78b1607e5b36aedbf13ce3e229cfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<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 <code>gleam/io</code> 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, 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 referred to as
  <code>text</code> here.
</p>