Skip to Content

Module

module is the file-level organizational unit and visibility boundary. Each file carries at most one module declaration, and it must come first in the file. A file without a declaration falls into the default module Main (implicitly partial).

File-Header Declaration

module App; func Describe() -> string => "single-file module"; func main() -> int { print(App.Describe(), Describe()); return 0; }
single-file module single-file module

Within its own module, a member is reachable both by qualified name (App.Describe()) and by bare name. A module name is a single-segment Unicode identifier; dots are not allowed, and neither is a leading digit.

Same-Package Modules Need No Prefix

Modules within the same package access each other’s members directly through the module name prefix, with no import at all:

// lib.ms module Lib; public func Hello() -> string => "from Lib"; public val Answer: int = 42;
// main.ms module Main; func main() -> int { print(Lib.Hello(), Lib.Answer); return 0; }
from Lib 42

Bare names require an import; without one, the prefix always works.

Closed by Default, partial to Merge

A module’s source lives in a single file by default. Two files cannot declare the same module name; to merge across files, both sides must declare partial module:

// pack-api.ms partial module Pack; public func Api() -> string => "available in the package";
// pack-main.ms partial module Pack; func main() -> int { print(Api()); return 0; }

After the merge, both files belong to the same module, and internal members are visible to each other.

Same-Name Functions

When two modules each declare a function with the same name, the call must target the module exactly:

// a.ms module A; public func Go() -> string => "A ran";
// b.ms module B; public func Go() -> string => "B ran";
// main.ms import A.*; import B.*; print(A.Go(), B.Go());
A ran B ran

Notes

  • func main may appear in only one module per package; with a main in each of two modules, mush run cannot pick an entry point;
  • circular imports between same-package modules are legal; only package-level dependency cycles are forbidden;
  • extern module Name; is the reference surface for host-injected modules. It is legal only inside built-in packages and cannot be declared in user files — see Host Boundary.
Last updated on October 11, 2026