Manuscript Documentation
v2026.12.0

Imports and exports#

Each .ms file is a module with its own boundary. export makes a declaration available to other files; import brings in one exported declaration. The resolved file path identifies the module. There is no module declaration, wildcard import, or cyclic dependency.

Names and declaration order#

Import several symbols with a nonempty comma-separated list on one line: import Name, OtherName from "./module.ms". A single name (import Name from "./module.ms") works the same way. To wrap across lines, parenthesize the list (import (Name, OtherName) from "./module.ms"); a trailing comma is allowed there. Braces are rejected, and duplicate names and collisions are errors.

ms fmt sorts the names. It writes a list that fits on one line bare, and wraps a wider list into the parenthesized form, one name per line.

One statement can import from several modules: parenthesize comma-separated names from "path" clauses.

Manuscript
import (
    Deque from "@std/collections/deque.ms",
    Queue from "@std/collections/queue.ms",
    PathParts from "@std/os/path.ms",
)

A group means the same as the separate imports it replaces. Inside the parentheses, from after the names starts a clause; ) after the names is the single-module form above. ms fmt merges consecutive imports into one group with one clause per module, names sorted. Clauses are ordered by path within three sections separated by a blank line: public @std/ modules, @std/internal/ modules, then everything else. A clause wider than 88 columns puts one name on each line, and a single clause that fits stays a bare import. An import with a comment is left as written.

Types, interfaces, functions, and imports share one module namespace. Duplicates, collisions between an import and a declaration, and overloads are rejected.

Two modules that export the same name (for example parse in @std/data/csv.ms and @std/data/toml.ms) cannot both be imported under that name into one module. Rename an import with as; the new name is the only name this module sees for it:

Manuscript
import parse from "@std/data/csv.ms"
import parse as parse_toml from "@std/data/toml.ms"

as works in every import form (bare, parenthesized, and grouped clauses). The renamed name follows the same rules as any import name: it must not collide with another import, a declaration, or an intrinsic name.

Declaration order does not matter: names and signatures are collected before bodies are checked, so forward references and mutual recursion work. Type layout cycles follow the recursive data rule .

The intrinsic core type names are Bool, Int, Float, String, Void, and Never. The standard interfaces Equal, Comparable, Hashable, and Clonable also have fixed identities in the prelude. Declarations, imports, and type parameters cannot redefine these. A local may reuse a module-level name, but it cannot shadow another local or parameter unless the new name starts with _; see scope and shadowing . A value name cannot be used as a type.

Prelude declarations: Optional, Result, Error, List, Map, Set, ListEntry, MapEntry, print, ok_or, and null, ok, error. A present optional is a plain value in a T? position; there is no some(...) constructor. Qualify a Result case when its types need context, for example Result[Int, Error].ok(3). A module declaration or import reusing a prelude name is rejected (“reuses a prelude name”); locals, parameters, and type parameters may shadow them.

An explicit import of a prelude declaration, including Equal and Hashable, is rejected with MS2003; remove the import. Other exports of the same standard modules, such as collection builders, still need explicit imports.

Other standard declarations (Decimal, Bytes, builders, Closeable, runtime and host APIs) are imported from @std; see the API reference .

Unqualified case shorthand applies only when lexical lookup finds no binding of that name. Candidates are cases of visible enum types (prelude, declared, or imported by name); exactly one must match, and an expected type cannot choose. Type.Case selects explicitly. Match patterns use the scrutinee type (pattern matching ).

Namespace imports, re-exports, and wildcards have no syntax. A dotted type path is not a namespace; import each type by name. Module-level statements and var are rejected. A module-level := declares a constant .

Constants#

A module-level := names a value usable throughout the module; add export to share it.

Manuscript
export MAX_ITEMS := 100
NAMES List[String] := ["Ada", "Grace"]
LIMIT := MAX_ITEMS * 2

fn is_full(count Int) Bool {
    return count >= LIMIT
}

The type comes from the annotation or initializer. The initializer is a constant expression: literals, constant f text, operators, list and map literals, payloadless cases (null, State.Ready), and other constants. Calls, constructors, functions, and match are not allowed. Self-dependent constants are rejected.

A constant has no storage or initialization order; each use evaluates the initializer in place, so a list constant is always fresh. Locals and parameters shadow it. Constants cannot be assigned, and main must be a function.

A visible contract#

src/domain/customers.ms exports a nominal identifier type:

Manuscript
export type CustomerId {
    value String
}

src/main.ms imports it:

Manuscript
import CustomerId from "./domain/customers.ms"

Relative imports resolve from the importing file’s directory. Paths include .ms and name a file exactly; there is no directory or extension lookup.

Public signature closure#

An exported function, data type, or contract cannot expose an internal nominal type through a parameter, result, field, case payload, generic bound, or operation signature, transitively. Imported exported types may appear without being re-exported. Generic parameters are not private declarations.

Manuscript
type PrivateToken {
    value String
}

// Rejected: callers cannot name the internal result type.
export fn issue() PrivateToken {
    return PrivateToken("token")
}

Exporting a type exposes every field and its constructor; an enum, every case and payload; an interface, every operation. export opaque type hides fields and export opaque enum hides enum cases outside the declaring file; selective per-field visibility is unsupported (public data surfaces ).

A method declared in its type’s module is available wherever the type is used; a module cannot add methods to an imported type. See the coherence and visibility rules .

Standard-library imports#

Manuscript
import Queue from "@std/collections/queue.ms"

@std is always available, needs no [aliases] entry, and cannot be overridden. An import brings in only the named declaration, not the other types its signatures mention (Result, for example, comes from the prelude). Import each operation you call, such as read_file from @std/os/fs.ms.

Optional aliases#

A project-root ms.toml can define file and directory aliases. With @domain mapped to ./src/domain and @customers to ./src/domain/customers.ms, either import selects the same type:

Manuscript
import CustomerId from "@domain/customers.ms"
Manuscript
import CustomerId from "@customers"

Aliases change only how a path is written; module identity follows the resolved file.

Missing files, unknown aliases, missing exports, and cycles are compile errors. See project configuration .

See source structure and boundary contracts .