reply
reply data # { reply = data; }reply.right data # { reply = { right = data; }; }reply.left data # { reply = { left = data; }; }Description
Section titled “Description”reply is an attrset with a __functor field, so it works both as a function and as a namespace.
reply data is shorthand for writing { reply = data; } in a behaviour’s return value. The actor extracts reply fields from the state stream to build outbox.
reply.right and reply.left produce Either-tagged values. The outbox stream exposes .right and .left for splitting the stream by tag.
Combining with become
Section titled “Combining with become”Use // to merge reply and become in one expression:
reply data // become new-beh# { reply = data; next-behaviour = new-beh; }Either splitting
Section titled “Either splitting”validator-c = actor (n: if n > 0 then reply.right n else reply.left "err: ${toString n}");
a = validator-c { inbox = st 5 (-1) 3; };a.outbox.toList # [ { right = 5; } { left = "err: -1"; } { right = 3; } ]a.outbox.right.toList # [ 5 3 ]a.outbox.left.toList # [ "err: -1" ]replywithout.right/.leftputs the raw value in outbox — no tagging.- A behaviour that returns
{ }(noreplyfield) produces no outbox entry for that message. - The
replyfield can be aST—states.fields "reply"flattens it, so one message can produce multiple outbox entries.