IO
Console and filesystem I/O, tracked with the `IO` effect.
IO
The IO effect is the most practical effect to teach because it appears in simple programs, shell-facing examples, and compiler onboarding. It is also the easiest place to show what Sounio means by “effects belong in the signature.”
Current contract
- Console output belongs under
with IOin public examples. - Calling an
IO-using helper from a pure function should be documented as a type or effect boundary mistake, not as harmless style. - The checked artifact and the docs both treat
IOas the most obvious example of explicit effect tracking.
IO boundary
fn read_name() -> string with IO {
read_line()
}
fn main() with IO {
println("Enter your name:")
let name = read_name()
println(name)
}
Repo map
self-hosted/io/stdio.sio,self-hosted/io/file_read.sio, andself-hosted/io/file_write.sioare the obvious places to inspect host-facing I/O work in the self-hosted tree.self-hosted/check/effects.siois where the checker should make sure those operations do not appear in pure contexts by accident.examples/io/and small fixtures underexamples/are the best places to look for current user-facing examples.
Guidance
- Put
IOat the program boundary and keep the rest of the pipeline pure where possible. - If a docs example reads from the console or filesystem, show the effect clause explicitly instead of implying it.
- Use
checkas the first proof that the boundary is declared correctly.