import "../../../Operator"
import * as Chunk from "../../../Collections/Immutable/Chunk"
import type * as Tp from "../../../Collections/Immutable/Tuple"
import * as T from "../../../Effect"
import type * as Exit from "../../../Exit"
import * as M from "../../../Managed"
import * as O from "../../../Option"
import * as C from "../Channel"
import * as Sink from "../Sink"
export declare const StreamTypeId: unique symbol
export declare type StreamTypeId = typeof StreamTypeId
/**
 * A `Stream<R, E, A>` is a description of a program that, when evaluated,
 * may emit 0 or more values of type `A`, may fail with errors of type `E`
 * and uses an environment of type `R`.
 * One way to think of `Stream` is as a `Effect` program that could emit multiple values.
 *
 * `Stream` is a purely functional *pull* based stream. Pull based streams offer
 * inherent laziness and backpressure, relieving users of the need to manage buffers
 * between operators. As an optimization, `Stream` does not emit single values, but
 * rather an array of values. This allows the cost of effect evaluation to be
 * amortized.
 *
 * `Stream` forms a monad on its `A` type parameter, and has error management
 * facilities for its `E` type parameter, modeled similarly to `Effect` (with some
 * adjustments for the multiple-valued nature of `Stream`). These aspects allow
 * for rich and expressive composition of streams.
 */
export declare class Stream<R, E, A> {
  readonly channel: C.Channel<R, unknown, unknown, unknown, E, Chunk.Chunk<A>, unknown>
  readonly _typeId: StreamTypeId;
  readonly [T._R]: (_: R) => void;
  readonly [T._E]: () => E;
  readonly [T._A]: () => A
  constructor(
    channel: C.Channel<R, unknown, unknown, unknown, E, Chunk.Chunk<A>, unknown>
  )
}
/**
 * Empty stream
 */
export declare const empty: Stream<unknown, never, never>
/**
 * Returns a stream made of the concatenation in strict order of all the streams
 * produced by passing each element of this stream to `f`
 */
export declare function chain_<R, E, O, R1, E1, O1>(
  self: Stream<R, E, O>,
  f: (o: O) => Stream<R1, E1, O1>
): Stream<R & R1, E | E1, O1>
/**
 * Returns a stream made of the concatenation in strict order of all the streams
 * produced by passing each element of this stream to `f`
 *
 * @dataFirst chain_
 */
export declare function chain<O, R1, E1, O1>(
  f: (o: O) => Stream<R1, E1, O1>
): <R, E>(self: Stream<R, E, O>) => Stream<R & R1, E | E1, O1>
/**
 * Combines the chunks from this stream and the specified stream by repeatedly applying the
 * function `f` to extract a chunk using both sides and conceptually "offer"
 * it to the destination stream. `f` can maintain some internal state to control
 * the combining process, with the initial state being specified by `s`.
 */
export declare function combineChunks_<R, E, A, R1, E1, A1, S, R2, A2>(
  self: Stream<R, E, A>,
  that: Stream<R1, E1, A1>,
  s: S,
  f: (
    s: S,
    l: T.Effect<R, O.Option<E>, Chunk.Chunk<A>>,
    r: T.Effect<R1, O.Option<E1>, Chunk.Chunk<A1>>
  ) => T.Effect<R2, never, Exit.Exit<O.Option<E | E1>, Tp.Tuple<[Chunk.Chunk<A2>, S]>>>
): Stream<R1 & R & R2, E | E1, A2>
/**
 * Combines the chunks from this stream and the specified stream by repeatedly applying the
 * function `f` to extract a chunk using both sides and conceptually "offer"
 * it to the destination stream. `f` can maintain some internal state to control
 * the combining process, with the initial state being specified by `s`.
 *
 * @dataFirst combineChunks_
 */
export declare function combineChunks<R, E, A, R1, E1, A1, S, R2, A2>(
  that: Stream<R1, E1, A1>,
  s: S,
  f: (
    s: S,
    l: T.Effect<R, O.Option<E>, Chunk.Chunk<A>>,
    r: T.Effect<R1, O.Option<E1>, Chunk.Chunk<A1>>
  ) => T.Effect<R2, never, Exit.Exit<O.Option<E | E1>, Tp.Tuple<[Chunk.Chunk<A2>, S]>>>
): (self: Stream<R, E, A>) => Stream<R1 & R & R2, E | E1, A2>
/**
 * Halt a stream with the specified exception
 */
export declare function die(u: unknown): Stream<unknown, never, never>
/**
 * Halt a stream with the specified exception
 */
export declare function dieWith(u: () => unknown): Stream<unknown, never, never>
/**
 * Halt a stream with the specified error
 */
export declare function fail<E>(error: E): Stream<unknown, E, never>
/**
 * Halt a stream with the specified error
 */
export declare function failWith<E>(error: () => E): Stream<unknown, E, never>
/**
 * Repeats this stream forever.
 */
export declare function forever<R, E, A>(self: Stream<R, E, A>): Stream<R, E, A>
/**
 * Creates a stream from a `Chunk` of values
 *
 * @param c a chunk of values
 * @return a finite stream of values
 */
export declare function fromChunk<O>(c: Chunk.Chunk<O>): Stream<unknown, never, O>
/**
 * Creates a stream from a `Chunk` of values
 *
 * @param c a chunk of values
 * @return a finite stream of values
 */
export declare function fromChunkWith<O>(
  c: () => Chunk.Chunk<O>
): Stream<unknown, never, O>
/**
 * Creates a stream from an effect producing a value of type `A`
 */
export declare function effect<R, E, A>(self: T.Effect<R, E, A>): Stream<R, E, A>
/**
 * Creates a stream from an effect producing a value of type `A` or an empty Stream
 */
export declare function effectOption<R, E, A>(
  self: T.Effect<R, O.Option<E>, A>
): Stream<R, E, A>
/**
 * Creates a single-valued stream from a managed resource
 */
export declare function managed<R, E, A>(self: M.Managed<R, E, A>): Stream<R, E, A>
/**
 * Maps over elements of the stream with the specified effectful function.
 */
export declare function mapM_<R, E, A, R1, E1, B>(
  self: Stream<R, E, A>,
  f: (a: A) => T.Effect<R1, E1, B>
): Stream<R & R1, E | E1, B>
/**
 * Maps over elements of the stream with the specified effectful function.
 *
 * @dataFirst mapM_
 */
export declare function mapM<A, R1, E1, B>(
  f: (a: A) => T.Effect<R1, E1, B>
): <R, E>(self: Stream<R, E, A>) => Stream<R & R1, E | E1, B>
/**
 * Flattens this stream-of-streams into a stream made of the concatenation in
 * strict order of all the streams.
 */
export declare function flatten<R0, E0, R, E, A>(
  self: Stream<R0, E0, Stream<R, E, A>>
): Stream<R0 & R, E0 | E, A>
/**
 * Loops over the stream chunks concatenating the result of f
 */
export declare function loopOnChunks_<R, E, A, R1, E1, A1>(
  self: Stream<R, E, A>,
  f: (
    a: Chunk.Chunk<A>
  ) => C.Channel<R1, E | E1, Chunk.Chunk<A>, unknown, E | E1, Chunk.Chunk<A1>, boolean>
): Stream<R & R1, E | E1, A1>
/**
 * Loops on chunks emitting partially
 */
export declare function loopOnPartialChunks_<R, E, A, R1, E1, A1>(
  self: Stream<R, E, A>,
  f: (a: Chunk.Chunk<A>, emit: (a: A1) => T.UIO<void>) => T.Effect<R1, E1, boolean>
): Stream<R & R1, E | E1, A1>
/**
 * Loops on chunks elements emitting partially
 */
export declare function loopOnPartialChunksElements_<R, E, A, R1, E1, A1>(
  self: Stream<R, E, A>,
  f: (a: A, emit: (a: A1) => T.UIO<void>) => T.Effect<R1, E1, void>
): Stream<R & R1, E | E1, A1>
/**
 * Transforms the elements of this stream using the supplied function.
 */
export declare function map_<R, E, O, O1>(
  self: Stream<R, E, O>,
  f: (o: O) => O1
): Stream<R, E, O1>
/**
 * Transforms the elements of this stream using the supplied function.
 *
 * @dataFirst map_
 */
export declare function map<O, O1>(
  f: (o: O) => O1
): <R, E>(self: Stream<R, E, O>) => Stream<R, E, O1>
/**
 * Runs the sink on the stream to produce either the sink's result or an error.
 */
export declare function run_<R, E, A, R2, E2, Z>(
  self: Stream<R, E, A>,
  sink: Sink.Sink<R2, E, A, E2, unknown, Z>
): T.Effect<R & R2, E2, Z>
/**
 * Runs the sink on the stream to produce either the sink's result or an error.
 *
 * @dataFirst run_
 */
export declare function run<E, A, R2, E2, Z>(
  sink: Sink.Sink<R2, E, A, E2, unknown, Z>
): <R>(self: Stream<R, E, A>) => T.Effect<R & R2, E2, Z>
/**
 * Runs the stream and collects all of its elements to a chunk.
 */
export declare function runCollect<R, E, A>(
  self: Stream<R, E, A>
): T.Effect<R, E, Chunk.Chunk<A>>
/**
 * Runs the stream and collects ignore its elements.
 */
export declare function runDrain<R, E, A>(self: Stream<R, E, A>): T.Effect<R, E, void>
/**
 * Creates a single-valued pure stream
 */
export declare function succeed<O>(o: O): Stream<unknown, never, O>
/**
 * Creates a single-valued pure stream
 */
export declare function succeedWith<O>(o: () => O): Stream<unknown, never, O>
/**
 * Takes the specified number of elements from this stream.
 */
export declare function take_<R, E, A>(
  self: Stream<R, E, A>,
  n: number
): Stream<R, E, A>
/**
 * Takes the specified number of elements from this stream.
 *
 * @dataFirst take_
 */
export declare function take(
  n: number
): <R, E, A>(self: Stream<R, E, A>) => Stream<R, E, A>
/**
 * Interpret the stream as a managed pull
 */
export declare function toPull<R, E, A>(
  self: Stream<R, E, A>
): M.Managed<R, never, T.Effect<R, O.Option<E>, Chunk.Chunk<A>>>
/**
 * Creates a stream by effectfully peeling off the "layers" of a value of type `S`
 */
export declare function unfoldChunksM<R, E, A, S>(
  s: S,
  f: (s: S) => T.Effect<R, E, O.Option<Tp.Tuple<[Chunk.Chunk<A>, S]>>>
): Stream<R, E, A>
/**
 * Creates a stream produced from an effect
 */
export declare function unwrap<R0, E0, R, E, A>(
  self: T.Effect<R0, E0, Stream<R, E, A>>
): Stream<R0 & R, E0 | E, A>
/**
 * Creates a stream produced from a managed
 */
export declare function unwrapManaged<R0, E0, R, E, A>(
  self: M.Managed<R0, E0, Stream<R, E, A>>
): Stream<R0 & R, E0 | E, A>
//# sourceMappingURL=core.d.ts.map
