StdioDefines the service interface for process standard I/O.
When to use
Use to depend on command-line arguments and standard I/O through the Effect environment.
Details
The service provides command-line arguments, sinks for standard output and
standard error, and a stream of standard input bytes. I/O operations can fail
with PlatformError.
export interface Stdio {
readonly [const TypeId: TypeIdString literal type used as the unique brand for the Stdio service.
When to use
Use to type the runtime identifier stored on Stdio service implementations.
Runtime identifier stored on Stdio service implementations.
Details
This marker is part of the runtime representation of Stdio service
implementations.
TypeId]: type TypeId = "~effect/Stdio"String literal type used as the unique brand for the Stdio service.
When to use
Use to type the runtime identifier stored on Stdio service implementations.
Runtime identifier stored on Stdio service implementations.
Details
This marker is part of the runtime representation of Stdio service
implementations.
TypeId
readonly Stdio.args: Effect.Effect<ReadonlyArray<string>>(property) Stdio.args: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
args: import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<interface ReadonlyArray<T>ReadonlyArray<string>>
Stdio.stdout(options?: { readonly endOnDone?: boolean | undefined }): Sink.Sink<void, string | Uint8Array, never, PlatformError>stdout(options: | {
readonly endOnDone?: boolean | undefined
}
| undefined
options?: {
readonly endOnDone?: boolean | undefinedendOnDone?: boolean | undefined
}): import SinkSink.type Sink.Sink = /*unresolved*/ anySink<void, string | interface Uint8Array<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike>A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
requested number of bytes could not be allocated an exception is raised.
Uint8Array, never, import PlatformErrorPlatformError>
Stdio.stderr(options?: { readonly endOnDone?: boolean | undefined }): Sink.Sink<void, string | Uint8Array, never, PlatformError>stderr(options: | {
readonly endOnDone?: boolean | undefined
}
| undefined
options?: {
readonly endOnDone?: boolean | undefinedendOnDone?: boolean | undefined
}): import SinkSink.type Sink.Sink = /*unresolved*/ anySink<void, string | interface Uint8Array<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike>A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
requested number of bytes could not be allocated an exception is raised.
Uint8Array, never, import PlatformErrorPlatformError>
readonly Stdio.stdin: Stream.Stream<Uint8Array, PlatformError>(property) Stdio.stdin: {
channel: Channel.Channel<Arr.NonEmptyReadonlyArray<A>, E, void, unknown, unknown, unknown, R>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
stdin: import StreamStream.interface Stream<out A, out E = never, out R = never>A Stream<A, E, R> describes a program that can emit many A values, fail
with E, and require R.
Details
Streams are pull-based with backpressure and emit chunks to amortize effect
evaluation. They support monadic composition and error handling similar to
Effect, adapted for multiple values.
Example (Creating and consuming streams)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
yield* Stream.make(1, 2, 3).pipe(
Stream.map((n) => n * 2),
Stream.runForEach((n) => Console.log(n))
)
})
Effect.runPromise(program)
// Output:
// 2
// 4
// 6
Stream<interface Uint8Array<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike>A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
requested number of bytes could not be allocated an exception is raised.
Uint8Array, import PlatformErrorPlatformError>
}
/**
* Service tag for process standard I/O.
*
* **When to use**
*
* Use when you need command-line arguments or standard I/O streams supplied by
* an effect's environment.
*
* @see {@link make} for constructing a `Stdio` service directly
* @see {@link layerTest} for a test layer with defaults and overrides
*
* @category services
* @since 4.0.0
*/
export const const Stdio: Context.Service<Stdio, Stdio>const Stdio: {
key: string;
Service: {
args: Effect.Effect<ReadonlyArray<string>>;
stdout: (options?: { readonly endOnDone?: boolean | undefined }) => Sink.Sink<void, string | Uint8Array, never, PlatformError>;
stderr: (options?: { readonly endOnDone?: boolean | undefined }) => Sink.Sink<void, string | Uint8Array, never, PlatformError>;
stdin: Stream.Stream<Uint8Array, PlatformError>;
};
of: (this: void, self: Stdio) => Stdio;
context: (self: Stdio) => Context.Context<Stdio>;
use: (f: (service: Stdio) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Stdio | R>;
useSync: (f: (service: Stdio) => A) => Effect.Effect<A, never, Stdio>;
Identifier: Identifier;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
Defines the service interface for process standard I/O.
When to use
Use to depend on command-line arguments and standard I/O through the Effect
environment.
Details
The service provides command-line arguments, sinks for standard output and
standard error, and a stream of standard input bytes. I/O operations can fail
with PlatformError.
Service tag for process standard I/O.
When to use
Use when you need command-line arguments or standard I/O streams supplied by
an effect's environment.
Stdio: import ContextContext.type Context.Service = /*unresolved*/ anyService<Stdio, Stdio> = import ContextContext.Service<Stdio>(const TypeId: TypeIdString literal type used as the unique brand for the Stdio service.
When to use
Use to type the runtime identifier stored on Stdio service implementations.
Runtime identifier stored on Stdio service implementations.
Details
This marker is part of the runtime representation of Stdio service
implementations.
TypeId)