Skip to content

Imports and modules

This page explains the mental model behind Incan modules and imports.

For details and tasks, use the split pages:

Key ideas

  • Incan supports two import styles (Python-style and Rust-style) that can be mixed freely.
  • Modules are discovered from the filesystem — there is no explicit mod declaration step.
  • Directories can act as modules; use mod.incn as the “main file” for a directory module when needed.
  • Common types and functions are available without imports via the prelude (see the reference page for the full list).

Coming from Python?

In Python, packages are driven by directory structure and __init__.py.
In Incan, directories are recognized automatically; you can use mod.incn when you need a directory/module entrypoint.

How module discovery works (conceptual)

When you import a local module, the compiler:

  1. Resolves the path (handling ., .., super, crate)
  2. Finds the .incn file (or mod.incn for directories)
  3. Parses and type-checks that file
  4. Makes its types and functions available in the importing file

Coming from Rust

In Rust, you typically need explicit module declarations before importing. In Incan, you generally “just import” and the compiler discovers modules automatically.

Coming from Python

In Python, packages are driven by directory structure and __init__.py. In Incan, directories are recognized as modules without __init__.py; use mod.incn when you need a directory entrypoint.

Where to go next