Ejemplo n.º 1
0
 def to_either(self, fa: Maybe[A],
               left: Union[B, Callable[[], B]]) -> either.Either[A, B]:
     from amino.either import Left, Right
     return fa.cata(Right, lambda: Left(call_by_name(left)))
Ejemplo n.º 2
0
 def or_else(self, fa: F, a: Union[F, Callable[[], F]]):
     return fa if self.present(fa) else maybe.call_by_name(a)
Ejemplo n.º 3
0
 def find_map_optional(self,
                       fa: Maybe[A],
                       tpe: Type[F],
                       f: Callable[[B], F[C]],
                       msg: CallByName = None) -> F[C]:
     return fa / f | (lambda: fa.absent(call_by_name(msg)))