# IO Module: Ergonomic Effect Creation
The IO module provides convenient helpers for creating Effects from I/O operations.
## Core Functions
### IO::read - Read-only operations
For queries that don't modify state:
```rust
use stillwater::IO;
struct Database { /* ... */ }
});
```
### IO::write - Mutating operations
For operations that modify state (uses interior mutability):
```rust
use stillwater::IO;
use std::sync::{Arc, Mutex};
struct Cache {
data: Arc<Mutex<HashMap<u64, String>>>,
}
Ok(())
});
```
### IO::execute - Async operations
For async I/O:
```rust
use stillwater::IO;
});
```
## Environment Pattern
IO uses `AsRef<T>` for automatic dependency extraction:
```rust
struct AppEnv {
db: Database,
cache: Cache,
}
impl AsRef<Database> for AppEnv {
fn as_ref(&self) -> &Database { &self.db }
}
impl AsRef<Cache> for AppEnv {
fn as_ref(&self) -> &Cache { &self.cache }
}
// Type inference extracts the right dependency
```
## Examples
See full examples in [examples/io_patterns.rs](../../examples/io_patterns.rs).
## Next Steps
- Learn about [Helper Combinators](06-helper-combinators.md)
- Back to [Effects guide](03-effects.md)