LogoChemical Docs
Ctrl+K

chemical.mod

The chemical.mod file is the fundamental unit of project configuration in Chemical. While build.lab is for complex build orchestration, chemical.mod is used to define simple modules and their immediate dependencies.

Structure of chemical.mod

A typical chemical.mod consists of three main parts: module name, source directories, and imports.

# Define the name of this module
module my_module

# Specify where the .ch source files are located
source "src"

# Import other modules this project depends on
import std
import fs
import my_other_lib

Keyword Reference

No Top-Level Imports

One of the unique features of Chemical is that you never write import at the top of a .ch file. If you have two files a.ch and b.ch in the same module, they can see each other's public symbols automatically. If you import std in chemical.mod, all files in your project can see std::string, std::vector, etc., immediately.