def test_option_some_bind_piped(): binder: Callable[[int], Option[int]] = lambda x: Some(x + 1) xs = Some(42) ys = xs.pipe(option.bind(binder), ) for value in ys.match(Some): assert value == 43 break else: assert False
def test_option_some_bind_piped(): xs = Some(42) ys = xs.pipe(option.bind(lambda x: Some(x + 1)), ) assert ys.match( Some, lambda some: some.value == 43, _, False, )
def bind(self, xs: Option[TSource], fn: Callable[[TSource], Option[TResult]]): return option.bind(fn)(xs)
def combine(self, xs: Option[TSource], ys: Option[TSource]) -> Option[TSource]: binder: Callable[[Any], Option[TSource]] = lambda _: ys return option.bind(binder)(xs)