"""Operations on booleans."""# mypy: disable-error-code="empty-body, misc, override, valid-type, no-untyped-def"from__future__importannotationsfromtypingimportno_type_checkfromguppylang_internals.decoratorimportcustom_function,extend_type,hugr_opfromguppylang_internals.definition.customimportNoopCompilerfromguppylang_internals.std._internal.checkerimportDunderCheckerfromguppylang_internals.std._internal.utilimportbool_logic_opfromguppylang_internals.tys.builtinimportbool_type_deffromguppylangimportguppyfromguppylang.std.numimportnat
[docs]@extend_type(bool_type_def)classbool:"""Booleans representing truth values. The bool type has exactly two constant instances: ``True`` and ``False``. The bool constructor takes a single argument and converts it to ``True`` or ``False`` using the standard truth testing procedure. """
[docs]@guppy@no_type_checkdef__nat__(self:bool)->nat:# TODO: Type information doesn't flow through the `if` expression, so we# have to insert the `nat` coercions by hand.# See https://github.com/CQCL/guppylang/issues/707returnnat(1)ifselfelsenat(0)