Skip to content

Instantly share code, notes, and snippets.

@antonagestam
Created January 28, 2022 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antonagestam/d2bf5c5680ac21bd80c1a722a0018841 to your computer and use it in GitHub Desktop.
Save antonagestam/d2bf5c5680ac21bd80c1a722a0018841 to your computer and use it in GitHub Desktop.
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