Created
January 28, 2022 23:34
-
-
Save antonagestam/d2bf5c5680ac21bd80c1a722a0018841 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Callable | |
from typing import TypeVar | |
from phantom.predicates.generic import equal | |
from phantom import Predicate | |
T = TypeVar("T") | |
def apply_factory(factory: Callable[[T], Predicate[T]]) -> Predicate[tuple[T, T]]: | |
def predicate(args: tuple[T, T]) -> bool: | |
return factory(args[0])(args[1]) | |
return predicate | |
assert apply_factory(equal)((1, 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment