Std. Actor
(Cure Standard Library v0.37.2)
View Source
The structured actor and dependent-reply behavior macro surface.
Provides the source-defined actor and behavior syntax families along
with the compile-time derivation helpers that lower them into typed OTP
gen_server modules.
Examples
use Std.Actor
actor Counter
state Int
initial 0
on_message
Inc() -> state + 1
Reset() -> 0
Summary
Types
The structured family has three initialization modes. The default keeps
the ordinary GenServer argument as the state; initial and init make
the generated starter nullary and use Unit only as the OTP callback's
transport argument. The state expression/body remains ordinary generated
Cure code and is checked by the normal callback type.
Functions
Rewrite a synchronous call :pattern_match body so each arm replies via
Std.Otp.reply and returns %[:noreply, state].
Rewrite a single :match_arm to send a reply with Std.Otp.reply and keep state.
Construct the rewritten call :match_arm node invoking Std.Otp.reply(from, body).
Map actor_call_handler_arm across a list of call match arms.
Rewrite a :pattern_match node by transforming each call match arm.
Normalize an optional code_change callback body, defaulting to %[:ok, state].
Adapt the state-valued body of an inferred actor handler to the ordinary GenServer callback result. This remains in the actor macro module: it is domain-specific syntax construction, not part of the generic reflection vocabulary.
Wrap a single :match_arm body in a :noreply GenServer tuple.
Construct the rewritten :match_arm node whose body returns %[:noreply, body].
Map actor_handler_arm across a list of match arms.
Rewrite a :pattern_match node by wrapping every arm body in :noreply.
Lower an on_info body into a GenServer handle_info expression, defaulting
to %[:noreply, state] when no info clauses are provided.
Build typed parameter declarations for a generated on_call client adapter.
Generate typed client helper functions (one per on_call query) that build
the request value and invoke request(actor, ...).
Build variable references for forwarding on_call adapter arguments into
the request constructor.
Lower a single on_call query into a :match_arm carrying its reply
expression and next-state metadata.
Lower a list of on_call query definitions into match arms.
Build the match request expression dispatching all on_call queries, or
Raw(SOpaque) when the actor declares no queries.
Extract variable patterns from captured on_call query parameters.
Extract the type syntax of each captured on_call query parameter.
Build the constructor match pattern for an on_call query request.
Convert on_call queries into enum variant declarations for ActorRequest.
Generate the type-level ReplyOf(request: ActorRequest) -> Type family
mapping each query constructor to its declared reply type.
Generate the match arms of ReplyOf from on_call query definitions.
Return the argument list forwarded from start to start_base based on
whether the actor takes an explicit initial state parameter.
Build the init/1 return expression, running an optional on_start
transformation with state bound to initial_state.
Normalize an optional terminate callback body, defaulting to :ok.
Build reply(request) — the request's own reply type — from the captured reply family name applied to the
request binder, the dependent middle of the %[:reply, _, state] result tuple.
Wrap a single :match_arm reply body into a %[:reply, value, next_state] tuple.
Construct the rewritten :match_arm node using the arm's :actor_query_state
metadata if present, or keeping state unchanged otherwise.
Wrap each handle arm's reply VALUE into the OTP call result tuple %[:reply, <value>, state], so the user
writes only the answer and the macro supplies the protocol shape and the (unchanged) state.
Select the cast/info body transform for the emitter. The raw branch splices
the user's full GenServer result verbatim; the Cases branch wraps each arm
in :noreply via actor_handler. Kept as tail-position helpers (not an
inline let-RHS match) because a bool-literal match in let-RHS position
mis-lowers through the effect-bind path (§1e wall 4).
A cast-only actor still claims the complete gen_server behaviour. Keep
that claim honest with an unreachable-through-the-typed-API call floor:
its request is polymorphic and its reply is Unit, while the actor state is
preserved. Raw BEAM callers therefore receive a total reply instead of
crashing the server, and the generated module carries no missing-callback
warning.
Build the default ActorInitSpec that accepts an initial State value
directly and returns %[:ok, initial].
State-polymorphic default init for stateless actor forms. Mirrors
default_actor_init but binds the state to a free type var p instead of the
State alias (which stateless modules don't emit): init(initial: p) = %[:ok, initial] with a unary start_link(initial: p) seeding the state.
Rewrite a query match expression so each arm produces a %[:reply, value, next_state] tuple.
Entry point for the actor macro family. Dispatches to the derived cases
emitter when on_message or on_cast is provided, and falls back to the
raw GenServer callback emitter otherwise.
The derived (Cases) branch of the family: on_cast arms are reflected into
a message type and each arm body is wrapped in the GenServer :noreply
result. Byte-identical to the pre-1e emitter — this path feeds the
GDerived/GStructuredCall/GLifecycle byte-identical goldens.
The Tier-0 raw branch of the family: handle_cast/handle_info bodies are
full GenServer callback results spliced verbatim (no :noreply wrapping,
no message-type derivation). Value-equality dispatch, pickup/else, and
guards that the Cases surface cannot express live here. All raw positional
rules can funnel into this one emitter instead of re-spelling a module.
The raw branch's query dispatch, mirroring the Cases branch's own
match definition.queries. Without this an actor whose only synchronous
surface is on_call -- no on_message, no on_cast, so it lands here --
had its queries dropped in silence: no handle_call/3, no Handle, no
adapters, and a module that still compiled clean.
State-polymorphic sibling of derive_actor_family_raw for STATELESS actor
forms. Structurally identical, but the state stays polymorphic: it uses
derive_actor_init_poly (free p default init) and routes through
emit_actor_parts_poly_state, which emits NO typealias State. Stateless
templates never carry a messages annotation, so the message type is always
polymorphic here; definition.state is ignored (the callbacks are p).
Derive an ActorInitSpec from optional initial, init, and on_start
clauses of an actor definition.
State-polymorphic counterpart of derive_actor_init. The initial:/init:
seed cases are identical (they pin the state to a concrete value, so they need
no State type); only the default falls through to the poly p init.
Derive the terminate/2 body from an optional on_stop hook (converting
the exit reason via Std.ExitReason.from_atom) or a raw terminate block.
Expand the behavior macro family into a dependent-reply gen_server module
with a synthesized reply_for helper and standard OTP callbacks.
Infer the request constructors and uniform reply type for a synchronous call handler body.
Emit a gen_server module supporting uniform-reply synchronous calls via
linear Reply(reply_type) handles along with the typed client API.
Emit a gen_server module supporting per-request dependent reply types via
Std.Otp.DepActorServer and a synthesized reply_for helper.
message_aliased selects how the handle_cast/handle_info message type is
expressed. When true (a messages type or a derived enum is supplied), the
type is a module-level typealias Message = <type> referenced by both
callbacks — the byte-identical pre-1e shape (emit_actor_parts_aliased).
When false (a raw actor with no messages), the message is polymorphic: NO
module-level alias is emitted (a free m there has no binder and fails as
:unknown_global); instead each callback carries an inline free type var,
auto-generalized per function (emit_actor_parts_poly). The two branches are
separate functions so the aliased list literal — and thus its compiled bytes
— stays untouched.
Emit a cast-only gen_server module with a module-level Message alias
and the typed start/send/stop client API.
Emit a raw gen_server module with a Message alias, splicing the user's
handle_cast and handle_info bodies verbatim.
Emit a gen_server module whose cast and info callbacks are polymorphic in
their message types (omitting a module-level Message alias).
State-polymorphic emitter for stateless actor forms. Unlike
emit_actor_parts_poly (which references a State alias emitted by
gen_server_module), every callback here carries a free state type var p
and the module is built with gen_server_module_raw — NO typealias State.
Both the message (m/i) and state (p) type vars auto-generalize per
callback, exactly as the hand-written stateless templates did.
Shared transparent declaration bundle for generated GenServer modules. Domain-specific builders supply only aliases and callback overrides; the common import and state plumbing live in one ordinary Cure function.
State-alias-free variant of gen_server_module. Stateless actor forms keep
the state polymorphic (a free p on every callback), so they must NOT emit a
typealias State = p — a free p at module scope elaborates to
:unknown_global. gen_server_module is defined in terms of this by prepending
the State alias, so the aliased path stays byte-identical (append is
associative: [use_module] ++ ([alias] ++ decls) = [use_module, alias, ...decls]).
Infer the reply type from the first arm and verify all remaining arms agree.
Verify that every remaining call arm has a reply type matching reply_key.
Infer a uniform reply type across all arms of a call :pattern_match node.
Select the handle_info body transform: raw bodies are spliced verbatim,
while derived cases are wrapped via actor_info_handler.
Map a literal node's :subtype attribute to its corresponding Cure type syntax.
Unwrap an optional body declaration block into its child declaration list.
The raw-branch counterpart of actor_info_handler. An absent (:raw) info
body still defaults to the passthrough %[:noreply, state], but a present
body is a full GenServer result spliced VERBATIM — never routed through
actor_handler, which would re-wrap a match body's arms in a second
:noreply (the raw/Cases double-wrap defect, §1e wall 4).
Infer the reply type of a single call match arm, unwrapping a single-expression block.
Infer the reply type of a simple expression (state, literal, or tuple).
Types
struct ActorInitSpec
?
?
?
?
The structured family has three initialization modes. The default keeps
the ordinary GenServer argument as the state; initial and init make
the generated starter nullary and use Unit only as the OTP callback's
transport argument. The state expression/body remains ordinary generated
Cure code and is checked by the normal callback type.
enum ReplyInference
NoCall
CallContract
InvalidCall
enum ReplyTypeInference
ReplyType
InvalidReply
Functions
fn actor_call_handler(body: Syntax) -> Syntax
Rewrite a synchronous call :pattern_match body so each arm replies via
Std.Otp.reply and returns %[:noreply, state].
fn actor_call_handler_arm(arm: Syntax) -> Syntax
Rewrite a single :match_arm to send a reply with Std.Otp.reply and keep state.
fn actor_call_handler_arm_node(values: List(Attr), children: List(Syntax)) -> Syntax
Construct the rewritten call :match_arm node invoking Std.Otp.reply(from, body).
fn actor_call_handler_arms(arms: List(Syntax)) -> List(Syntax)
Map actor_call_handler_arm across a list of call match arms.
fn actor_call_handler_node(values: List(Attr), children: List(Syntax)) -> Syntax
Rewrite a :pattern_match node by transforming each call match arm.
fn actor_code_change_handler(body: Syntax) -> Syntax
Normalize an optional code_change callback body, defaulting to %[:ok, state].
fn actor_handler(body: Syntax) -> Syntax
Adapt the state-valued body of an inferred actor handler to the ordinary GenServer callback result. This remains in the actor macro module: it is domain-specific syntax construction, not part of the generic reflection vocabulary.
fn actor_handler_arm(arm: Syntax) -> Syntax
Wrap a single :match_arm body in a :noreply GenServer tuple.
fn actor_handler_arm_node(values: List(Attr), children: List(Syntax)) -> Syntax
Construct the rewritten :match_arm node whose body returns %[:noreply, body].
fn actor_handler_arms(arms: List(Syntax)) -> List(Syntax)
Map actor_handler_arm across a list of match arms.
fn actor_handler_node(values: List(Attr), children: List(Syntax)) -> Syntax
Rewrite a :pattern_match node by wrapping every arm body in :noreply.
fn actor_info_handler(info_body: Syntax) -> Syntax
Lower an on_info body into a GenServer handle_info expression, defaulting
to %[:noreply, state] when no info clauses are provided.
fn actor_query_adapter_parameters(parameters: List(Syntax)) -> List(Syntax)
Build typed parameter declarations for a generated on_call client adapter.
fn actor_query_adapters(queries: List(ActorQueryDefinitionSyntax), handle_type: Syntax) -> List(Syntax)
Generate typed client helper functions (one per on_call query) that build
the request value and invoke request(actor, ...).
fn actor_query_argument_values(parameters: List(Syntax)) -> List(Syntax)
Build variable references for forwarding on_call adapter arguments into
the request constructor.
fn actor_query_arm(query: ActorQueryDefinitionSyntax) -> Syntax
Lower a single on_call query into a :match_arm carrying its reply
expression and next-state metadata.
fn actor_query_arms(queries: List(ActorQueryDefinitionSyntax)) -> List(Syntax)
Lower a list of on_call query definitions into match arms.
fn actor_query_body(queries: List(ActorQueryDefinitionSyntax)) -> Syntax
Build the match request expression dispatching all on_call queries, or
Raw(SOpaque) when the actor declares no queries.
fn actor_query_parameter_patterns(parameters: List(Syntax)) -> List(Syntax)
Extract variable patterns from captured on_call query parameters.
fn actor_query_parameter_types(parameters: List(Syntax)) -> List(Syntax)
Extract the type syntax of each captured on_call query parameter.
fn actor_query_pattern(query: ActorQueryDefinitionSyntax) -> Syntax
Build the constructor match pattern for an on_call query request.
fn actor_query_variants(queries: List(ActorQueryDefinitionSyntax)) -> List(Syntax)
Convert on_call queries into enum variant declarations for ActorRequest.
fn actor_reply_family(queries: List(ActorQueryDefinitionSyntax)) -> Syntax
Generate the type-level ReplyOf(request: ActorRequest) -> Type family
mapping each query constructor to its declared reply type.
fn actor_reply_type_arms(queries: List(ActorQueryDefinitionSyntax)) -> List(Syntax)
Generate the match arms of ReplyOf from on_call query definitions.
fn actor_start_adapter_args(parameters: List(Syntax)) -> List(Syntax)
Return the argument list forwarded from start to start_base based on
whether the actor takes an explicit initial state parameter.
fn actor_start_body(initial_state: Syntax, on_start: Option(Syntax)) -> Syntax
Build the init/1 return expression, running an optional on_start
transformation with state bound to initial_state.
fn actor_terminate_handler(body: Syntax) -> Syntax
Normalize an optional terminate callback body, defaulting to :ok.
fn behavior_reply_apply(reply_fn: Syntax) -> Syntax
Build reply(request) — the request's own reply type — from the captured reply family name applied to the
request binder, the dependent middle of the %[:reply, _, state] result tuple.
fn behavior_reply_arm(arm: Syntax) -> Syntax
Wrap a single :match_arm reply body into a %[:reply, value, next_state] tuple.
fn behavior_reply_arm_node(values: List(Attr), children: List(Syntax)) -> Syntax
Construct the rewritten :match_arm node using the arm's :actor_query_state
metadata if present, or keeping state unchanged otherwise.
fn behavior_reply_arms(arms: List(Syntax)) -> List(Syntax)
Wrap each handle arm's reply VALUE into the OTP call result tuple %[:reply, <value>, state], so the user
writes only the answer and the macro supplies the protocol shape and the (unchanged) state.
fn cast_handler_for(cast_body: Syntax, raw_body: Bool) -> Syntax
Select the cast/info body transform for the emitter. The raw branch splices
the user's full GenServer result verbatim; the Cases branch wraps each arm
in :noreply via actor_handler. Kept as tail-position helpers (not an
inline let-RHS match) because a bool-literal match in let-RHS position
mis-lowers through the effect-bind path (§1e wall 4).
fn default_actor_handle_call(state_type: Syntax) -> Syntax
A cast-only actor still claims the complete gen_server behaviour. Keep
that claim honest with an unreachable-through-the-typed-API call floor:
its request is polymorphic and its reply is Unit, while the actor state is
preserved. Raw BEAM callers therefore receive a total reply instead of
crashing the server, and the generated module carries no missing-callback
warning.
fn default_actor_init(state_type: Syntax) -> ActorInitSpec
Build the default ActorInitSpec that accepts an initial State value
directly and returns %[:ok, initial].
fn default_actor_init_poly() -> ActorInitSpec
State-polymorphic default init for stateless actor forms. Mirrors
default_actor_init but binds the state to a free type var p instead of the
State alias (which stateless modules don't emit): init(initial: p) = %[:ok, initial] with a unary start_link(initial: p) seeding the state.
fn dependent_actor_call_body(call_body: Syntax) -> Syntax
Rewrite a query match expression so each arm produces a %[:reply, value, next_state] tuple.
fn derive_actor_family(name: ModuleNameSyntax, definition: ActorDefinitionSyntax) -> Syntax
Entry point for the actor macro family. Dispatches to the derived cases
emitter when on_message or on_cast is provided, and falls back to the
raw GenServer callback emitter otherwise.
fn derive_actor_family_cases(name: ModuleNameSyntax, definition: ActorDefinitionSyntax, cast_cases: Syntax) -> Syntax
The derived (Cases) branch of the family: on_cast arms are reflected into
a message type and each arm body is wrapped in the GenServer :noreply
result. Byte-identical to the pre-1e emitter — this path feeds the
GDerived/GStructuredCall/GLifecycle byte-identical goldens.
fn derive_actor_family_raw(name: ModuleNameSyntax, definition: ActorDefinitionSyntax) -> Syntax
The Tier-0 raw branch of the family: handle_cast/handle_info bodies are
full GenServer callback results spliced verbatim (no :noreply wrapping,
no message-type derivation). Value-equality dispatch, pickup/else, and
guards that the Cases surface cannot express live here. All raw positional
rules can funnel into this one emitter instead of re-spelling a module.
derive_actor_family_raw_queries(module_name: SynLit, module_expr: Syntax, definition: ActorDefinitionSyntax, init_spec: ActorInitSpec, cast_body: Syntax, info_body: Syntax, terminate_body: Syntax, code_change_body: Syntax, extra_declarations: List(Syntax), queries: List(ActorQueryDefinitionSyntax)) -> Syntax
fn derive_actor_family_raw_queries(module_name: SynLit, module_expr: Syntax, definition: ActorDefinitionSyntax, init_spec: ActorInitSpec, cast_body: Syntax, info_body: Syntax, terminate_body: Syntax, code_change_body: Syntax, extra_declarations: List(Syntax), queries: List(ActorQueryDefinitionSyntax)) -> Syntax
The raw branch's query dispatch, mirroring the Cases branch's own
match definition.queries. Without this an actor whose only synchronous
surface is on_call -- no on_message, no on_cast, so it lands here --
had its queries dropped in silence: no handle_call/3, no Handle, no
adapters, and a module that still compiled clean.
Message is Unit rather than the raw branch's free m because the
dependent emitter aliases the message type at module scope, where a free
type variable elaborates to :unknown_global. An actor that declares no cast
surface accepts no casts, which is exactly what Unit says; a raw
handle_cast alongside queries should name its inbox with messages.
fn derive_actor_family_raw_stateless(name: ModuleNameSyntax, definition: ActorDefinitionSyntax) -> Syntax
State-polymorphic sibling of derive_actor_family_raw for STATELESS actor
forms. Structurally identical, but the state stays polymorphic: it uses
derive_actor_init_poly (free p default init) and routes through
emit_actor_parts_poly_state, which emits NO typealias State. Stateless
templates never carry a messages annotation, so the message type is always
polymorphic here; definition.state is ignored (the callbacks are p).
fn derive_actor_init(state_type: Syntax, initial: Option(Syntax), init: Option(Syntax), on_start: Option(Syntax)) -> ActorInitSpec
Derive an ActorInitSpec from optional initial, init, and on_start
clauses of an actor definition.
fn derive_actor_init_poly(initial: Option(Syntax), init: Option(Syntax)) -> ActorInitSpec
State-polymorphic counterpart of derive_actor_init. The initial:/init:
seed cases are identical (they pin the state to a concrete value, so they need
no State type); only the default falls through to the poly p init.
fn derive_actor_stop(on_stop: Option(Syntax), raw_terminate: Option(Syntax)) -> Syntax
Derive the terminate/2 body from an optional on_stop hook (converting
the exit reason via Std.ExitReason.from_atom) or a raw terminate block.
fn derive_behavior_family(name: ModuleNameSyntax, definition: BehaviorDefinitionSyntax) -> Syntax
Expand the behavior macro family into a dependent-reply gen_server module
with a synthesized reply_for helper and standard OTP callbacks.
fn derive_reply_contract(call_body: Syntax, state_type: Syntax) -> ReplyInference
Infer the request constructors and uniform reply type for a synchronous call handler body.
emit_actor_call_parts(module_name: SynLit, module_expr: Syntax, state_type: Syntax, init_spec: ActorInitSpec, message_type: Syntax, message_declarations: List(Syntax), cast_body: Syntax, call_body: Syntax, info_body: Syntax, terminate_body: Syntax, code_change_body: Syntax, message_heads: List(Syntax), request_heads: List(Syntax), reply_type: Syntax, extra_declarations: List(Syntax)) -> Syntax
fn emit_actor_call_parts(module_name: SynLit, module_expr: Syntax, state_type: Syntax, init_spec: ActorInitSpec, message_type: Syntax, message_declarations: List(Syntax), cast_body: Syntax, call_body: Syntax, info_body: Syntax, terminate_body: Syntax, code_change_body: Syntax, message_heads: List(Syntax), request_heads: List(Syntax), reply_type: Syntax, extra_declarations: List(Syntax)) -> Syntax
Emit a gen_server module supporting uniform-reply synchronous calls via
linear Reply(reply_type) handles along with the typed client API.
emit_actor_dep_call_parts(module_name: SynLit, module_expr: Syntax, state_type: Syntax, init_spec: ActorInitSpec, message_type: Syntax, message_declarations: List(Syntax), cast_body: Syntax, call_body: Syntax, info_body: Syntax, terminate_body: Syntax, code_change_body: Syntax, request_heads: List(Syntax), reply_fn: Syntax, extra_declarations: List(Syntax)) -> Syntax
fn emit_actor_dep_call_parts(module_name: SynLit, module_expr: Syntax, state_type: Syntax, init_spec: ActorInitSpec, message_type: Syntax, message_declarations: List(Syntax), cast_body: Syntax, call_body: Syntax, info_body: Syntax, terminate_body: Syntax, code_change_body: Syntax, request_heads: List(Syntax), reply_fn: Syntax, extra_declarations: List(Syntax)) -> Syntax
Emit a gen_server module supporting per-request dependent reply types via
Std.Otp.DepActorServer and a synthesized reply_for helper.
emit_actor_parts(module_name: SynLit, module_expr: Syntax, state_type: Syntax, init_spec: ActorInitSpec, message_type: Syntax, message_declarations: List(Syntax), cast_body: Syntax, info_body: Syntax, terminate_body: Syntax, code_change_body: Syntax, heads: List(Syntax), extra_declarations: List(Syntax), message_aliased: Bool, raw_body: Bool) -> Syntax
fn emit_actor_parts(module_name: SynLit, module_expr: Syntax, state_type: Syntax, init_spec: ActorInitSpec, message_type: Syntax, message_declarations: List(Syntax), cast_body: Syntax, info_body: Syntax, terminate_body: Syntax, code_change_body: Syntax, heads: List(Syntax), extra_declarations: List(Syntax), message_aliased: Bool, raw_body: Bool) -> Syntax
message_aliased selects how the handle_cast/handle_info message type is
expressed. When true (a messages type or a derived enum is supplied), the
type is a module-level typealias Message = <type> referenced by both
callbacks — the byte-identical pre-1e shape (emit_actor_parts_aliased).
When false (a raw actor with no messages), the message is polymorphic: NO
module-level alias is emitted (a free m there has no binder and fails as
:unknown_global); instead each callback carries an inline free type var,
auto-generalized per function (emit_actor_parts_poly). The two branches are
separate functions so the aliased list literal — and thus its compiled bytes
— stays untouched.
emit_actor_parts_aliased(module_name: SynLit, module_expr: Syntax, state_type: Syntax, init_spec: ActorInitSpec, message_type: Syntax, message_declarations: List(Syntax), cast_body: Syntax, info_body: Syntax, terminate_body: Syntax, code_change_body: Syntax, extra_declarations: List(Syntax), raw_body: Bool) -> Syntax
fn emit_actor_parts_aliased(module_name: SynLit, module_expr: Syntax, state_type: Syntax, init_spec: ActorInitSpec, message_type: Syntax, message_declarations: List(Syntax), cast_body: Syntax, info_body: Syntax, terminate_body: Syntax, code_change_body: Syntax, extra_declarations: List(Syntax), raw_body: Bool) -> Syntax
Emit a cast-only gen_server module with a module-level Message alias
and the typed start/send/stop client API.
emit_actor_parts_aliased_raw(module_name: SynLit, module_expr: Syntax, state_type: Syntax, init_spec: ActorInitSpec, message_type: Syntax, message_declarations: List(Syntax), cast_body: Syntax, info_body: Syntax, terminate_body: Syntax, code_change_body: Syntax, extra_declarations: List(Syntax)) -> Syntax
fn emit_actor_parts_aliased_raw(module_name: SynLit, module_expr: Syntax, state_type: Syntax, init_spec: ActorInitSpec, message_type: Syntax, message_declarations: List(Syntax), cast_body: Syntax, info_body: Syntax, terminate_body: Syntax, code_change_body: Syntax, extra_declarations: List(Syntax)) -> Syntax
Emit a raw gen_server module with a Message alias, splicing the user's
handle_cast and handle_info bodies verbatim.
fn emit_actor_parts_poly(module_name: SynLit, module_expr: Syntax, state_type: Syntax, init_spec: ActorInitSpec, message_declarations: List(Syntax), cast_body: Syntax, info_body: Syntax, terminate_body: Syntax, code_change_body: Syntax, extra_declarations: List(Syntax), raw_body: Bool) -> Syntax
Emit a gen_server module whose cast and info callbacks are polymorphic in
their message types (omitting a module-level Message alias).
fn emit_actor_parts_poly_state(module_name: SynLit, module_expr: Syntax, init_spec: ActorInitSpec, message_declarations: List(Syntax), cast_body: Syntax, info_body: Syntax, terminate_body: Syntax, code_change_body: Syntax, extra_declarations: List(Syntax), raw_body: Bool) -> Syntax
State-polymorphic emitter for stateless actor forms. Unlike
emit_actor_parts_poly (which references a State alias emitted by
gen_server_module), every callback here carries a free state type var p
and the module is built with gen_server_module_raw — NO typealias State.
Both the message (m/i) and state (p) type vars auto-generalize per
callback, exactly as the hand-written stateless templates did.
fn gen_server_module(module_name: SynLit, state_type: Syntax, declarations: List(Syntax)) -> Syntax
Shared transparent declaration bundle for generated GenServer modules. Domain-specific builders supply only aliases and callback overrides; the common import and state plumbing live in one ordinary Cure function.
fn gen_server_module_raw(module_name: SynLit, declarations: List(Syntax)) -> Syntax
State-alias-free variant of gen_server_module. Stateless actor forms keep
the state polymorphic (a free p on every callback), so they must NOT emit a
typealias State = p — a free p at module scope elaborates to
:unknown_global. gen_server_module is defined in terms of this by prepending
the State alias, so the aliased path stays byte-identical (append is
associative: [use_module] ++ ([alias] ++ decls) = [use_module, alias, ...decls]).
fn infer_reply_arms(arms: List(Syntax), state_type: Syntax) -> ReplyTypeInference
Infer the reply type from the first arm and verify all remaining arms agree.
fn infer_reply_tail(arms: List(Syntax), state_type: Syntax, reply_type: Syntax, reply_key: Atom) -> ReplyTypeInference
Verify that every remaining call arm has a reply type matching reply_key.
fn infer_reply_type(body: Syntax, state_type: Syntax) -> ReplyTypeInference
Infer a uniform reply type across all arms of a call :pattern_match node.
fn info_handler_for(info_body: Syntax, raw_body: Bool) -> Syntax
Select the handle_info body transform: raw bodies are spliced verbatim,
while derived cases are wrapped via actor_info_handler.
fn literal_reply_type(values: List(Attr)) -> ReplyTypeInference
Map a literal node's :subtype attribute to its corresponding Cure type syntax.
fn optional_declarations(value: Option(Syntax)) -> List(Syntax)
Unwrap an optional body declaration block into its child declaration list.
fn raw_info_handler(info_body: Syntax) -> Syntax
The raw-branch counterpart of actor_info_handler. An absent (:raw) info
body still defaults to the passthrough %[:noreply, state], but a present
body is a full GenServer result spliced VERBATIM — never routed through
actor_handler, which would re-wrap a match body's arms in a second
:noreply (the raw/Cases double-wrap defect, §1e wall 4).
fn reply_arm_type(arm: Syntax, state_type: Syntax) -> ReplyTypeInference
Infer the reply type of a single call match arm, unwrapping a single-expression block.
fn reply_expr_type(expr: Syntax, state_type: Syntax) -> ReplyTypeInference
Infer the reply type of a simple expression (state, literal, or tuple).