Modules & Imports — Mapanare

Organizing code with imports, exports, and visibility.

Imports

import std::math
import std::io { read_file, write_file }
import std::http::client { get, post }
import helpers          // sibling file
import utils::validators // nested directory

File-Based Resolution

Module paths map to files: import math resolves to math.mn, import utils::helpers resolves to utils/helpers.mn.

Circular Import Detection

The compiler detects circular imports and produces a clear error message.

Exports & Visibility

export fn process(data: List<Int>) -> List<Int> { return data |> map(x => x * 2) }
pub fn api_function() -> String { return helper() }

The pub keyword marks definitions as public. Without it, items are private to their file.

Standard Library Modules

std::math — sqrt, pow, abs, clamp, trig, statistics. std::io — File I/O, stdin/stdout. std::http — HTTP client/server agents. std::time — Timers, intervals, delay. std::text — String manipulation. std::log — Structured logging.