"""Guppy standard library for future type and its operations"""fromtypingimportGeneric,no_type_checkfromguppylang_internals.decoratorimportcustom_type,hugr_opfromguppylang_internals.std._internal.compiler.futuresimportfuture_op,future_to_hugrfromguppylang_internals.tys.paramimportTypeParamfromguppylangimportguppyfromguppylang.std.langimportownedT=guppy.type_var("T",copyable=False,droppable=False)_future_params=[TypeParam(0,"T",must_be_copyable=False,must_be_droppable=False)]
[docs]@custom_type(future_to_hugr,copyable=False,droppable=False,params=_future_params)classFuture(Generic[T]):# type: ignore[misc]"""A value of type `T` that is computed asynchronously."""
[docs]@hugr_op(future_op("Read"))@no_type_checkdefread(self:"Future[T]"@owned)->T:"""Reads a value from a future, consuming it."""
[docs]@hugr_op(future_op("Dup"))@no_type_checkdefcopy(self:"Future[T]")->"Future[T]":"""Duplicate a future."""
[docs]@hugr_op(future_op("Free"))@no_type_checkdefdiscard(self:"Future[T]"@owned)->None:"""Discards a future without reading it."""