Modules
Every .zyn file is a module. A program can be split over many files, which use each other with import.
#Importing a file
Say a project has a file geometry.zyn:
data Point(x: Float, y: Float)
fn distance(a: Point, b: Point): Float = sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2))
let origin = Point(0.0, 0.0)import geometry brings in the module; its names are used through it:
import geometry
println(geometry.distance(geometry.origin, geometry.Point(3.0, 4.0)))5.0
Or import names directly, in braces:
import geometry.{Point, distance, origin}
println(distance(origin, Point(6.0, 8.0)))10.0
Everything at a module's top level can be imported: functions, lets and vars, data types, enums (with their cases), classes and interfaces. Types are imported by name, like Point above.
#Folders
Module names follow folders, starting from the project folder: the folder of the file you run. import text.format loads text/format.zyn, from whichever file the import is in:
fn title(s: String): String = s.split(" ").map { w -> if w.isEmpty() { w } else { w[0].uppercase().toString() + w.substring(1) } }.joinToString(" ")
fn box(s: String): String {
let line = "-".repeat(s.length + 4)
return "{line}\n| {s} |\n{line}"
}import text.format.{title, box}
println(box(title("hello from a module")))----------------------- | Hello From A Module | -----------------------
#Imports come first
Imports are at the top of a file, before anything else. A file can be imported by many others; it's loaded and run once, the first time it's imported, and every importer sees the same values.
Two files can't import each other in a circle: Zyn reports it as an error. Move what they share into a third file.
#A typical layout
A project keeps its code in src/, where imports start:
my-app/
├── build.zyn ← the project and its libraries
├── src/
│ ├── main.zyn ← zyn run
│ ├── model/
│ │ ├── user.zyn ← import model.user.{User}
│ │ └── order.zyn ← import model.order
│ └── util/
│ └── text.zyn ← import util.text
└── resources/ ← copied into the jar by zyn build#Java classes
The same import brings in Java classes, when there's no .zyn file at that path:
import java.util.UUID
import java.time.LocalDate
println(UUID.fromString("123e4567-e89b-12d3-a456-426614174000").version())
println(LocalDate.of(2026, 1, 31).plusDays(1))1 2026-02-01
See Java interop.