Skip to content

Foldable

funstruct.typeclasses.foldable

Foldable — reduce a structure to a single value.

fold_left: (B, A → B) → F[A] → B fold_right: (A, B → B) → F[A] → B

Foldable

Bases: BaseTypeclass

fold_left + fold_right.

Source code in funstruct/typeclasses/foldable.py
15
16
17
18
19
20
21
22
class Foldable(BaseTypeclass):
    """fold_left + fold_right."""

    @abstractmethod
    def fold_left(self, fa, acc, f: Callable) -> object: ...

    @abstractmethod
    def fold_right(self, fa, acc, f: Callable) -> object: ...