Skip to content

Instantly share code, notes, and snippets.

@arsalan0c
Created February 11, 2021 17:02
Show Gist options
  • Save arsalan0c/d6d3eb28ef4bc7b9a6405253680f814b to your computer and use it in GitHub Desktop.
Save arsalan0c/d6d3eb28ef4bc7b9a6405253680f814b to your computer and use it in GitHub Desktop.
from typing import Callable
from typing import TypeVar
A = TypeVar('A')
B = TypeVar('B')
def apply(f: Callable[[A],B], a: A):
return f(a)
def fst(a: A, b: B):
return a
def a(n):
return n
apply(a, 10)
fst(10, "str")
from typing import Union
def Add(a: Union[str, int], b: Union[str, int]) -> Union[str, int]:
return a + b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment