diff --git a/hugr-py/src/hugr/serialization/ops.py b/hugr-py/src/hugr/serialization/ops.py index 849c7aff2..985bd37c9 100644 --- a/hugr-py/src/hugr/serialization/ops.py +++ b/hugr-py/src/hugr/serialization/ops.py @@ -1,7 +1,7 @@ import inspect import sys from abc import ABC -from typing import Any, Literal, cast +from typing import Any, Literal from pydantic import Field, RootModel @@ -28,7 +28,7 @@ class BaseOp(ABC, ConfiguredBaseModel): # Parent node index of node the op belongs to, used only at serialization time parent: NodeID - input_extensions: ExtensionSet = Field(default_factory=ExtensionSet) + input_extensions: ExtensionSet | None = Field(default=None) def insert_port_types(self, in_types: TypeRow, out_types: TypeRow) -> None: """Hook to insert type information from the input and output ports into the @@ -59,14 +59,7 @@ class FuncDefn(BaseOp): op: Literal["FuncDefn"] = "FuncDefn" name: str - signature: PolyFuncType = Field(default_factory=PolyFuncType.empty) - - def insert_port_types(self, in_types: TypeRow, out_types: TypeRow) -> None: - assert len(in_types) == 0 - assert len(out_types) == 1 - out = out_types[0] - assert isinstance(out, PolyFuncType) - self.signature = out # TODO: Extensions + signature: PolyFuncType class FuncDecl(BaseOp): @@ -74,14 +67,7 @@ class FuncDecl(BaseOp): op: Literal["FuncDecl"] = "FuncDecl" name: str - signature: PolyFuncType = Field(default_factory=PolyFuncType.empty) - - def insert_port_types(self, in_types: TypeRow, out_types: TypeRow) -> None: - assert len(in_types) == 0 - assert len(out_types) == 1 - out = out_types[0] - assert isinstance(out, PolyFuncType) - self.signature = out + signature: PolyFuncType CustomConst = Any # TODO @@ -186,13 +172,13 @@ def insert_port_types(self, in_types: TypeRow, out_types: TypeRow) -> None: def insert_child_dfg_signature(self, inputs: TypeRow, outputs: TypeRow) -> None: self.inputs = inputs - pred = outputs[0] - assert isinstance(pred, tys.UnitSum | tys.GeneralSum) - if isinstance(pred, tys.UnitSum): - self.sum_rows = [[] for _ in range(cast(tys.UnitSum, pred).size)] + pred = outputs[0].root + assert isinstance(pred, tys.TaggedSumType) + if isinstance(pred.st.root, tys.UnitSum): + self.sum_rows = [[] for _ in range(pred.st.root.size)] else: self.sum_rows = [] - for variant in pred.rows: + for variant in pred.st.root.rows: self.sum_rows.append(variant) self.other_outputs = outputs[1:] @@ -266,16 +252,9 @@ class Call(DataflowOp): """ op: Literal["Call"] = "Call" - func_sig: PolyFuncType = Field(default_factory=FunctionType.empty) - type_args: list[tys.TypeArg] = Field(default_factory=list) - instantiation: FunctionType = Field(default_factory=FunctionType.empty) - - def insert_port_types(self, in_types: TypeRow, out_types: TypeRow) -> None: - fun_ty = in_types[-1] - assert isinstance(fun_ty, PolyFuncType) - poly_func = cast(PolyFuncType, fun_ty) - assert len(poly_func.params) == 0 - self.signature = poly_func.body + func_sig: PolyFuncType + type_args: list[tys.TypeArg] + instantiation: FunctionType class Config: # Needed to avoid random '\n's in the pydantic description @@ -292,19 +271,18 @@ class Config: class CallIndirect(DataflowOp): """Call a function indirectly. - Like call, but the first input is a standard dataflow graph type.""" + Like call, but the first input is a standard dataflow graph type. + """ op: Literal["CallIndirect"] = "CallIndirect" signature: FunctionType = Field(default_factory=FunctionType.empty) def insert_port_types(self, in_types: TypeRow, out_types: TypeRow) -> None: - fun_ty = in_types[0] - assert isinstance(fun_ty, PolyFuncType) - poly_func = cast(PolyFuncType, fun_ty) - assert len(poly_func.params) == 0 - assert len(poly_func.body.input) == len(in_types) - 1 - assert len(poly_func.body.output) == len(out_types) - self.signature = poly_func.body + fun_ty = in_types[0].root + assert isinstance(fun_ty, FunctionType) + assert len(fun_ty.input) == len(in_types) - 1 + assert len(fun_ty.output) == len(out_types) + self.signature = fun_ty class LoadConstant(DataflowOp): @@ -359,12 +337,14 @@ def insert_port_types(self, in_types: TypeRow, out_types: TypeRow) -> None: # First port is a predicate, i.e. a sum of tuple types. We need to unpack # those into a list of type rows pred = in_types[0] - if isinstance(pred, tys.UnitSum): - self.sum_rows = [[] for _ in range(cast(tys.UnitSum, pred).size)] + assert isinstance(pred.root, tys.TaggedSumType) + sum = pred.root.st.root + if isinstance(sum, tys.UnitSum): + self.sum_rows = [[] for _ in range(sum.size)] else: - assert isinstance(pred, tys.GeneralSum) + assert isinstance(sum, tys.GeneralSum) self.sum_rows = [] - for ty in pred.rows: + for ty in sum.rows: self.sum_rows.append(ty) self.other_inputs = list(in_types[1:]) self.outputs = list(out_types) diff --git a/hugr-py/src/hugr/serialization/tys.py b/hugr-py/src/hugr/serialization/tys.py index 95703861c..d181b7e45 100644 --- a/hugr-py/src/hugr/serialization/tys.py +++ b/hugr-py/src/hugr/serialization/tys.py @@ -1,7 +1,7 @@ import inspect import sys from enum import Enum -from typing import Annotated, Any, Literal, Optional, Union, Mapping +from typing import Annotated, Any, Literal, Union, Mapping from pydantic import ( BaseModel, @@ -28,6 +28,7 @@ def _json_custom_error_validator( Used to define named recursive alias types. """ + return handler(value) try: return handler(value) except ValidationError as err: @@ -38,6 +39,7 @@ def _json_custom_error_validator( ExtensionId = str +ExtensionSet = list[ExtensionId] default_model_config = ConfigDict() @@ -50,12 +52,6 @@ def set_model_config(cls, config: ConfigDict): cls.model_config = config -class ExtensionSet(RootModel): - """A set of extensions ids.""" - - root: Optional[list[ExtensionId]] = Field(default=None) - - # -------------------------------------------- # --------------- TypeParam ------------------ # -------------------------------------------- @@ -219,7 +215,7 @@ class FunctionType(ConfiguredBaseModel): @classmethod def empty(cls) -> "FunctionType": - return FunctionType(input=[], output=[], extension_reqs=ExtensionSet([])) + return FunctionType(input=[], output=[], extension_reqs=[]) class Config: # Needed to avoid random '\n's in the pydantic description diff --git a/specification/schema/hugr_schema_strict_v1.json b/specification/schema/hugr_schema_strict_v1.json index 67c5359c2..a6a0de7a1 100644 --- a/specification/schema/hugr_schema_strict_v1.json +++ b/specification/schema/hugr_schema_strict_v1.json @@ -36,7 +36,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "AliasDecl", @@ -71,7 +83,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "AliasDefn", @@ -188,7 +212,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "CFG", @@ -218,7 +254,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Call", @@ -244,7 +292,10 @@ } }, "required": [ - "parent" + "parent", + "func_sig", + "type_args", + "instantiation" ], "title": "Call", "type": "object" @@ -258,7 +309,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "CallIndirect", @@ -288,7 +351,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Case", @@ -318,7 +393,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Conditional", @@ -355,7 +442,11 @@ "type": "array" }, "extension_delta": { - "$ref": "#/$defs/ExtensionSet" + "items": { + "type": "string" + }, + "title": "Extension Delta", + "type": "array" } }, "required": [ @@ -373,7 +464,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Const", @@ -404,7 +507,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "CustomOp", @@ -475,7 +590,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "DFG", @@ -505,7 +632,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "DataflowBlock", @@ -541,7 +680,11 @@ "type": "array" }, "extension_delta": { - "$ref": "#/$defs/ExtensionSet" + "items": { + "type": "string" + }, + "title": "Extension Delta", + "type": "array" } }, "required": [ @@ -559,7 +702,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "ExitBlock", @@ -585,22 +740,6 @@ "title": "ExitBlock", "type": "object" }, - "ExtensionSet": { - "anyOf": [ - { - "items": { - "type": "string" - }, - "type": "array" - }, - { - "type": "null" - } - ], - "default": null, - "description": "A set of extensions ids.", - "title": "ExtensionSet" - }, "ExtensionValue": { "additionalProperties": false, "description": "An extension constant value, that can check it is of a given [CustomType].", @@ -637,7 +776,11 @@ "type": "string" }, "es": { - "$ref": "#/$defs/ExtensionSet" + "items": { + "type": "string" + }, + "title": "Es", + "type": "array" } }, "required": [ @@ -671,7 +814,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "FuncDecl", @@ -692,7 +847,8 @@ }, "required": [ "parent", - "name" + "name", + "signature" ], "title": "FuncDecl", "type": "object" @@ -706,7 +862,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "FuncDefn", @@ -727,7 +895,8 @@ }, "required": [ "parent", - "name" + "name", + "signature" ], "title": "FuncDefn", "type": "object" @@ -760,7 +929,11 @@ "type": "array" }, "extension_reqs": { - "$ref": "#/$defs/ExtensionSet" + "items": { + "type": "string" + }, + "title": "Extension Reqs", + "type": "array" } }, "required": [ @@ -832,7 +1005,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Input", @@ -866,7 +1051,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Lift", @@ -928,7 +1125,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "LoadConstant", @@ -959,7 +1168,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "LoadFunction", @@ -1001,7 +1222,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "MakeTuple", @@ -1035,7 +1268,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Module", @@ -1062,7 +1307,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Noop", @@ -1289,7 +1546,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Output", @@ -1442,7 +1711,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Tag", @@ -1507,7 +1788,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "TailLoop", @@ -1811,7 +2104,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "UnpackTuple", diff --git a/specification/schema/hugr_schema_v1.json b/specification/schema/hugr_schema_v1.json index 3b4be37c7..0a1a24d29 100644 --- a/specification/schema/hugr_schema_v1.json +++ b/specification/schema/hugr_schema_v1.json @@ -36,7 +36,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "AliasDecl", @@ -71,7 +83,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "AliasDefn", @@ -188,7 +212,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "CFG", @@ -218,7 +254,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Call", @@ -244,7 +292,10 @@ } }, "required": [ - "parent" + "parent", + "func_sig", + "type_args", + "instantiation" ], "title": "Call", "type": "object" @@ -258,7 +309,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "CallIndirect", @@ -288,7 +351,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Case", @@ -318,7 +393,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Conditional", @@ -355,7 +442,11 @@ "type": "array" }, "extension_delta": { - "$ref": "#/$defs/ExtensionSet" + "items": { + "type": "string" + }, + "title": "Extension Delta", + "type": "array" } }, "required": [ @@ -373,7 +464,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Const", @@ -404,7 +507,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "CustomOp", @@ -475,7 +590,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "DFG", @@ -505,7 +632,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "DataflowBlock", @@ -541,7 +680,11 @@ "type": "array" }, "extension_delta": { - "$ref": "#/$defs/ExtensionSet" + "items": { + "type": "string" + }, + "title": "Extension Delta", + "type": "array" } }, "required": [ @@ -559,7 +702,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "ExitBlock", @@ -585,22 +740,6 @@ "title": "ExitBlock", "type": "object" }, - "ExtensionSet": { - "anyOf": [ - { - "items": { - "type": "string" - }, - "type": "array" - }, - { - "type": "null" - } - ], - "default": null, - "description": "A set of extensions ids.", - "title": "ExtensionSet" - }, "ExtensionValue": { "additionalProperties": true, "description": "An extension constant value, that can check it is of a given [CustomType].", @@ -637,7 +776,11 @@ "type": "string" }, "es": { - "$ref": "#/$defs/ExtensionSet" + "items": { + "type": "string" + }, + "title": "Es", + "type": "array" } }, "required": [ @@ -671,7 +814,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "FuncDecl", @@ -692,7 +847,8 @@ }, "required": [ "parent", - "name" + "name", + "signature" ], "title": "FuncDecl", "type": "object" @@ -706,7 +862,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "FuncDefn", @@ -727,7 +895,8 @@ }, "required": [ "parent", - "name" + "name", + "signature" ], "title": "FuncDefn", "type": "object" @@ -760,7 +929,11 @@ "type": "array" }, "extension_reqs": { - "$ref": "#/$defs/ExtensionSet" + "items": { + "type": "string" + }, + "title": "Extension Reqs", + "type": "array" } }, "required": [ @@ -832,7 +1005,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Input", @@ -866,7 +1051,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Lift", @@ -928,7 +1125,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "LoadConstant", @@ -959,7 +1168,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "LoadFunction", @@ -1001,7 +1222,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "MakeTuple", @@ -1035,7 +1268,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Module", @@ -1062,7 +1307,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Noop", @@ -1289,7 +1546,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Output", @@ -1442,7 +1711,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Tag", @@ -1507,7 +1788,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "TailLoop", @@ -1811,7 +2104,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "UnpackTuple", diff --git a/specification/schema/testing_hugr_schema_strict_v1.json b/specification/schema/testing_hugr_schema_strict_v1.json index 0af373dad..0de6a9683 100644 --- a/specification/schema/testing_hugr_schema_strict_v1.json +++ b/specification/schema/testing_hugr_schema_strict_v1.json @@ -36,7 +36,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "AliasDecl", @@ -71,7 +83,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "AliasDefn", @@ -188,7 +212,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "CFG", @@ -218,7 +254,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Call", @@ -244,7 +292,10 @@ } }, "required": [ - "parent" + "parent", + "func_sig", + "type_args", + "instantiation" ], "title": "Call", "type": "object" @@ -258,7 +309,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "CallIndirect", @@ -288,7 +351,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Case", @@ -318,7 +393,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Conditional", @@ -355,7 +442,11 @@ "type": "array" }, "extension_delta": { - "$ref": "#/$defs/ExtensionSet" + "items": { + "type": "string" + }, + "title": "Extension Delta", + "type": "array" } }, "required": [ @@ -373,7 +464,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Const", @@ -404,7 +507,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "CustomOp", @@ -475,7 +590,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "DFG", @@ -505,7 +632,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "DataflowBlock", @@ -541,7 +680,11 @@ "type": "array" }, "extension_delta": { - "$ref": "#/$defs/ExtensionSet" + "items": { + "type": "string" + }, + "title": "Extension Delta", + "type": "array" } }, "required": [ @@ -559,7 +702,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "ExitBlock", @@ -585,22 +740,6 @@ "title": "ExitBlock", "type": "object" }, - "ExtensionSet": { - "anyOf": [ - { - "items": { - "type": "string" - }, - "type": "array" - }, - { - "type": "null" - } - ], - "default": null, - "description": "A set of extensions ids.", - "title": "ExtensionSet" - }, "ExtensionValue": { "additionalProperties": false, "description": "An extension constant value, that can check it is of a given [CustomType].", @@ -637,7 +776,11 @@ "type": "string" }, "es": { - "$ref": "#/$defs/ExtensionSet" + "items": { + "type": "string" + }, + "title": "Es", + "type": "array" } }, "required": [ @@ -671,7 +814,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "FuncDecl", @@ -692,7 +847,8 @@ }, "required": [ "parent", - "name" + "name", + "signature" ], "title": "FuncDecl", "type": "object" @@ -706,7 +862,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "FuncDefn", @@ -727,7 +895,8 @@ }, "required": [ "parent", - "name" + "name", + "signature" ], "title": "FuncDefn", "type": "object" @@ -760,7 +929,11 @@ "type": "array" }, "extension_reqs": { - "$ref": "#/$defs/ExtensionSet" + "items": { + "type": "string" + }, + "title": "Extension Reqs", + "type": "array" } }, "required": [ @@ -832,7 +1005,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Input", @@ -866,7 +1051,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Lift", @@ -928,7 +1125,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "LoadConstant", @@ -959,7 +1168,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "LoadFunction", @@ -1001,7 +1222,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "MakeTuple", @@ -1035,7 +1268,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Module", @@ -1062,7 +1307,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Noop", @@ -1289,7 +1546,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Output", @@ -1442,7 +1711,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Tag", @@ -1507,7 +1788,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "TailLoop", @@ -1811,7 +2104,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "UnpackTuple", diff --git a/specification/schema/testing_hugr_schema_v1.json b/specification/schema/testing_hugr_schema_v1.json index 4628c337b..dac43864e 100644 --- a/specification/schema/testing_hugr_schema_v1.json +++ b/specification/schema/testing_hugr_schema_v1.json @@ -36,7 +36,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "AliasDecl", @@ -71,7 +83,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "AliasDefn", @@ -188,7 +212,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "CFG", @@ -218,7 +254,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Call", @@ -244,7 +292,10 @@ } }, "required": [ - "parent" + "parent", + "func_sig", + "type_args", + "instantiation" ], "title": "Call", "type": "object" @@ -258,7 +309,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "CallIndirect", @@ -288,7 +351,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Case", @@ -318,7 +393,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Conditional", @@ -355,7 +442,11 @@ "type": "array" }, "extension_delta": { - "$ref": "#/$defs/ExtensionSet" + "items": { + "type": "string" + }, + "title": "Extension Delta", + "type": "array" } }, "required": [ @@ -373,7 +464,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Const", @@ -404,7 +507,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "CustomOp", @@ -475,7 +590,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "DFG", @@ -505,7 +632,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "DataflowBlock", @@ -541,7 +680,11 @@ "type": "array" }, "extension_delta": { - "$ref": "#/$defs/ExtensionSet" + "items": { + "type": "string" + }, + "title": "Extension Delta", + "type": "array" } }, "required": [ @@ -559,7 +702,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "ExitBlock", @@ -585,22 +740,6 @@ "title": "ExitBlock", "type": "object" }, - "ExtensionSet": { - "anyOf": [ - { - "items": { - "type": "string" - }, - "type": "array" - }, - { - "type": "null" - } - ], - "default": null, - "description": "A set of extensions ids.", - "title": "ExtensionSet" - }, "ExtensionValue": { "additionalProperties": true, "description": "An extension constant value, that can check it is of a given [CustomType].", @@ -637,7 +776,11 @@ "type": "string" }, "es": { - "$ref": "#/$defs/ExtensionSet" + "items": { + "type": "string" + }, + "title": "Es", + "type": "array" } }, "required": [ @@ -671,7 +814,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "FuncDecl", @@ -692,7 +847,8 @@ }, "required": [ "parent", - "name" + "name", + "signature" ], "title": "FuncDecl", "type": "object" @@ -706,7 +862,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "FuncDefn", @@ -727,7 +895,8 @@ }, "required": [ "parent", - "name" + "name", + "signature" ], "title": "FuncDefn", "type": "object" @@ -760,7 +929,11 @@ "type": "array" }, "extension_reqs": { - "$ref": "#/$defs/ExtensionSet" + "items": { + "type": "string" + }, + "title": "Extension Reqs", + "type": "array" } }, "required": [ @@ -832,7 +1005,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Input", @@ -866,7 +1051,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Lift", @@ -928,7 +1125,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "LoadConstant", @@ -959,7 +1168,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "LoadFunction", @@ -1001,7 +1222,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "MakeTuple", @@ -1035,7 +1268,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Module", @@ -1062,7 +1307,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Noop", @@ -1289,7 +1546,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Output", @@ -1442,7 +1711,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "Tag", @@ -1507,7 +1788,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "TailLoop", @@ -1811,7 +2104,19 @@ "type": "integer" }, "input_extensions": { - "$ref": "#/$defs/ExtensionSet" + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Input Extensions" }, "op": { "const": "UnpackTuple",