Modules & Packages
Aria's module system is filesystem-independent — multiple files can contribute to the same module. Imports are concise and unambiguous.
Module Declaration
Every file declares which module it belongs to with mod:
// src/auth/login.aria
mod auth
fn login(creds: Credentials) -> Session ! AuthError {
...
}
// src/auth/register.aria
mod auth
fn register(info: UserInfo) -> User ! AuthError {
...
}
// Both files contribute to the same 'auth' module Imports
// Import a module
use auth
// Import multiple modules
use net, json, time
// Import specific items
use auth.{login, register}
// Import alias — refer to the module by a different name
use crypto as c
c.sha256(data)
// Rename a specific import
use crypto.sha256 as sha Visibility
Declarations are public by default within a module. Use pub to export symbols for access from other modules. The compiler enforces visibility — accessing a private symbol from another file produces an E0704 error.
Resolution Order
When you reference a name, Aria resolves it in this order:
- Tier 0 builtins —
println,Option,Result, etc. - Local modules — your project's
moddeclarations - Dependencies — packages from
aria.toml - Tier 1 stdlib —
io,net,json, etc.
Project Manifest (aria.toml)
[project]
name = "myapp"
version = "0.1.0"
aria = "0.1"
entry = "src/main.aria"
[deps]
http = "1.2"
postgres = "0.8"
redis = "1.0"
[dev-deps]
mock = "0.3" Multi-File Projects
myapp/
├── aria.toml
├── src/
│ ├── main.aria # mod main, entry point
│ ├── auth/
│ │ ├── login.aria # mod auth
│ │ └── register.aria # mod auth
│ ├── models/
│ │ ├── user.aria # mod models
│ │ └── order.aria # mod models
│ └── handlers/
│ ├── api.aria # mod handlers
│ └── web.aria # mod handlers // src/main.aria
mod main
use auth, handlers
entry {
auth.initialize()
handlers.startServer(":8080")
}