Add p_instance
This commit is contained in:
parent
439fc91fc9
commit
da35286207
|
@ -1,7 +1,7 @@
|
|||
from dataclasses import dataclass
|
||||
from functools import partial, wraps
|
||||
from operator import not_
|
||||
from typing import Any, Callable, Concatenate, Generic, Iterable, Iterator, List, ParamSpec, Sequence, Tuple, TypeVar
|
||||
from typing import Any, Callable, Concatenate, Generic, Iterable, Iterator, List, ParamSpec, Sequence, Tuple, Type, TypeGuard, TypeVar
|
||||
|
||||
A = TypeVar('A')
|
||||
B = TypeVar('B')
|
||||
|
@ -150,6 +150,10 @@ def p_filter(f: Callable[[A], bool]) -> Callable[[Sequence[A]], Sequence[A]]:
|
|||
"A curried version of the built in `filter` function"
|
||||
return partial(filter,f) #type: ignore
|
||||
|
||||
def p_instance(c: Type[A]) -> Callable[[Any], TypeGuard[A]]:
|
||||
"A curried version of the built in `is_instance` function"
|
||||
return flip(cur2(isinstance))(c) #type: ignore
|
||||
|
||||
# Normal Accessors
|
||||
@cur2
|
||||
def indx(i: int, s: Sequence[A]) -> A:
|
||||
|
|
Loading…
Reference in a new issue