<ROut>(): <ROut2 extends ROut, E, RIn>(
layer: Layer<ROut2, E, RIn>
) => Layer<ROut2, E, RIn>Ensures that a layer's success type extends a given type ROut.
Details
This function provides compile-time type checking to ensure that the success value of a layer conforms to a specific type constraint.
Example (Constraining layer success types)
import { Layer } from "effect"
declare const FortyTwoLayer: Layer.Layer<42, never, never>
declare const StringLayer: Layer.Layer<string, never, never>
// Define a constraint that the success type must be a number
const satisfiesNumber = Layer.satisfiesSuccessType<number>()
// This works - Layer<42, never, never> extends Layer<number, never, never>
const validLayer = satisfiesNumber(FortyTwoLayer)
// This would cause a TypeScript compilation error:
// const invalidLayer = satisfiesNumber(StringLayer)
// ^^^^^^^^^^^
// Type 'string' is not assignable to type 'number'export const const satisfiesSuccessType: <ROut>() => <
ROut2 extends ROut,
E,
RIn
>(
layer: Layer<ROut2, E, RIn>
) => Layer<ROut2, E, RIn>
Ensures that a layer's success type extends a given type ROut.
Details
This function provides compile-time type checking to ensure that the success
value of a layer conforms to a specific type constraint.
Example (Constraining layer success types)
import { Layer } from "effect"
declare const FortyTwoLayer: Layer.Layer<42, never, never>
declare const StringLayer: Layer.Layer<string, never, never>
// Define a constraint that the success type must be a number
const satisfiesNumber = Layer.satisfiesSuccessType<number>()
// This works - Layer<42, never, never> extends Layer<number, never, never>
const validLayer = satisfiesNumber(FortyTwoLayer)
// This would cause a TypeScript compilation error:
// const invalidLayer = satisfiesNumber(StringLayer)
// ^^^^^^^^^^^
// Type 'string' is not assignable to type 'number'
satisfiesSuccessType =
<function (type parameter) ROut in <ROut>(): <ROut2 extends ROut, E, RIn>(layer: Layer<ROut2, E, RIn>) => Layer<ROut2, E, RIn>ROut>() => <function (type parameter) ROut2 in <ROut2 extends ROut, E, RIn>(layer: Layer<ROut2, E, RIn>): Layer<ROut2, E, RIn>ROut2 extends function (type parameter) ROut in <ROut>(): <ROut2 extends ROut, E, RIn>(layer: Layer<ROut2, E, RIn>) => Layer<ROut2, E, RIn>ROut, function (type parameter) E in <ROut2 extends ROut, E, RIn>(layer: Layer<ROut2, E, RIn>): Layer<ROut2, E, RIn>E, function (type parameter) RIn in <ROut2 extends ROut, E, RIn>(layer: Layer<ROut2, E, RIn>): Layer<ROut2, E, RIn>RIn>(layer: Layer<ROut2, E, RIn>(parameter) layer: {
build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<ROut2>, E, RIn>;
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; <…;
}
layer: interface Layer<in ROut, out E = never, out RIn = never>A Layer describes how to build one or more services for dependency injection.
When to use
Use to model construction of application services for dependency injection,
especially when services have dependencies, can fail during construction, or
need scoped setup and release.
Details
A Layer<ROut, E, RIn> represents ROut as the services this layer
provides, E as the possible errors during layer construction, and RIn as
the services this layer requires as dependencies.
Layer<function (type parameter) ROut2 in <ROut2 extends ROut, E, RIn>(layer: Layer<ROut2, E, RIn>): Layer<ROut2, E, RIn>ROut2, function (type parameter) E in <ROut2 extends ROut, E, RIn>(layer: Layer<ROut2, E, RIn>): Layer<ROut2, E, RIn>E, function (type parameter) RIn in <ROut2 extends ROut, E, RIn>(layer: Layer<ROut2, E, RIn>): Layer<ROut2, E, RIn>RIn>): interface Layer<in ROut, out E = never, out RIn = never>A Layer describes how to build one or more services for dependency injection.
When to use
Use to model construction of application services for dependency injection,
especially when services have dependencies, can fail during construction, or
need scoped setup and release.
Details
A Layer<ROut, E, RIn> represents ROut as the services this layer
provides, E as the possible errors during layer construction, and RIn as
the services this layer requires as dependencies.
Layer<function (type parameter) ROut2 in <ROut2 extends ROut, E, RIn>(layer: Layer<ROut2, E, RIn>): Layer<ROut2, E, RIn>ROut2, function (type parameter) E in <ROut2 extends ROut, E, RIn>(layer: Layer<ROut2, E, RIn>): Layer<ROut2, E, RIn>E, function (type parameter) RIn in <ROut2 extends ROut, E, RIn>(layer: Layer<ROut2, E, RIn>): Layer<ROut2, E, RIn>RIn> => layer: Layer<ROut2, E, RIn>(parameter) layer: {
build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<ROut2>, E, RIn>;
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; <…;
}
layer