def set_of(cls):
    """
    Returns a function that checks that each element in a
    set is of a specific type.
    """
    return lambda l: isinstance(l, set) and all(isinstance(x, cls) for x in l)
Returns a function that checks that each element in a
    set is of a specific type.