Manuscript Documentation
v0.1.0

Standard imports#

Most standard names need an explicit import. An imported function or type follows the same scope rules as one declared in your own module.

Manuscript
import {filesystem, FileSystemError} from "@std/fs.ms"

Import a type outside the prelude when naming it in an annotation or constructor. A type inferred from a return value needs no separate import unless you name it in source. The API reference lists each module’s declarations.

Names and identity#

Bool, Int, Float, String, Unit, Never, Equal, Hashable, Optional, Result, Error, List, Map, Set, CollectionError, ListEntry, MapEntry, and MissingValue are available through the prelude. The some, none, ok, and error cases and the cases of CollectionError and MissingValue are available through their prelude types. Every other standard name comes from an explicit @std/… import. Importing one name does not expose other names from that module; wildcard imports are unsupported.

@std is the reserved directory supplied by the compiler distribution. Standard identities are independent of its installation path. Application declarations and imports may shadow the prelude data types and Error; matching a standard spelling does not give a type standard behavior. Equal and Hashable retain fixed identities. See the canonical module scope rules .

Migrating prelude imports#

Explicit standard imports of the source-backed prelude declarations above now fail with MS2003. Delete a singleton import; in a grouped import, remove only those names and keep unrelated APIs such as ListBuilder, range, or ErrorCategory. The editor offers a removal quick fix. Application imports, including project aliases to same-named application types, keep their ordinary meaning.

CollectionError is now visible in every module. If another visible alternative also defines InvalidInput, LimitExceeded, or OutOfRange, qualify expression constructors as CollectionError.OutOfRange or OtherError.OutOfRange. The same rule applies to MissingValue.Missing and another visible type’s Missing case. Match patterns continue to select cases from their scrutinee type.

Syntax that uses standard types#

  • Bracket list literals use the standard List from the prelude.
  • A d-suffixed number needs Decimal from @std/decimal.ms.
  • try recognizes the standard Result type.
  • with uses the standard Closeable implementation or an interface declaring the exact close() -> Unit operation. Using an already-typed resource does not require an otherwise unused Closeable import.

Application code cannot add methods or implementations to intrinsic or standard-library types. Source types can implement standard interfaces according to the implementation rules .

Types and service values#

Importing FileSystem supplies a type. Calling the imported filesystem() function obtains the current execution’s filesystem service. The same distinction applies to clocks, network access, and process services. Continue with external services .