A stored procedure whose rows are As.
Attributes#
| Attribute | Type | Description |
|---|---|---|
name | str | |
params | tuple[Parameter[Any], ...] = () | |
output_params | tuple[Parameter[Any], ...] = () |
Functions#
__init__#
__init__(name, params=(), output_params=()) -> None| Parameter | Type | Description |
|---|---|---|
name | str | |
params | tuple[Parameter[Any], ...] = () | |
output_params | tuple[Parameter[Any], ...] = () |
param#
param(parameter) -> Procedure[A_co]With the input parameter.
| Parameter | Type | Description |
|---|---|---|
parameter | Parameter[Any] |
Returns Procedure[A_co]
def param(self, parameter: Parameter[Any]) -> Procedure[A_co]:
"""With the input ``parameter``."""
return Procedure(self.name, _with(self.params, parameter), self.output_params)output_param#
output_param(parameter) -> Procedure[A_co]With the output parameter.
| Parameter | Type | Description |
|---|---|---|
parameter | Parameter[Any] |
Returns Procedure[A_co]
def output_param(self, parameter: Parameter[Any]) -> Procedure[A_co]:
"""With the output ``parameter``."""
return Procedure(self.name, self.params, _with(self.output_params, parameter))with_rows#
with_rows[B](row) -> Procedure[B]Its rows typed as row (Effect's withRows<A>()).
| Parameter | Type | Description |
|---|---|---|
row | type[B] |
Returns Procedure[B]
def with_rows[B](self, row: type[B]) -> Procedure[B]:
"""Its rows typed as ``row`` (Effect's ``withRows<A>()``)."""
return Procedure(self.name, self.params, self.output_params)compile#
compile(*values) -> ProcedureWithValues[A_co]This procedure with a value for each input; ValueError when one
is missing, repeated or not an input of it.
| Parameter | Type | Description |
|---|---|---|
values | Bound[Any] = () |
Returns ProcedureWithValues[A_co]
def compile(self, *values: Bound[Any]) -> ProcedureWithValues[A_co]:
"""This procedure with a value for each input; ``ValueError`` when one
is missing, repeated or not an input of it."""
bound: dict[str, object] = {}
inputs = {p.name: p for p in self.params}
for value in values:
name = value.parameter.name
if inputs.get(name) != value.parameter:
raise ValueError(f"{name!r} is not an input of procedure {self.name!r}")
if name in bound:
raise ValueError(f"{name!r} is bound twice")
bound[name] = value.value
missing = [name for name in inputs if name not in bound]
if missing:
raise ValueError(f"procedure {self.name!r} needs values for {missing}")
return ProcedureWithValues(self, bound)