(zone: string): <A, E, R>(
effect: Effect.Effect<A, E, R>
) => Effect.Effect<
A,
E | IllegalArgumentError,
Exclude<R, CurrentTimeZone>
>
<A, E, R>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<
A,
E | IllegalArgumentError,
Exclude<R, CurrentTimeZone>
>Provides the CurrentTimeZone to an effect using an IANA time zone
identifier.
Details
If the time zone is invalid, it will fail with an IllegalArgumentError.
Example (Providing a named time zone)
import { DateTime, Effect } from "effect"
Effect.gen(function*() {
// will use the "Europe/London" time zone
const now = yield* DateTime.nowInCurrentZone
}).pipe(DateTime.withCurrentZoneNamed("Europe/London"))export const const withCurrentZoneNamed: {
(zone: string): <A, E, R>(
effect: Effect.Effect<A, E, R>
) => Effect.Effect<
A,
E | IllegalArgumentError,
Exclude<R, CurrentTimeZone>
>
<A, E, R>(
effect: Effect.Effect<A, E, R>,
zone: string
): Effect.Effect<
A,
E | IllegalArgumentError,
Exclude<R, CurrentTimeZone>
>
}
Provides the CurrentTimeZone to an effect using an IANA time zone
identifier.
Details
If the time zone is invalid, it will fail with an IllegalArgumentError.
Example (Providing a named time zone)
import { DateTime, Effect } from "effect"
Effect.gen(function*() {
// will use the "Europe/London" time zone
const now = yield* DateTime.nowInCurrentZone
}).pipe(DateTime.withCurrentZoneNamed("Europe/London"))
withCurrentZoneNamed: {
(zone: stringzone: string): <function (type parameter) A in <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>A, function (type parameter) E in <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>E, function (type parameter) R in <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>R>(
effect: Effect.Effect<A, E, R>(parameter) effect: {
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;
}
effect: 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>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>A, function (type parameter) E in <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>E, function (type parameter) R in <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>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>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>A, function (type parameter) E in <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>E | import IllegalArgumentErrorIllegalArgumentError, type Exclude<T, U> = T extends U
? never
: T
Exclude from T those types that are assignable to U
Exclude<function (type parameter) R in <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>R, class CurrentTimeZoneclass CurrentTimeZone {
Service: Service;
key: Identifier;
}
Context service that supplies the ambient TimeZone for APIs that work in
the current zone, such as DateTime.setZoneCurrent and
DateTime.nowInCurrentZone.
Details
Provide it with DateTime.withCurrentZone, one of the withCurrentZone*
helpers, or one of the layerCurrentZone* layers.
Example (Accessing the current time zone service)
import { DateTime, Effect } from "effect"
const program = Effect.gen(function*() {
// Access the current time zone service
const zone = yield* DateTime.CurrentTimeZone
console.log(DateTime.zoneToString(zone))
})
// Provide a time zone
const layer = DateTime.layerCurrentZoneNamed("Europe/London")
Effect.provide(program, layer)
CurrentTimeZone>>
<function (type parameter) A in <A, E, R>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>A, function (type parameter) E in <A, E, R>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>E, function (type parameter) R in <A, E, R>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>R>(
effect: Effect.Effect<A, E, R>(parameter) effect: {
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;
}
effect: 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>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>A, function (type parameter) E in <A, E, R>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>E, function (type parameter) R in <A, E, R>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>R>,
zone: stringzone: string
): 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>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>A, function (type parameter) E in <A, E, R>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>E | import IllegalArgumentErrorIllegalArgumentError, type Exclude<T, U> = T extends U
? never
: T
Exclude from T those types that are assignable to U
Exclude<function (type parameter) R in <A, E, R>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>R, class CurrentTimeZoneclass CurrentTimeZone {
Service: Service;
key: Identifier;
}
Context service that supplies the ambient TimeZone for APIs that work in
the current zone, such as DateTime.setZoneCurrent and
DateTime.nowInCurrentZone.
Details
Provide it with DateTime.withCurrentZone, one of the withCurrentZone*
helpers, or one of the layerCurrentZone* layers.
Example (Accessing the current time zone service)
import { DateTime, Effect } from "effect"
const program = Effect.gen(function*() {
// Access the current time zone service
const zone = yield* DateTime.CurrentTimeZone
console.log(DateTime.zoneToString(zone))
})
// Provide a time zone
const layer = DateTime.layerCurrentZoneNamed("Europe/London")
Effect.provide(program, layer)
CurrentTimeZone>>
} = dual<(...args: Array<any>) => any, <A, E, R>(effect: Effect.Effect<A, E, R>, zone: string) => Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>>(arity: 2, body: <A, E, R>(effect: Effect.Effect<A, E, R>, zone: string) => Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>): ((...args: Array<any>) => any) & (<A, E, R>(effect: Effect.Effect<A, E, R>, zone: string) => Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>) (+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, E, R>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>A, function (type parameter) E in <A, E, R>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>E, function (type parameter) R in <A, E, R>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>R>(
effect: Effect.Effect<A, E, R>(parameter) effect: {
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;
}
effect: 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>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>A, function (type parameter) E in <A, E, R>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>E, function (type parameter) R in <A, E, R>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>R>,
zone: stringzone: string
): 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>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>A, function (type parameter) E in <A, E, R>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>E | import IllegalArgumentErrorIllegalArgumentError, type Exclude<T, U> = T extends U
? never
: T
Exclude from T those types that are assignable to U
Exclude<function (type parameter) R in <A, E, R>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<A, E | IllegalArgumentError, Exclude<R, CurrentTimeZone>>R, class CurrentTimeZoneclass CurrentTimeZone {
Service: Service;
key: Identifier;
}
Context service that supplies the ambient TimeZone for APIs that work in
the current zone, such as DateTime.setZoneCurrent and
DateTime.nowInCurrentZone.
Details
Provide it with DateTime.withCurrentZone, one of the withCurrentZone*
helpers, or one of the layerCurrentZone* layers.
Example (Accessing the current time zone service)
import { DateTime, Effect } from "effect"
const program = Effect.gen(function*() {
// Access the current time zone service
const zone = yield* DateTime.CurrentTimeZone
console.log(DateTime.zoneToString(zone))
})
// Provide a time zone
const layer = DateTime.layerCurrentZoneNamed("Europe/London")
Effect.provide(program, layer)
CurrentTimeZone>> =>
import EffectEffect.const provideServiceEffect: {
<I, S, E2, R2>(
service: Context.Key<I, S>,
acquire: Effect<S, E2, R2>
): <A, E, R>(
self: Effect<A, E, R>
) => Effect<A, E | E2, Exclude<R, I> | R2>
<A, E, R, I, S, E2, R2>(
self: Effect<A, E, R>,
service: Context.Key<I, S>,
acquire: Effect<S, E2, R2>
): Effect<A, E | E2, Exclude<R, I> | R2>
}
provideServiceEffect(effect: Effect.Effect<A, E, R>(parameter) effect: {
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;
}
effect, class CurrentTimeZoneclass CurrentTimeZone {
key: Identifier;
of: (this: void, self: TimeZone) => TimeZone;
context: (self: TimeZone) => Context.Context<CurrentTimeZone>;
use: (f: (service: TimeZone) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, CurrentTimeZone | R>;
useSync: (f: (service: TimeZone) => A) => Effect.Effect<A, never, CurrentTimeZone>;
Identifier: Identifier;
Service: Shape;
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;
}
Context service that supplies the ambient TimeZone for APIs that work in
the current zone, such as DateTime.setZoneCurrent and
DateTime.nowInCurrentZone.
Details
Provide it with DateTime.withCurrentZone, one of the withCurrentZone*
helpers, or one of the layerCurrentZone* layers.
Example (Accessing the current time zone service)
import { DateTime, Effect } from "effect"
const program = Effect.gen(function*() {
// Access the current time zone service
const zone = yield* DateTime.CurrentTimeZone
console.log(DateTime.zoneToString(zone))
})
// Provide a time zone
const layer = DateTime.layerCurrentZoneNamed("Europe/London")
Effect.provide(program, layer)
CurrentTimeZone, const zoneMakeNamedEffect: (
zoneId: string
) => Effect.Effect<
TimeZone.Named,
IllegalArgumentError
>
Creates a named time zone effectfully from an IANA time zone identifier.
When to use
Use when invalid IANA zone ids should fail in the Effect error channel
instead of returning Option.none or throwing.
Example (Creating named time zones effectfully)
import { DateTime, Effect } from "effect"
const program = Effect.gen(function*() {
const zone = yield* DateTime.zoneMakeNamedEffect("Europe/London")
const now = yield* DateTime.now
return DateTime.setZone(now, zone)
})
zoneMakeNamedEffect(zone: stringzone))
)