✨ Concurrent programming for Gleam ✨
Taskle brings Elixir-style Task to Gleam.
import taskle
import gleam/io
pub fn main() {
let task = taskle.async(fn() { expensive_computation() })
case taskle.await(task, 5000) {
Ok(result) -> io.println("Got: " <> result)
Error(taskle.Timeout) -> io.println("Timed out")
Error(taskle.Crashed(_)) -> io.println("Task crashed")
}
}
- Async/await patterns inspired by Elixir's Task module
- True concurrency using BEAM processes
- Type-safe with compile-time guarantees
- Timeout support for all operations
- Task cancellation and resource management
- Parallel processing utilities
import taskle
import gleam/list
let numbers = list.range(1, 100)
case taskle.parallel_map(numbers, fn(n) { n * n }, 5000) {
Ok(squares) -> // Process results
Error(_) -> // Handle error
}
import taskle
let task = taskle.async(fn() { long_running_work() })
let result = taskle.await(task, 5000)
// Cancel if needed
taskle.cancel(task, 5000)
Contributions welcome! Run:
gleam test # Run tests
gleam format # Format code
.png)
