How to use the pypeline.core.arrows.kleisli_arrow.KleisliArrow function in Pypeline

To help you get started, we’ve selected a few Pypeline examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ianj-als / pypeline / src / pypeline / helpers / parallel_helpers.py View on Github external
return (new_future, wrapped_state)
            return State(test_state_function)
        return test_bind_function

    def get_if_left_function(left_function):
        def if_left_function(futured_either):
            either = futured_either.result()
            if isinstance(either, Left):
                return left_function(either.val) >= (lambda a: return_(Left(a)))
            elif isinstance(either, Right):
                return return_(either)
            else:
                raise ValueError("Result of future must be of type Either")
        return if_left_function

    if_comp = KleisliArrow(return_, get_test_bind_function()) >> \
              ((KleisliArrowChoice(return_, get_if_left_function(then_component._func)) >> \
                KleisliArrowChoice(return_, else_component._func).right()) >> \
               KleisliArrow(return_, lambda either: return_(either.val)))

    return if_comp