# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/03_tgrd.ipynb.

# %% auto 0
__all__ = ['istypeq', 'isinst', 'isinstq', 'isof']

# %% ../nbs/03_tgrd.ipynb 4
from types import NoneType
from typing import TypeGuard
from typing import Tuple, Union

# %% ../nbs/03_tgrd.ipynb 5
from .atyp import G, TypeLike

# %% ../nbs/03_tgrd.ipynb 7
def istypeq(x: G, t: TypeLike) -> TypeGuard[Union[G, NoneType]]:
    '''Check if `x` is of type `t` or `NoneType`'''
    return isinstance(x, (t, NoneType))

def isinst(x: G, t: TypeLike) -> TypeGuard[G]:
    '''Alias for `isinstance`'''
    return isinstance(x, t)

def isinstq(x: G, t: TypeLike) -> TypeGuard[Union[G, NoneType]]:
    '''Alias for `isinstance`'''
    return isinstance(x, (t, NoneType))

def isof(x: G, t: Tuple[TypeLike, ...]) -> TypeGuard[TypeLike]:
    '''Alias for `isinstance`'''
    return isinst(x, t)
