def typed_masses_to_spans(typed_masses):
    """ Converts typed segmentations in the masses format to spans.

    The resulting spans are non-overlapping and in linear order.

    >>> list(typed_masses_to_spans([(1, 'A'), (1, 'B'), (1, 'C')]))
    [(0, 1, 'A'), (1, 1, 'B'), (2, 1, 'C')]
    >>> list(typed_masses_to_spans([(3, 'A'), (2, 'B'), (1, 'C')]))
    [(0, 3, 'A'), (3, 2, 'B'), (5, 1, 'C')]
    >>> list(typed_masses_to_spans([(1, 'A'), (2, 'B'), (3, 'C')]))
    [(0, 1, 'A'), (1, 2, 'B'), (3, 3, 'C')]
    """
    start = 0
    for length, cat in typed_masses:
        yield start, length, cat
        start += length
