get_first_sum#
- hugr.tys.get_first_sum(types: list[Type]) tuple[Sum, list[Type]] [source]#
Check the first type in a row of types is a
Sum
, returning it and the rest.- Parameters:
types – row of types.
- Raises:
AssertionError – if the first type is not a
Sum
.
Example
>>> get_first_sum([UnitSum(3), Qubit]) (UnitSum(3), [Qubit]) >>> get_first_sum([Qubit, UnitSum(3)]) Traceback (most recent call last): AssertionError: Expected Sum, got Qubit