All files / src/typeclass RightFoldable.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41                                                                                 
import {Foldable as FO} from '@effect/typeclass'
import type {Kind, TypeLambda} from 'effect/HKT'
 
/**
 * @category type lambda
 */
export interface RightFoldableTypeLambda extends TypeLambda {
  readonly type: RightFoldable<this['Target'] & TypeLambda>
}
 
/**
 * The type of the `reduceRight` function for the foldable instance of the
 * higher-kinded datatype `F`.
 *
 * Not included in the `effect-ts`
 * [Foldable](https://github.com/Effect-TS/effect/blob/main/packages/typeclass/src/Foldable.ts)
 * typeclass but implemented for several datatypes, for example
 * [Array](https://github.com/Effect-TS/effect/blob/main/packages/effect/src/Array.ts#L2505).
 * @category typeclass
 */
export interface ReduceRight<F extends TypeLambda> {
  <A, B, R = never, O = unknown, E = unknown>(
    zero: B,
    f: (accumulator: B, value: A) => B,
  ): (self: Kind<F, R, O, E, A>) => B
  <A, B, R = never, O = unknown, E = unknown>(
    self: Kind<F, R, O, E, A>,
    zero: B,
    f: (accumulator: B, value: A) => B,
  ): B
}
 
/**
 * Adds a `reduceRight` function to
 * [Foldable](https://github.com/Effect-TS/effect/blob/main/packages/typeclass/src/Foldable.ts).
 * @category typeclass
 */
export interface RightFoldable<F extends TypeLambda> extends FO.Foldable<F> {
  readonly reduceRight: ReduceRight<F>
}