<A, B>(f: (a: A) => Effect.Effect<B, ConfigError>): (
self: Config<A>
) => Config<B>
<A, B>(
self: Config<A>,
f: (a: A) => Effect.Effect<B, ConfigError>
): Config<B>Transforms the parsed value with a function that may fail.
When to use
Use when you need to transform a parsed config value with a function that can
produce a ConfigError (e.g. parsing a URL, checking a range).
Example (Wrapping a value in an effectful transformation)
import { Config, Effect } from "effect"
const trimmed = Config.string("name").pipe(
Config.mapOrFail((s) => Effect.succeed(s.trim()))
)export const const mapOrFail: {
<A, B>(
f: (a: A) => Effect.Effect<B, ConfigError>
): (self: Config<A>) => Config<B>
<A, B>(
self: Config<A>,
f: (a: A) => Effect.Effect<B, ConfigError>
): Config<B>
}
Transforms the parsed value with a function that may fail.
When to use
Use when you need to transform a parsed config value with a function that can
produce a ConfigError (e.g. parsing a URL, checking a range).
Example (Wrapping a value in an effectful transformation)
import { Config, Effect } from "effect"
const trimmed = Config.string("name").pipe(
Config.mapOrFail((s) => Effect.succeed(s.trim()))
)
mapOrFail: {
<function (type parameter) A in <A, B>(f: (a: A) => Effect.Effect<B, ConfigError>): (self: Config<A>) => Config<B>A, function (type parameter) B in <A, B>(f: (a: A) => Effect.Effect<B, ConfigError>): (self: Config<A>) => Config<B>B>(f: (a: A) => Effect.Effect<B, ConfigError>f: (a: Aa: function (type parameter) A in <A, B>(f: (a: A) => Effect.Effect<B, ConfigError>): (self: Config<A>) => Config<B>A) => import EffectEffect.interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<function (type parameter) B in <A, B>(f: (a: A) => Effect.Effect<B, ConfigError>): (self: Config<A>) => Config<B>B, class ConfigErrorclass ConfigError {
_tag: 'ConfigError';
name: string;
cause: SourceError | Schema.SchemaError;
message: string;
toString: () => string;
}
Represents the error type produced when config loading or validation fails.
When to use
Use when you need to inspect config loading or validation failures.
Details
Wraps either:
- A
SourceError — the provider could not read data (I/O failure).
- A
SchemaError — the data was found but did not match the schema
(wrong type, out of range, missing key, etc.).
ConfigError>): (self: Config<A>(parameter) self: {
parse: (provider: ConfigProvider.ConfigProvider, pathPrefix?: Path) => Effect.Effect<T, ConfigError>;
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;
}
self: interface Config<out T>A recipe for extracting a typed value T from a ConfigProvider.
When to use
Use to describe typed configuration that can be parsed from a provider or
yielded inside Effect.gen.
Details
Key members:
parse(provider, pathPrefix?) – runs the config against a specific provider.
The optional path prefix is the logical scope accumulated from outer
Config.nested calls.
- Yieldable – can be yielded inside
Effect.gen, which automatically
resolves the current ConfigProvider from the context.
- Pipeable – supports
.pipe(Config.map(...)) etc.
Config<function (type parameter) A in <A, B>(f: (a: A) => Effect.Effect<B, ConfigError>): (self: Config<A>) => Config<B>A>) => interface Config<out T>A recipe for extracting a typed value T from a ConfigProvider.
When to use
Use to describe typed configuration that can be parsed from a provider or
yielded inside Effect.gen.
Details
Key members:
parse(provider, pathPrefix?) – runs the config against a specific provider.
The optional path prefix is the logical scope accumulated from outer
Config.nested calls.
- Yieldable – can be yielded inside
Effect.gen, which automatically
resolves the current ConfigProvider from the context.
- Pipeable – supports
.pipe(Config.map(...)) etc.
Config<function (type parameter) B in <A, B>(f: (a: A) => Effect.Effect<B, ConfigError>): (self: Config<A>) => Config<B>B>
<function (type parameter) A in <A, B>(self: Config<A>, f: (a: A) => Effect.Effect<B, ConfigError>): Config<B>A, function (type parameter) B in <A, B>(self: Config<A>, f: (a: A) => Effect.Effect<B, ConfigError>): Config<B>B>(self: Config<A>(parameter) self: {
parse: (provider: ConfigProvider.ConfigProvider, pathPrefix?: Path) => Effect.Effect<T, ConfigError>;
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;
}
self: interface Config<out T>A recipe for extracting a typed value T from a ConfigProvider.
When to use
Use to describe typed configuration that can be parsed from a provider or
yielded inside Effect.gen.
Details
Key members:
parse(provider, pathPrefix?) – runs the config against a specific provider.
The optional path prefix is the logical scope accumulated from outer
Config.nested calls.
- Yieldable – can be yielded inside
Effect.gen, which automatically
resolves the current ConfigProvider from the context.
- Pipeable – supports
.pipe(Config.map(...)) etc.
Config<function (type parameter) A in <A, B>(self: Config<A>, f: (a: A) => Effect.Effect<B, ConfigError>): Config<B>A>, f: (a: A) => Effect.Effect<B, ConfigError>f: (a: Aa: function (type parameter) A in <A, B>(self: Config<A>, f: (a: A) => Effect.Effect<B, ConfigError>): Config<B>A) => import EffectEffect.interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<function (type parameter) B in <A, B>(self: Config<A>, f: (a: A) => Effect.Effect<B, ConfigError>): Config<B>B, class ConfigErrorclass ConfigError {
_tag: 'ConfigError';
name: string;
cause: SourceError | Schema.SchemaError;
message: string;
toString: () => string;
}
Represents the error type produced when config loading or validation fails.
When to use
Use when you need to inspect config loading or validation failures.
Details
Wraps either:
- A
SourceError — the provider could not read data (I/O failure).
- A
SchemaError — the data was found but did not match the schema
(wrong type, out of range, missing key, etc.).
ConfigError>): interface Config<out T>A recipe for extracting a typed value T from a ConfigProvider.
When to use
Use to describe typed configuration that can be parsed from a provider or
yielded inside Effect.gen.
Details
Key members:
parse(provider, pathPrefix?) – runs the config against a specific provider.
The optional path prefix is the logical scope accumulated from outer
Config.nested calls.
- Yieldable – can be yielded inside
Effect.gen, which automatically
resolves the current ConfigProvider from the context.
- Pipeable – supports
.pipe(Config.map(...)) etc.
Config<function (type parameter) B in <A, B>(self: Config<A>, f: (a: A) => Effect.Effect<B, ConfigError>): Config<B>B>
} = dual<(...args: Array<any>) => any, <A, B>(self: Config<A>, f: (a: A) => Effect.Effect<B, ConfigError>) => Config<B>>(arity: 2, body: <A, B>(self: Config<A>, f: (a: A) => Effect.Effect<B, ConfigError>) => Config<B>): ((...args: Array<any>) => any) & (<A, B>(self: Config<A>, f: (a: A) => Effect.Effect<B, ConfigError>) => Config<B>) (+1 overload)Creates a function that can be called in data-first style or data-last
(pipe-friendly) style.
When to use
Use to expose one implementation through both direct and pipe-friendly
call styles.
Details
Pass either the arity of the uncurried function or a predicate that decides
whether the current call is data-first. Arity is the common case. Use a
predicate when optional arguments make arity ambiguous.
Example (Selecting data-first or data-last style by arity)
import { Function, pipe } from "effect"
const sum = Function.dual<
(that: number) => (self: number) => number,
(self: number, that: number) => number
>(2, (self, that) => self + that)
console.log(sum(2, 3)) // 5
console.log(pipe(2, sum(3))) // 5
Example (Defining overloads with call signatures)
import { Function, pipe } from "effect"
const sum: {
(that: number): (self: number) => number
(self: number, that: number): number
} = Function.dual(2, (self: number, that: number): number => self + that)
console.log(sum(2, 3)) // 5
console.log(pipe(2, sum(3))) // 5
Example (Selecting data-first or data-last style with a predicate)
import { Function, pipe } from "effect"
const sum = Function.dual<
(that: number) => (self: number) => number,
(self: number, that: number) => number
>(
(args) => args.length === 2,
(self, that) => self + that
)
console.log(sum(2, 3)) // 5
console.log(pipe(2, sum(3))) // 5
dual(2, <function (type parameter) A in <A, B>(self: Config<A>, f: (a: A) => Effect.Effect<B, ConfigError>): Config<B>A, function (type parameter) B in <A, B>(self: Config<A>, f: (a: A) => Effect.Effect<B, ConfigError>): Config<B>B>(self: Config<A>(parameter) self: {
parse: (provider: ConfigProvider.ConfigProvider, pathPrefix?: Path) => Effect.Effect<T, ConfigError>;
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;
}
self: interface Config<out T>A recipe for extracting a typed value T from a ConfigProvider.
When to use
Use to describe typed configuration that can be parsed from a provider or
yielded inside Effect.gen.
Details
Key members:
parse(provider, pathPrefix?) – runs the config against a specific provider.
The optional path prefix is the logical scope accumulated from outer
Config.nested calls.
- Yieldable – can be yielded inside
Effect.gen, which automatically
resolves the current ConfigProvider from the context.
- Pipeable – supports
.pipe(Config.map(...)) etc.
Config<function (type parameter) A in <A, B>(self: Config<A>, f: (a: A) => Effect.Effect<B, ConfigError>): Config<B>A>, f: (a: A) => Effect.Effect<B, ConfigError>f: (a: Aa: function (type parameter) A in <A, B>(self: Config<A>, f: (a: A) => Effect.Effect<B, ConfigError>): Config<B>A) => import EffectEffect.interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<function (type parameter) B in <A, B>(self: Config<A>, f: (a: A) => Effect.Effect<B, ConfigError>): Config<B>B, class ConfigErrorclass ConfigError {
_tag: 'ConfigError';
name: string;
cause: SourceError | Schema.SchemaError;
message: string;
toString: () => string;
}
Represents the error type produced when config loading or validation fails.
When to use
Use when you need to inspect config loading or validation failures.
Details
Wraps either:
- A
SourceError — the provider could not read data (I/O failure).
- A
SchemaError — the data was found but did not match the schema
(wrong type, out of range, missing key, etc.).
ConfigError>): interface Config<out T>A recipe for extracting a typed value T from a ConfigProvider.
When to use
Use to describe typed configuration that can be parsed from a provider or
yielded inside Effect.gen.
Details
Key members:
parse(provider, pathPrefix?) – runs the config against a specific provider.
The optional path prefix is the logical scope accumulated from outer
Config.nested calls.
- Yieldable – can be yielded inside
Effect.gen, which automatically
resolves the current ConfigProvider from the context.
- Pipeable – supports
.pipe(Config.map(...)) etc.
Config<function (type parameter) B in <A, B>(self: Config<A>, f: (a: A) => Effect.Effect<B, ConfigError>): Config<B>B> => {
return function make<T>(
parse: (
provider: ConfigProvider.ConfigProvider,
pathPrefix: Path
) => Effect.Effect<T, ConfigError>
): Config<T>
make((provider: ConfigProvider.ConfigProvider(parameter) provider: {
load: (path: Path) => Effect.Effect<Node | undefined, SourceError>;
state: ProviderState;
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; <…;
}
provider, pathPrefix: Path(parameter) pathPrefix: {
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
concat: { (...items: Array<ConcatArray<string | number>>): Array<string | number>; (...items: Array<string | number | ConcatArray<string | number>>): Array<string | number> };
join: (separator?: string) => string;
slice: (start?: number, end?: number) => Array<string | number>;
indexOf: (searchElement: string | number, fromIndex?: number) => number;
lastIndexOf: (searchElement: string | number, fromIndex?: number) => number;
every: { (predicate: (value: string | number, index: number, array: ReadonlyArray<string | number>) => value is S, thisArg?: any): this is readonly S[]; (predicate: (value: string | number, index: number, array: ReadonlyArray<string | number>) =>…;
some: (predicate: (value: string | number, index: number, array: ReadonlyArray<string | number>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: string | number, index: number, array: ReadonlyArray<string | number>) => void, thisArg?: any) => void;
map: (callbackfn: (value: string | number, index: number, array: ReadonlyArray<string | number>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: string | number, index: number, array: ReadonlyArray<string | number>) => value is S, thisArg?: any): Array<S>; (predicate: (value: string | number, index: number, array: ReadonlyArray<string | number>) => unknown, th…;
reduce: { (callbackfn: (previousValue: string | number, currentValue: string | number, currentIndex: number, array: ReadonlyArray<string | number>) => string | number): string | number; (callbackfn: (previousValue: string | number, currentValue: s…;
reduceRight: { (callbackfn: (previousValue: string | number, currentValue: string | number, currentIndex: number, array: ReadonlyArray<string | number>) => string | number): string | number; (callbackfn: (previousValue: string | number, currentValue: s…;
find: { (predicate: (value: string | number, index: number, obj: ReadonlyArray<string | number>) => value is S, thisArg?: any): S | undefined; (predicate: (value: string | number, index: number, obj: ReadonlyArray<string | number>) => unknown, t…;
findIndex: (predicate: (value: string | number, index: number, obj: ReadonlyArray<string | number>) => unknown, thisArg?: any) => number;
entries: () => ArrayIterator<[number, string | number]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<string | number>;
includes: (searchElement: string | number, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: string | number, index: number, array: Array<string | number>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => string | number | undefined;
findLast: { (predicate: (value: string | number, index: number, array: ReadonlyArray<string | number>) => value is S, thisArg?: any): S | undefined; (predicate: (value: string | number, index: number, array: ReadonlyArray<string | number>) => unknow…;
findLastIndex: (predicate: (value: string | number, index: number, array: ReadonlyArray<string | number>) => unknown, thisArg?: any) => number;
toReversed: () => Array<string | number>;
toSorted: (compareFn?: ((a: string | number, b: string | number) => number) | undefined) => Array<string | number>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<string | number>): Array<string | number>; (start: number, deleteCount?: number): Array<string | number> };
with: (index: number, value: string | number) => Array<string | number>;
}
pathPrefix) => import EffectEffect.const flatMap: {
<A, B, E1, R1>(
f: (a: A) => Effect<B, E1, R1>
): <E, R>(
self: Effect<A, E, R>
) => Effect<B, E1 | E, R1 | R>
<A, E, R, B, E1, R1>(
self: Effect<A, E, R>,
f: (a: A) => Effect<B, E1, R1>
): Effect<B, E | E1, R | R1>
}
flatMap(self: Config<A>(parameter) self: {
parse: (provider: ConfigProvider.ConfigProvider, pathPrefix?: Path) => Effect.Effect<T, ConfigError>;
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;
}
self.Config<A>.parse: (provider: ConfigProvider.ConfigProvider, pathPrefix?: Path) => Effect.Effect<T, ConfigError>parse(provider: ConfigProvider.ConfigProvider(parameter) provider: {
load: (path: Path) => Effect.Effect<Node | undefined, SourceError>;
state: ProviderState;
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; <…;
}
provider, pathPrefix: Path(parameter) pathPrefix: {
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
concat: { (...items: Array<ConcatArray<string | number>>): Array<string | number>; (...items: Array<string | number | ConcatArray<string | number>>): Array<string | number> };
join: (separator?: string) => string;
slice: (start?: number, end?: number) => Array<string | number>;
indexOf: (searchElement: string | number, fromIndex?: number) => number;
lastIndexOf: (searchElement: string | number, fromIndex?: number) => number;
every: { (predicate: (value: string | number, index: number, array: ReadonlyArray<string | number>) => value is S, thisArg?: any): this is readonly S[]; (predicate: (value: string | number, index: number, array: ReadonlyArray<string | number>) =>…;
some: (predicate: (value: string | number, index: number, array: ReadonlyArray<string | number>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: string | number, index: number, array: ReadonlyArray<string | number>) => void, thisArg?: any) => void;
map: (callbackfn: (value: string | number, index: number, array: ReadonlyArray<string | number>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: string | number, index: number, array: ReadonlyArray<string | number>) => value is S, thisArg?: any): Array<S>; (predicate: (value: string | number, index: number, array: ReadonlyArray<string | number>) => unknown, th…;
reduce: { (callbackfn: (previousValue: string | number, currentValue: string | number, currentIndex: number, array: ReadonlyArray<string | number>) => string | number): string | number; (callbackfn: (previousValue: string | number, currentValue: s…;
reduceRight: { (callbackfn: (previousValue: string | number, currentValue: string | number, currentIndex: number, array: ReadonlyArray<string | number>) => string | number): string | number; (callbackfn: (previousValue: string | number, currentValue: s…;
find: { (predicate: (value: string | number, index: number, obj: ReadonlyArray<string | number>) => value is S, thisArg?: any): S | undefined; (predicate: (value: string | number, index: number, obj: ReadonlyArray<string | number>) => unknown, t…;
findIndex: (predicate: (value: string | number, index: number, obj: ReadonlyArray<string | number>) => unknown, thisArg?: any) => number;
entries: () => ArrayIterator<[number, string | number]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<string | number>;
includes: (searchElement: string | number, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: string | number, index: number, array: Array<string | number>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => string | number | undefined;
findLast: { (predicate: (value: string | number, index: number, array: ReadonlyArray<string | number>) => value is S, thisArg?: any): S | undefined; (predicate: (value: string | number, index: number, array: ReadonlyArray<string | number>) => unknow…;
findLastIndex: (predicate: (value: string | number, index: number, array: ReadonlyArray<string | number>) => unknown, thisArg?: any) => number;
toReversed: () => Array<string | number>;
toSorted: (compareFn?: ((a: string | number, b: string | number) => number) | undefined) => Array<string | number>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<string | number>): Array<string | number>; (start: number, deleteCount?: number): Array<string | number> };
with: (index: number, value: string | number) => Array<string | number>;
}
pathPrefix), f: (a: A) => Effect.Effect<B, ConfigError>f))
})