Utility Functions¶
monad.utils - utility functions and values.
-
class
smonad.utils.SuppressContextManager(*exceptions)[source]¶ Bases:
objectContext manager class that suppress specified exceptions.
-
smonad.utils.compose(f, g)[source]¶ Function composition.
compose(f, g) -> f . g>>> add_2 = lambda a: a + 2 >>> mul_5 = lambda a: a * 5 >>> mul_5_add_2 = compose(add_2, mul_5) >>> mul_5_add_2(1) 7 >>> add_2_mul_5 = compose(mul_5, add_2) >>> add_2_mul_5(1) 15
-
smonad.utils.failed(obj)[source]¶ Return a Boolean that indicates if the value is an instance of smonad.types.ftry.Failure
>>> from smonad.types.ftry import Failure, Success >>> failed(Failure('shit is fucked up')) True >>> failed(Success('it worked!')) False