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)pure function min(const a : uint; const b : uint) : uint is {
var smaller : uint := b;
if a < b then { smaller := a; }
} with smallertype BasisPoints is uint16;
pure function apply(const fee : BasisPoints; const amount : uint) : uint is
amount * uint(uint16(fee)) / 10_000
(* `private` stays inside this file. *)
private pure function unused() : uint is
0- Imports come before every other declaration. A path names a module, without
.lithe, relative to the importing file unless it starts withstd/. - A file sees what it declares and what the files it imports declare, never what those files import in turn.
privatedeclarations, likeunused, are invisible to importers.

