### Gleam OTP Actor Example Source: https://hexdocs.pm/gleam_otp/v1.2.0/gleam_otp/index Demonstrates the creation and usage of a simple actor in Gleam using the OTP library. It shows how to start an actor, send messages, and receive replies, ensuring type safety and compatibility with Erlang's OTP. ```gleam import gleam/erlang/process.{type Subject} import gleam/otp/actor pub fn main() { // Start an actor let assert Ok(actor) = actor.new(0) |> actor.on_message(handle_message) |> actor.start // Send some messages to the actor actor.send(actor.data, Add(5)) actor.send(actor.data, Add(3)) // Send a message and get a reply assert actor.call(actor.data, waiting: 10, sending: Get) == 8 } pub fn handle_message(state: Int, message: Message) -> actor.Next(Int, Message) { case message { Add(i) -> { let state = state + i actor.continue(state) } Get(reply) -> { actor.send(reply, state) actor.continue(state) } } } pub type Message { Add(Int) Get(Subject(Int)) } ``` -------------------------------- ### Add gleam_otp Dependency Source: https://hexdocs.pm/gleam_otp/v1.2.0/gleam_otp/index Installs the gleam_otp library version 1.0.0 into the current Gleam project. This command is used to add the library as a dependency for future use in the project. ```bash gleam add gleam_otp@1 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.