API¶
Typeclasses¶
Data Types¶
Utilities¶
-
categories.utils.
compose
(*fs) → Callable[source]¶ Return a function that is the composition of the functions in
fs
. All functions infs
must take a single argument.Adapted from this StackOverflow answer: https://stackoverflow.com/a/34713317
Example: >>> compose(f, g)(x) == f(g(x))
-
categories.utils.
flip
(f: Callable[[A, B], Any]) → Callable[[B, A], Any][source] Return a function that reverses the arguments it’s called with.
Parameters: f – A function that takes exactly two arguments
Example: >>> exp = lambda x, y: x ** y >>> flip_exp = flip(exp) >>> exp(2, 3) 8 >>> flip_exp(2, 3) 9
-
categories.utils.
unit
(x: Any) → Any¶ The identity function. Returns whatever argument it’s called with.