import "../../../Operator"
import * as Chunk from "../../../Collections/Immutable/Chunk"
import * as T from "../../../Effect"
import type { Predicate } from "../../../Function"
import * as C from "../Channel"
/**
 * Sink is a data type that represent a channel that reads elements
 * of type `In`, handles input errors of type `InErr`, emits errors
 * of type `OutErr`, emits outputs of type `L` and ends with a value
 * of type `Z`.
 */
export declare class Sink<R, InErr, In, OutErr, L, Z> {
  readonly channel: C.Channel<
    R,
    InErr,
    Chunk.Chunk<In>,
    unknown,
    OutErr,
    Chunk.Chunk<L>,
    Z
  >
  constructor(
    channel: C.Channel<R, InErr, Chunk.Chunk<In>, unknown, OutErr, Chunk.Chunk<L>, Z>
  )
}
/**
 * A sink that collects all of its inputs into a chunk.
 */
export declare function collectAll<Err, A>(): Sink<
  unknown,
  Err,
  A,
  Err,
  never,
  Chunk.Chunk<A>
>
/**
 * A sink that ignores all of its inputs.
 */
export declare function drain<Err, A>(): Sink<unknown, Err, A, Err, never, void>
/**
 * A sink that executes the provided effectful function for every element fed to it
 * until `f` evaluates to `false`.
 */
export declare function forEachWhile<R, ErrIn, ErrOut, In>(
  f: (_in: In) => T.Effect<R, ErrOut, boolean>
): Sink<R, ErrIn, In, ErrIn | ErrOut, In, void>
/**
 * A sink that executes the provided effectful function for every element fed to it.
 */
export declare function forEach<R, ErrIn, ErrOut, In, B>(
  f: (_in: In) => T.Effect<R, ErrOut, B>
): Sink<R, ErrIn, In, ErrIn | ErrOut, In, void>
/**
 * A sink that folds its inputs with the provided function, termination predicate and initial state.
 */
export declare function reduce<S>(
  z: S
): (
  cont: Predicate<S>
) => <In, Err>(f: (s: S, _in: In) => S) => Sink<unknown, Err, In, Err, In, S>
/**
 * A sink that effectfully folds its inputs with the provided function, termination predicate and initial state.
 */
export declare function reduceM<S>(
  z: S
): (
  cont: Predicate<S>
) => <Env, In, Err>(
  f: (s: S, _in: In) => T.Effect<Env, Err, S>
) => Sink<Env, Err, In, Err, In, S>
/**
 * A sink that executes the provided effectful function for every chunk fed to it.
 */
export declare function forEachChunk<R, ErrIn, ErrOut, In, Z>(
  f: (c: Chunk.Chunk<In>) => T.Effect<R, ErrOut, Z>
): Sink<R, ErrIn, In, ErrIn | ErrOut, unknown, void>
/**
 * A sink that executes the provided effectful function for every chunk fed to it
 * until `f` evaluates to `false`.
 */
export declare function forEachChunkWhile<R, ErrIn, ErrOut, In>(
  f: (_in: Chunk.Chunk<In>) => T.Effect<R, ErrOut, boolean>
): Sink<R, ErrIn, In, ErrIn | ErrOut, unknown, void>
/**
 * Runs this sink until it yields a result, then uses that result to create another
 * sink from the provided function which will continue to run until it yields a result.
 *
 * This function essentially runs sinks in sequence.
 */
export declare function chain_<
  R,
  R1,
  InErr,
  InErr1,
  In,
  In1 extends In,
  OutErr,
  OutErr1,
  L,
  L1 extends L,
  Z,
  Z1
>(
  self: Sink<R, InErr, In, OutErr, L, Z>,
  f: (z: Z) => Sink<R1, InErr1, In1, OutErr1, L1, Z1>
): Sink<R & R1, InErr & InErr1, In & In1, OutErr | OutErr1, L1, Z1>
/**
 * Runs this sink until it yields a result, then uses that result to create another
 * sink from the provided function which will continue to run until it yields a result.
 *
 * This function essentially runs sinks in sequence.
 *
 * @dataFirst chain_
 */
export declare function chain<
  R1,
  InErr1,
  In,
  In1 extends In,
  OutErr1,
  L,
  L1 extends L,
  Z,
  Z1
>(
  f: (z: Z) => Sink<R1, InErr1, In1, OutErr1, L1, Z1>
): <R, InErr, OutErr>(
  self: Sink<R, InErr, In, OutErr, L, Z>
) => Sink<R & R1, InErr & InErr1, In & In1, OutErr1 | OutErr, L1, Z1>
export declare function foldM_<
  R,
  R1,
  R2,
  InErr,
  InErr1,
  InErr2,
  In,
  In1 extends In,
  In2 extends In,
  OutErr,
  OutErr2,
  OutErr3,
  L,
  L1 extends L,
  L2 extends L,
  Z,
  Z1,
  Z2
>(
  self: Sink<R, InErr, In, OutErr, L, Z>,
  failure: (err: OutErr) => Sink<R1, InErr1, In1, OutErr2, L1, Z1>,
  success: (z: Z) => Sink<R2, InErr2, In2, OutErr3, L2, Z2>
): Sink<
  R & R1 & R2,
  InErr & InErr1 & InErr2,
  In1 & In2,
  OutErr2 | OutErr3,
  L1 | L2,
  Z1 | Z2
>
/**
 *
 * @dataFirst foldM_
 */
export declare function foldM<
  R1,
  R2,
  InErr1,
  InErr2,
  In,
  In1 extends In,
  In2 extends In,
  OutErr,
  OutErr2,
  OutErr3,
  L,
  L1 extends L,
  L2 extends L,
  Z,
  Z1,
  Z2
>(
  failure: (err: OutErr) => Sink<R1, InErr1, In1, OutErr2, L1, Z1>,
  success: (z: Z) => Sink<R2, InErr2, In2, OutErr3, L2, Z2>
): <R, InErr>(
  self: Sink<R, InErr, In, OutErr, L, Z>
) => Sink<
  R & R1 & R2,
  InErr & InErr1 & InErr2,
  In1 & In2,
  OutErr2 | OutErr3,
  L1 | L2,
  Z1 | Z2
>
/**
 * A sink that always fails with the specified error.
 */
export declare function fail<E>(e: E): Sink<unknown, unknown, unknown, E, never, never>
//# sourceMappingURL=index.d.ts.map
