import * as Effect from "effect/Effect"; export type IsAny = 0 extends 1 & T ? true : false; export type ExcludeAny = IsAny extends true ? never : T; export type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ( k: infer I, ) => void ? I : never; export const assertDefined = (value: T | undefined, message: string): T => { if (!value) { throw new Error(message); } return value; }; export const asEffect = ( effect: T | Effect.Effect | { asEffect: () => Effect.Effect }, ): Effect.Effect => typeof (effect as any)?.asEffect === "function" ? (effect as any).asEffect() : Effect.isEffect(effect) ? effect : Effect.succeed(effect as T); export type IsNever = [T] extends [never] ? true : false; /** * `Omit` that distributes over a union instead of collapsing it. * * Bare `Omit` computes `keyof (A | B)` — the COMMON keys — and * merges the members into one object type. For discriminated prop unions * (e.g. a Function's zip-XOR-image props) that silently erases the * discrimination: required members become optional and mutually exclusive * fields become simultaneously allowed. Distributing preserves each member. */ export type DistributiveOmit = T extends any ? Omit : never;