PolyFuncType#

class hugr.tys.PolyFuncType(params: list[TypeParam], body: FunctionType)[source]#

Bases: Type

Polymorphic function type or type scheme. Defined by a list of type parameters that may appear in the FunctionType body.

Methods

empty

Generate an empty polymorphic function type.

resolve

Resolve types in the polymorphic function type using the given registry.

to_model

Convert the type to a model Term.

type_arg

The TypeTypeArg for this type.

type_bound

The bound of this type.

with_runtime_reqs

Adds a list of extension requirements to the function type, and returns the new signature.

Attributes

params

body

classmethod empty() PolyFuncType[source]#

Generate an empty polymorphic function type.

Example

>>> PolyFuncType.empty()
PolyFuncType(params=[], body=FunctionType([], []))
resolve(registry: ext.ExtensionRegistry) PolyFuncType[source]#

Resolve types in the polymorphic function type using the given registry.

to_model() Term[source]#

Convert the type to a model Term.

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]) PolyFuncType[source]#

Adds a list of extension requirements to the function type, and returns the new signature.