Skip to content

Instantly share code, notes, and snippets.

Created June 26, 2016 04:08
What would you like to do?
from typing import Callable
class A: pass
class B: pass
class C: pass
def composition(aToB: Callable[[A], B],
bToC: Callable[[B], C]) -> Callable[[A], C]:
"""Returns a callable that takes an A and returns a C"""
def aToC(a: A) -> C:
return bToC(aToB(a))
return aToC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment