(
options?:
| { label?: string | undefined; collapsed?: boolean | undefined }
| undefined
): Effect.Effect<void, never, Scope>Creates a scoped console group, optionally collapsed and labeled, and closes it automatically when the Effect scope is finalized.
Example (Grouping scoped output)
import { Console, Effect } from "effect"
const program = Effect.gen(function*() {
yield* Effect.scoped(
Effect.gen(function*() {
yield* Console.group({ label: "User Processing" })
yield* Console.log("Loading user data...")
yield* Console.log("Validating user...")
yield* Console.log("User processed successfully")
})
)
})export const const group: (
options?:
| {
label?: string | undefined
collapsed?: boolean | undefined
}
| undefined
) => Effect.Effect<void, never, Scope>
Creates a scoped console group, optionally collapsed and labeled, and closes it automatically when the Effect scope is finalized.
Example (Grouping scoped output)
import { Console, Effect } from "effect"
const program = Effect.gen(function*() {
yield* Effect.scoped(
Effect.gen(function*() {
yield* Console.group({ label: "User Processing" })
yield* Console.log("Loading user data...")
yield* Console.log("Validating user...")
yield* Console.log("User processed successfully")
})
)
})
group = (
options: | {
label?: string | undefined
collapsed?: boolean | undefined
}
| undefined
options?: { label?: string | undefinedlabel?: string | undefined; collapsed?: boolean | undefinedcollapsed?: boolean | undefined } | 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<void, never, Scope> =>
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 acquireRelease: <A, E, R, R2>(
acquire: Effect.Effect<A, E, R>,
release: (
a: A,
exit: Exit.Exit<unknown, unknown>
) => Effect.Effect<unknown, never, R2>,
options?: { readonly interruptible?: boolean }
) => Effect.Effect<A, E, R | R2 | Scope.Scope>
acquireRelease(
import effecteffect.const sync: <A>(
thunk: LazyArg<A>
) => Effect.Effect<A>
sync(() => {
if (options: | {
label?: string | undefined
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: {
label?: string | undefined
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: | {
label?: string | undefined
collapsed?: boolean | undefined
}
| undefined
options?.label?: string | undefinedlabel)
}
}),
() =>
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()
})
)
)