def flat_map( self, f: Callable[[A, B], Maybe[Tuple[C, D]]] ) -> 'Map[C, D]': filtered = List.wrap([f(a, b) for a, b in self.items()])\ .join return Map(filtered)
def _drain_find(self, abort): culprit = Empty() def gen(): nonlocal culprit while True: try: el = next(self.source) yield el if abort(el): culprit = Just(el) break except StopIteration: break drained = List.wrap(list(gen())) self.strict = self.strict + drained return culprit
def map2(self, f: Callable[[A, B], C]) -> List[C]: return List.wrap([f(a, b) for a, b in self.items()])
def get_all_map(self, *keys): def append(zm, k): return zm // (lambda z: self.get_item(k) / z.cat) return List.wrap(keys).fold_left(Just(Map()))(append)
def values_at(self, *keys): return List.wrap(keys) // self.get
def to_list(self): return List.wrap(self.items())