import { Eval, Kind, TyK, $type, TyVar } from '@fp4ts/core'; import { Monoid } from '@fp4ts/cats-kernel'; import { Monad } from './monad'; import { MonoidK } from './monoid-k'; import { UnorderedFoldable } from './unordered-foldable'; import { Option } from './data'; import { ComposedFoldable } from './composed'; import { ArrayF } from './instances/array'; /** * @category Type Class */ export interface Foldable extends UnorderedFoldable { /** * Right associative, lazy fold mapping each element of the structure `Kind` * into a monoid `M` and combining their results using `combineEval`. * * For a strict version, see `foldMapLeft`. */ foldMap(M: Monoid): (f: (a: A) => M) => (fa: Kind) => M; /** * Right associative, lazy fold mapping each element of the structure `Kind` * into a monoid `M` and combining their results using `combineEval`. * * For a strict version, see `foldMapLeft`. */ foldMap_(M: Monoid): (fa: Kind, f: (a: A) => M) => M; /** * Left associative, strict variant of the `foldMap` using monoid's `combine` * operator to combine results. */ foldMapLeft(M: Monoid): (f: (a: A) => M) => (fa: Kind) => M; /** * Left associative, strict variant of the `foldMap` using monoid's `combine` * operator to combine results. */ foldMapLeft_(M: Monoid): (fa: Kind, f: (a: A) => M) => M; /** * Right associative, lazy fold of the structure into a lazy accumulated value * `Eval`. */ foldRight(b: Eval, f: (a: A, b: Eval) => Eval): (fa: Kind) => Eval; /** * Right associative, lazy fold of the structure into a lazy accumulated value * `Eval`. */ foldRight_(fa: Kind, b: Eval, f: (a: A, b: Eval) => Eval): Eval; /** * Left associative, strict fold of the structure into an accumulated value `B`. */ foldLeft(b: B, f: (b: B, a: A) => B): (fa: Kind) => B; /** * Left associative, strict fold of the structure into an accumulated value `B`. */ foldLeft_(fa: Kind, b: B, f: (b: B, a: A) => B): B; foldMapK(G: MonoidK): (f: (a: A) => Kind) => (fa: Kind) => Kind; foldMapK_(G: MonoidK): (fa: Kind, f: (a: A) => Kind) => Kind; foldM(G: Monad): (z: B, f: (b: B, a: A) => Kind) => (fa: Kind) => Kind; foldM_(G: Monad): (fa: Kind, z: B, f: (b: B, a: A) => Kind) => Kind; elem(idx: number): (fa: Kind) => Option; elem_(fa: Kind, idx: number): Option; get(idx: number): (fa: Kind) => Option; get_(fa: Kind, idx: number): Option; iterator(fa: Kind): Iterator; toArray(fa: Kind): A[]; } export type FoldableRequirements = (Pick, 'foldMap_'> | Pick, 'foldRight_'>) & Partial>; export declare const Foldable: Readonly<{ of: (F: FoldableRequirements) => Foldable; compose: (F: Foldable, G: Foldable) => ComposedFoldable; readonly Array: Foldable; }>; export interface FoldableF extends TyK<[unknown]> { [$type]: Foldable>; } //# sourceMappingURL=foldable.d.ts.map