(options?: {
readonly label?: string | undefined
readonly collapsed?: boolean | undefined
}): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
<A, E, R>(
self: Effect.Effect<A, E, R>,
options?: {
readonly label?: string | undefined
readonly collapsed?: boolean | undefined
}
): Effect.Effect<A, E, R>Runs an Effect inside an optionally labeled or collapsed console group, starting the group before execution and ending it after the Effect completes.
Example (Wrapping an effect in a group)
import { Console, Effect } from "effect"
const program = Effect.gen(function*() {
yield* Console.withGroup(
Effect.gen(function*() {
yield* Console.log("Step 1: Initialize")
yield* Console.log("Step 2: Process")
yield* Console.log("Step 3: Complete")
}),
{ label: "Processing Steps", collapsed: false }
)
})export const const withGroup: ((options?: {
readonly label?: string | undefined
readonly collapsed?: boolean | undefined
}) => <A, E, R>(
self: Effect.Effect<A, E, R>
) => Effect.Effect<A, E, R>) &
(<A, E, R>(
self: Effect.Effect<A, E, R>,
options?: {
readonly label?: string | undefined
readonly collapsed?: boolean | undefined
}
) => Effect.Effect<A, E, R>)
Runs an Effect inside an optionally labeled or collapsed console group, starting the group before execution and ending it after the Effect completes.
Example (Wrapping an effect in a group)
import { Console, Effect } from "effect"
const program = Effect.gen(function*() {
yield* Console.withGroup(
Effect.gen(function*() {
yield* Console.log("Step 1: Initialize")
yield* Console.log("Step 2: Process")
yield* Console.log("Step 3: Complete")
}),
{ label: "Processing Steps", collapsed: false }
)
})
withGroup = dual<(options?: {
readonly label?: string | undefined;
readonly collapsed?: boolean | undefined;
}) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>, <A, E, R>(self: Effect.Effect<A, E, R>, options?: {
readonly label?: string | undefined;
readonly collapsed?: boolean | undefined;
}) => Effect.Effect<A, E, R>>(isDataFirst: (args: IArguments) => boolean, body: <A, E, R>(self: Effect.Effect<A, E, R>, options?: {
readonly label?: string | undefined;
readonly collapsed?: boolean | undefined;
}) => Effect.Effect<A, E, R>): ((options?: {
readonly label?: string | undefined;
readonly collapsed?: boolean | undefined;
}) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>) & (<A, E, R>(self: Effect.Effect<A, E, R>, options?: {
readonly label?: string | undefined;
readonly collapsed?: boolean | undefined;
}) => Effect.Effect<A, E, R>) (+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<
(
options: | {
readonly label?: string | undefined
readonly collapsed?: boolean | undefined
}
| undefined
options?: {
readonly label?: string | undefinedlabel?: string | undefined
readonly collapsed?: boolean | undefinedcollapsed?: boolean | undefined
}
) => <function (type parameter) A in <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>A, function (type parameter) E in <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>E, function (type parameter) R in <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>R>(self: Effect.Effect<A, E, R>(parameter) self: {
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: 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) A in <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>A, function (type parameter) E in <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>E, function (type parameter) R in <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>R>) => 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) A in <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>A, function (type parameter) E in <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>E, function (type parameter) R in <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>R>,
<function (type parameter) A in <A, E, R>(self: Effect.Effect<A, E, R>, options?: {
readonly label?: string | undefined;
readonly collapsed?: boolean | undefined;
}): Effect.Effect<A, E, R>
A, function (type parameter) E in <A, E, R>(self: Effect.Effect<A, E, R>, options?: {
readonly label?: string | undefined;
readonly collapsed?: boolean | undefined;
}): Effect.Effect<A, E, R>
E, function (type parameter) R in <A, E, R>(self: Effect.Effect<A, E, R>, options?: {
readonly label?: string | undefined;
readonly collapsed?: boolean | undefined;
}): Effect.Effect<A, E, R>
R>(
self: Effect.Effect<A, E, R>(parameter) self: {
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: 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) A in <A, E, R>(self: Effect.Effect<A, E, R>, options?: {
readonly label?: string | undefined;
readonly collapsed?: boolean | undefined;
}): Effect.Effect<A, E, R>
A, function (type parameter) E in <A, E, R>(self: Effect.Effect<A, E, R>, options?: {
readonly label?: string | undefined;
readonly collapsed?: boolean | undefined;
}): Effect.Effect<A, E, R>
E, function (type parameter) R in <A, E, R>(self: Effect.Effect<A, E, R>, options?: {
readonly label?: string | undefined;
readonly collapsed?: boolean | undefined;
}): Effect.Effect<A, E, R>
R>,
options: | {
readonly label?: string | undefined
readonly collapsed?: boolean | undefined
}
| undefined
options?: {
readonly label?: string | undefinedlabel?: string | undefined
readonly collapsed?: boolean | undefinedcollapsed?: boolean | undefined
}
) => 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) A in <A, E, R>(self: Effect.Effect<A, E, R>, options?: {
readonly label?: string | undefined;
readonly collapsed?: boolean | undefined;
}): Effect.Effect<A, E, R>
A, function (type parameter) E in <A, E, R>(self: Effect.Effect<A, E, R>, options?: {
readonly label?: string | undefined;
readonly collapsed?: boolean | undefined;
}): Effect.Effect<A, E, R>
E, function (type parameter) R in <A, E, R>(self: Effect.Effect<A, E, R>, options?: {
readonly label?: string | undefined;
readonly collapsed?: boolean | undefined;
}): Effect.Effect<A, E, R>
R>
>((args: IArgumentsargs) => import corecore.const isEffect: (
u: unknown
) => u is Effect.Effect<any, any, any>
isEffect(args: IArgumentsargs[0]), (self: Effect.Effect<A, E, R>(parameter) self: {
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, options: | {
readonly label?: string | undefined
readonly collapsed?: boolean | undefined
}
| undefined
options) =>
const consoleWith: <A, E, R>(
f: (console: Console) => Effect.Effect<A, E, R>
) => Effect.Effect<A, E, R>
Creates an Effect that provides access to the current console service and lets you perform operations with it within an Effect context.
Example (Accessing the current console service)
import { Console, Effect } from "effect"
const program = Console.consoleWith((console) =>
Effect.sync(() => {
console.log("Hello, world!")
console.error("This is an error message")
})
)
consoleWith((console: Console(parameter) console: {
assert: (condition: boolean, ...args: ReadonlyArray<any>) => void;
clear: () => void;
count: (label?: string) => void;
countReset: (label?: string) => void;
debug: (...args: ReadonlyArray<any>) => void;
dir: (item: any, options?: any) => void;
dirxml: (...args: ReadonlyArray<any>) => void;
error: (...args: ReadonlyArray<any>) => void;
group: (...args: ReadonlyArray<any>) => void;
groupCollapsed: (...args: ReadonlyArray<any>) => void;
groupEnd: () => void;
info: (...args: ReadonlyArray<any>) => void;
log: (...args: ReadonlyArray<any>) => void;
table: (tabularData: any, properties?: ReadonlyArray<string>) => void;
time: (label?: string) => void;
timeEnd: (label?: string) => void;
timeLog: (label?: string, ...args: ReadonlyArray<any>) => void;
trace: (...args: ReadonlyArray<any>) => void;
warn: (...args: ReadonlyArray<any>) => void;
}
console) =>
import effecteffect.const acquireUseRelease: <
Resource,
E,
R,
A,
E2,
R2,
E3,
R3
>(
acquire: Effect.Effect<Resource, E, R>,
use: (a: Resource) => Effect.Effect<A, E2, R2>,
release: (
a: Resource,
exit: Exit.Exit<A, E2>
) => Effect.Effect<void, E3, R3>
) => Effect.Effect<A, E | E2 | E3, R | R2 | R3>
acquireUseRelease(
import effecteffect.const sync: <A>(
thunk: LazyArg<A>
) => Effect.Effect<A>
sync(() => {
if (options: | {
readonly label?: string | undefined
readonly collapsed?: boolean | undefined
}
| undefined
options?.collapsed?: boolean | undefinedcollapsed) {
console: Console(parameter) console: {
assert: (condition: boolean, ...args: ReadonlyArray<any>) => void;
clear: () => void;
count: (label?: string) => void;
countReset: (label?: string) => void;
debug: (...args: ReadonlyArray<any>) => void;
dir: (item: any, options?: any) => void;
dirxml: (...args: ReadonlyArray<any>) => void;
error: (...args: ReadonlyArray<any>) => void;
group: (...args: ReadonlyArray<any>) => void;
groupCollapsed: (...args: ReadonlyArray<any>) => void;
groupEnd: () => void;
info: (...args: ReadonlyArray<any>) => void;
log: (...args: ReadonlyArray<any>) => void;
table: (tabularData: any, properties?: ReadonlyArray<string>) => void;
time: (label?: string) => void;
timeEnd: (label?: string) => void;
timeLog: (label?: string, ...args: ReadonlyArray<any>) => void;
trace: (...args: ReadonlyArray<any>) => void;
warn: (...args: ReadonlyArray<any>) => void;
}
console.Console.groupCollapsed(...args: ReadonlyArray<any>): voidgroupCollapsed(options: {
readonly label?: string | undefined
readonly collapsed?: boolean | undefined
}
options.label?: string | undefinedlabel)
} else {
console: Console(parameter) console: {
assert: (condition: boolean, ...args: ReadonlyArray<any>) => void;
clear: () => void;
count: (label?: string) => void;
countReset: (label?: string) => void;
debug: (...args: ReadonlyArray<any>) => void;
dir: (item: any, options?: any) => void;
dirxml: (...args: ReadonlyArray<any>) => void;
error: (...args: ReadonlyArray<any>) => void;
group: (...args: ReadonlyArray<any>) => void;
groupCollapsed: (...args: ReadonlyArray<any>) => void;
groupEnd: () => void;
info: (...args: ReadonlyArray<any>) => void;
log: (...args: ReadonlyArray<any>) => void;
table: (tabularData: any, properties?: ReadonlyArray<string>) => void;
time: (label?: string) => void;
timeEnd: (label?: string) => void;
timeLog: (label?: string, ...args: ReadonlyArray<any>) => void;
trace: (...args: ReadonlyArray<any>) => void;
warn: (...args: ReadonlyArray<any>) => void;
}
console.Console.group(...args: ReadonlyArray<any>): voidgroup(options: | {
readonly label?: string | undefined
readonly collapsed?: boolean | undefined
}
| undefined
options?.label?: string | undefinedlabel)
}
}),
() => self: Effect.Effect<A, E, R>(parameter) self: {
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,
() =>
import effecteffect.const sync: <A>(
thunk: LazyArg<A>
) => Effect.Effect<A>
sync(() => {
console: Console(parameter) console: {
assert: (condition: boolean, ...args: ReadonlyArray<any>) => void;
clear: () => void;
count: (label?: string) => void;
countReset: (label?: string) => void;
debug: (...args: ReadonlyArray<any>) => void;
dir: (item: any, options?: any) => void;
dirxml: (...args: ReadonlyArray<any>) => void;
error: (...args: ReadonlyArray<any>) => void;
group: (...args: ReadonlyArray<any>) => void;
groupCollapsed: (...args: ReadonlyArray<any>) => void;
groupEnd: () => void;
info: (...args: ReadonlyArray<any>) => void;
log: (...args: ReadonlyArray<any>) => void;
table: (tabularData: any, properties?: ReadonlyArray<string>) => void;
time: (label?: string) => void;
timeEnd: (label?: string) => void;
timeLog: (label?: string, ...args: ReadonlyArray<any>) => void;
trace: (...args: ReadonlyArray<any>) => void;
warn: (...args: ReadonlyArray<any>) => void;
}
console.Console.groupEnd(): voidgroupEnd()
})
)
))