Skip to content

Instantly share code, notes, and snippets.

@thomasballinger
Created June 26, 2016 04:08
Show Gist options
  • Save thomasballinger/b8c1c49585100d926a7b084866c1a466 to your computer and use it in GitHub Desktop.
Save thomasballinger/b8c1c49585100d926a7b084866c1a466 to your computer and use it in GitHub Desktop.
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