TypeDef#
- class hugr.ext.TypeDef(name: str, description: str, params: list[TypeParam], bound: ExplicitBound | FromParamsBound)[source]#
Bases:
ExtensionObject
Type definition in an
Extension
.Examples
>>> td = TypeDef( ... name="MyType", ... description="A type definition.", ... params=[tys.TypeTypeParam(tys.Bool)], ... bound=ExplicitBound(tys.TypeBound.Copyable), ... ) >>> td.name 'MyType'
Methods
Retrieve the extension associated with the object.
Instantiate a concrete type from this type definition.
Attributes
The name of the type.
A description of the type.
The type parameters of the type if polymorphic.
The type bound of the type.
- bound: ExplicitBound | FromParamsBound#
The type bound of the type.
- get_extension() Extension #
Retrieve the extension associated with the object.
- Returns:
The extension associated with the object.
- Raises:
NoParentExtension – If the object is not associated with an extension.
- instantiate(args: Sequence[tys.TypeArg]) tys.ExtType [source]#
Instantiate a concrete type from this type definition.
- Parameters:
args – Type arguments corresponding to the type parameters of the definition.