Events continuations
Events continuations are the fundamental building blocks of Koru. An event continuations declares its input payload and possible output branches.
Event Declaration
~event greet { name: []const u8 }
| greeting { message: []const u8 }
| error { reason: []const u8 } Proc Implementation
A proc provides the implementation for an event:
~proc greet {
if (name.len == 0) {
return .{ .@"error" = .{ .reason = "Name cannot be empty" } };
}
const msg = try std.fmt.allocPrint(allocator, "Hello, {s}!", .{name});
return .{ .greeting = .{ .message = msg } };
} Invoking Events
Events are invoked with flows:
~import "$std/io"
~greet(name: "World")
| greeting g |> std.io:println(g.message)
| error e |> std.io:eprintln(e.reason) More documentation coming soon…