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.

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'>