# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/99_misc.ipynb.

# %% auto 0
__all__ = ['allinstance', 'allsametype', 'isin', 'arein']

# %% ../nbs/99_misc.ipynb 4
from typing import Type, Union, Callable, Literal, Iterable, TypeAlias, TypeGuard
from .core import isiter

# %% ../nbs/99_misc.ipynb 6
def allinstance(vals: Iterable, dtype: Union[Type, TypeAlias], isfunc: Callable = isinstance) -> bool:
    return isiter(vals) and all(isfunc(val, dtype) for val in vals)

def allsametype(vals: Iterable, isfunc: Callable = isinstance) -> bool:
    if not isiter(vals) or len(vals) == 0: return True    
    return allinstance(vals, type(vals[0]), isfunc)

def isin(val, refs: Iterable) -> bool: 
    return val in refs

def arein(vals: Iterable, refs: Iterable) -> bool:                                             
    return isiter(vals) and isiter(refs) and all(isin(v, refs) for v in vals)
