Sum#

class hugr.tys.Sum(variant_rows: list[list[Type]])[source]#

Bases: Type

Algebraic sum-over-product type. Instances of this type correspond to tuples (products) over one of the variant_rows in the sum type, tagged by the index of the row.

Methods

as_tuple

resolve

Resolve types in the sum type using the given registry.

type_arg

The TypeTypeArg for this type.

type_bound

The bound of this type.

Attributes

variant_rows

resolve(registry: ext.ExtensionRegistry) Sum[source]#

Resolve types in the sum 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'>