Skip to content
LogoLogo

Imports

import brings in another file's declarations. A plain import makes names available directly. as keeps them behind a prefix.

(* A plain import brings names in directly. `as` keeps them behind a prefix. *)
import "./lib/math";
import "./lib/fees" as Fees;
 
storage is record {
  fee : Fees.BasisPoints;
  cap : uint;
}
 
external function configure(const fee : Fees.BasisPoints; const cap : uint) is {
  storage.fee := fee;
  storage.cap := cap;
}
 
external view function charge(const amount : uint) : uint is
  min(Fees.apply(storage.fee, amount), storage.cap)
  • Imports come before every other declaration. A path names a module, without .lithe, relative to the importing file unless it starts with std/.
  • A file sees what it declares and what the files it imports declare, never what those files import in turn.
  • private declarations, like unused, are invisible to importers.