Module System

Comprehensive guide to Modules in Linea

Importing Built-In Modules

Linea modules are imported once and used via namespace calls.

Example

import ml
import sql
import system

func main() -> any {
    var db = sql::open("app.db")
    var cwd = system::cwd()
    display cwd
    display db
    return 0
}

Local Reusable Modules

Keep custom modules inside your local `libs/` folder and import them directly.

import greeter

func main() -> any {
    greeter::hello("Developer")
    return 0
}

Selective Imports and Validation

Use selective imports to import specific exported symbols, and the compiler validates symbol names early.

import math { abs, max }

func main() -> any {
    display math::abs(-5)
    display math::max(7, 9)
    return 0
}

If you import a symbol that is not exported by the module, compilation fails with a clear error and available symbol preview.