FunctionType¶
- class hugr.tys.FunctionType(input: list[Type], output: list[Type])[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.
Convert the type to a model Term.
The
TypeTypeArg
for this type.The bound of this type.
Attributes
input
output
- classmethod empty() FunctionType [source]¶
Generate an empty function type.
Example
>>> FunctionType.empty() FunctionType([], [])
- classmethod endo(tys: list[Type]) 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)