Skip to content
Pyrula

Quickstart

The core package has no dependencies beyond the Rust extension. These examples run against pip install pyrula alone.

Either holds a value or an error. Build the sides with ok and err, transform with map, then collapse with fold or get_or_else.

from pyrula import Either
def parse_port(raw: str) -> Either:
if not raw.isdigit():
return Either.err(f"not a number: {raw!r}")
port = int(raw)
if not 0 < port < 65536:
return Either.err(f"out of range: {port}")
return Either.ok(port)
parse_port("8080").map(lambda p: p + 1).get_or_else(0) # 8081
parse_port("nope").get_or_else(0) # 0
parse_port("99999").fold(
lambda err: f"rejected: {err}",
lambda port: f"using {port}",
) # "rejected: out of range: 99999"

No exceptions. A bad parse is a value you can pass around and branch on later.

Option replaces None checks. Option.of wraps a value; map and filter chain without guarding for absence.

from pyrula import Option
config = {"timeout": "30"}
Option.of(config.get("timeout")).map(int).filter(lambda s: s > 0).get_or_else(10)
# 30, or 10 if the key is missing or non-positive

That’s the shape of the whole library: failure and absence are ordinary return values, not control flow.

Next: the full Primitives reference, or pick a runtime. Workflows, Agents, Kafka.

For end-to-end runnable scripts (a durable workflow, an offline agent, an exactly-once Kafka to Delta pipeline), see the examples/ directory.