6.2 Effects
| Effect | What it permits |
|---|---|
io | files, processes, environment variables, stdout/stderr |
net | network: rpc, streams, actors, cluster, HTTP |
db | ORM, std.kv, the built-in storage |
time | reading clocks, sleep, timers |
rand | random numbers |
- The set of effects is written after the return type, comma-separated:
-> User | NotFound net, db.pureis the empty set. - A function MAY call only functions whose effects are included in its set. A violation is a compile error.
- The effects of private functions are inferred.
pub(api)functions MUST declare their effects explicitly (orpure). - Effect polymorphism:
fn map<T, U, effect F>(xs: List<T>, f: fn(T) -> U F) -> List<U> F. - A panic is not an effect and is possible in any function.
- A function with any of the effects
io,net,db,timeis suspendable: it may yield the thread to the scheduler (§8.2).pureandrandfunctions do not suspend.
Related diagnostics
See also
Source: docs/spec/oxl-standard.en.md