Std. ActorBehavior
(Cure Standard Library v0.37.2)
View Source
Shared compile-time substrate for actor-like abstractions.
Both public actor declarations and constrained actors such as fsm,
supervisor, and application supply ordinary checked declarations here;
these builders emit the final direct BEAM behaviour module without
introducing a runtime container or dispatcher.
Examples
use Std.ActorBehavior
use Std.Syntax
actor_module(SAtom(:counter_actor), variable("Int"), [])
state_machine_module(SAtom(:door_fsm), [])
Summary
Functions
Emit a :gen_server behaviour module with typealias State = state_type
and standard OTP imports (Std.Otp, Std.ExitReason).
Emit a :gen_server behaviour module without a State type alias, used
by state-polymorphic or stateless actor definitions.
Emit an :application behaviour module with standard OTP and application
imports (Std.Otp, Std.App, Std.ExitReason).
Emit an isolated BEAM behaviour module of the given kind (for example
:gen_server or :gen_statem), prepending imports before declarations.
An FSM is an actor whose mailbox protocol is constrained by a transition graph. It retains gen_statem's direct wire protocol while sharing the same transparent module-construction path as every other actor family.
Emit a :supervisor behaviour module with standard OTP and supervisor
imports (Std.Otp, Std.Supervisor, Std.ExitReason).
Functions
fn actor_module(module_name: SynLit, state_type: Syntax, declarations: List(Syntax)) -> Syntax
Emit a :gen_server behaviour module with typealias State = state_type
and standard OTP imports (Std.Otp, Std.ExitReason).
fn actor_module_raw(module_name: SynLit, declarations: List(Syntax)) -> Syntax
Emit a :gen_server behaviour module without a State type alias, used
by state-polymorphic or stateless actor definitions.
fn application_module(module_name: SynLit, declarations: List(Syntax)) -> Syntax
Emit an :application behaviour module with standard OTP and application
imports (Std.Otp, Std.App, Std.ExitReason).
fn behavior_module(module_name: SynLit, kind: Atom, imports: List(Syntax), declarations: List(Syntax)) -> Syntax
Emit an isolated BEAM behaviour module of the given kind (for example
:gen_server or :gen_statem), prepending imports before declarations.
fn state_machine_module(module_name: SynLit, declarations: List(Syntax)) -> Syntax
An FSM is an actor whose mailbox protocol is constrained by a transition graph. It retains gen_statem's direct wire protocol while sharing the same transparent module-construction path as every other actor family.
fn supervisor_module(module_name: SynLit, declarations: List(Syntax)) -> Syntax
Emit a :supervisor behaviour module with standard OTP and supervisor
imports (Std.Otp, Std.Supervisor, Std.ExitReason).