module, import, import ... as, and import type declarations.
module
Declares the logical module a source file belongs to.
Syntax
- Exactly one
moduledeclaration per.akfile. - Must be the first non-comment line.
- Segments use PascalCase; the full name uses dot separators.
- Multiple files may contribute to the same module.
- File paths are conventions only. The
moduledeclaration is authoritative.
import
Imports a module into the current file’s scope.
Syntax
- Must appear after
moduleand before declarations. - No wildcard imports.
- Importing a module makes its public members accessible by name.
import ... as
Imports a module under a local alias.
Syntax
- The alias is file-local. It does not create a new module identity.
- Alias must be unique within the file’s import scope.
- Alias identifiers follow the same casing rule as the module segment they replace.
import type
Imports a specific type by name, not a whole module.
Syntax
- Target must resolve to a type when metadata is available.
- Useful when the file only needs a specific type and not the whole module.
- Removes any ambiguity between module names and type names.
Ordering and placement
Every.ak file follows the same order:
1
module
Exactly one
module declaration.2
imports
Zero or more
import, import ... as, or import type statements.3
declarations
Types, functions, and other members.
Diagnostics
Common Forge diagnostics related to modules and imports:- Missing
moduledeclaration. moduledeclaration not first in the file.- Wildcard import used (not supported in v0.1).
- Alias already declared in this file.
- Type import target does not resolve to a type.
Related
Language syntax
Higher-level guide to modules and imports.
Command Catalog
Spec-style entries for every construct.
