def mask(collection, collection_ty, booleans):
    """
    Returns a masking operation that filters values from 'collection' using
    the bitvector 'booleans'.

    Examples
    --------
    >>> mask("v", "i64", "mask").code
    'map(filter(zip(v, mask), |e: {i64,bool}| e.$1), |e: {i64,bool}| e.$0)'

    """
    struct_ty = "{{{collection_ty},bool}}".format(collection_ty=collection_ty)
    template = "map(filter(zip({collection}, {mask}), |e: {struct_ty}| e.$1), |e: {struct_ty}| e.$0)"
    return template.format(collection=collection, mask=booleans, struct_ty=struct_ty)