FunctionType#
- class hugr.tys.FunctionType(input: list[~hugr.tys.Type], output: list[~hugr.tys.Type], runtime_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.
Adds a list of extension requirements to the function type, and returns the new signature.
Attributes
input
output
runtime_reqs
- classmethod empty() FunctionType [source]#
Generate an empty function type.
Example
>>> FunctionType.empty() FunctionType([], [])
- classmethod endo(tys: list[Type], runtime_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)
- type_bound() TypeBound [source]#
The bound of this type.
Example
>>> Tuple(Bool, Bool).type_bound() <TypeBound.Copyable: 'C'> >>> Tuple(Qubit, Bool).type_bound() <TypeBound.Any: 'A'>
- with_runtime_reqs(runtime_reqs: list[str]) FunctionType [source]#
Adds a list of extension requirements to the function type, and returns the new signature.