FunctionType#
- class hugr.tys.FunctionType(input: list[~hugr.tys.Type], output: list[~hugr.tys.Type], extension_reqs: list[str] = <factory>)[source]#
Bases:
Type
A function type, defined by input types, output types and extension requirements.
Methods
Generate an empty function type.
Function type with the same input and output types.
Return a new function type with input and output types swapped.
Resolve types in the function type using the given registry.
The
TypeTypeArg
for this type.The bound of this type.
Attributes
input
output
extension_reqs
- classmethod empty() FunctionType [source]#
Generate an empty function type.
Example
>>> FunctionType.empty() FunctionType([], [])
- classmethod endo(tys: list[Type], extension_reqs: list[str] | None = None) FunctionType [source]#
Function type with the same input and output types.
Example
>>> FunctionType.endo([Qubit]) FunctionType([Qubit], [Qubit])
- flip() FunctionType [source]#
Return a new function type with input and output types swapped.
Example
>>> FunctionType([Qubit], [Bool]).flip() FunctionType([Bool], [Qubit])
- resolve(registry: ext.ExtensionRegistry) FunctionType [source]#
Resolve types in the function type using the given registry.
- type_arg() TypeTypeArg #
The
TypeTypeArg
for this type.Example
>>> Qubit.type_arg() TypeTypeArg(ty=Qubit)