// ets_tracing: off import type * as Cause from "../Cause/core.js" import type { Tuple } from "../Collections/Immutable/Tuple/index.js" import type * as Exit from "../Exit/exit.js" import type { FiberContext } from "../Fiber/context.js" import type * as Fiber from "../Fiber/core.js" import type { FiberID } from "../Fiber/id.js" import type { Platform } from "../Fiber/index.js" import type { Trace } from "../Fiber/tracing.js" import type { Runtime } from "../FiberRef/fiberRef.js" import type * as O from "../Option/index.js" import type { Scope } from "../Scope/index.js" import type { Supervisor } from "../Supervisor/index.js" import type { XPureBase } from "../XPure/core.js" import type { Effect } from "./effect.js" import { Base } from "./effect.js" // // @category Primitives // export type Instruction = | IFlatMap | ISucceed | IEffectPartial | IEffectTotal | IEffectAsync | IFold | IFork | IInterruptStatus | ICheckInterrupt | ICheckTracingStatus | IFail | IDescriptor | IYield | ITrace | IRead | IProvide | ISuspend | ISuspendPartial | IFiberRefNew | IFiberRefModify | IRaceWith | ISupervise | IGetForkScope | IOverrideForkScope | ITracingStatus | IPlatform | ITracer | XPureBase export class IFail extends Base { readonly _tag = "Fail" constructor( readonly fill: (_: () => Trace) => Cause.Cause, readonly trace?: string ) { super() } } export class IFlatMap extends Base { readonly _tag = "FlatMap" constructor( readonly val: Effect, readonly f: (a: A) => Effect, readonly trace?: string ) { super() } } export class ISucceed extends Base { readonly _tag = "Succeed" constructor(readonly val: A, readonly trace?: string) { super() } } export class ITrace extends Base { readonly _tag = "Trace" constructor() { super() } } export class ITracingStatus extends Base { readonly _tag = "TracingStatus" constructor(readonly effect: Effect, readonly flag: boolean) { super() } } export class ICheckTracingStatus extends Base { readonly _tag = "CheckTracingStatus" constructor(readonly f: (tracingStatus: boolean) => Effect) { super() } } export class IEffectPartial extends Base { readonly _tag = "EffectPartial" constructor( readonly effect: () => A, readonly onThrow: (u: unknown) => E, readonly trace?: string ) { super() } } export class IEffectTotal extends Base { readonly _tag = "EffectTotal" constructor(readonly effect: () => A, readonly trace?: string) { super() } } export class IEffectAsync extends Base { readonly _tag = "EffectAsync" constructor( readonly register: (cb: (_: Effect) => void) => O.Option>, readonly blockingOn: readonly FiberID[], readonly trace?: string ) { super() } } export class IFold extends Base< R & R2 & R3, E2 | E3, A2 | A3 > { readonly _tag = "Fold" constructor( readonly value: Effect, readonly failure: (cause: Cause.Cause) => Effect, readonly apply: (a: A) => Effect, readonly trace?: string ) { super() } } export type FailureReporter = (e: Cause.Cause) => void export class IFork extends Base> { readonly _tag = "Fork" constructor( readonly value: Effect, readonly scope: O.Option>>, readonly reportFailure: O.Option, readonly trace?: string ) { super() } } export class IInterruptStatus extends Base { readonly _tag = "InterruptStatus" constructor( readonly effect: Effect, readonly flag: Fiber.InterruptStatus, readonly trace?: string ) { super() } } export class ICheckInterrupt extends Base { readonly _tag = "CheckInterrupt" constructor( readonly f: (_: Fiber.InterruptStatus) => Effect, readonly trace?: string ) { super() } } export class IDescriptor extends Base { readonly _tag = "Descriptor" constructor( readonly f: (_: Fiber.Descriptor) => Effect, readonly trace?: string ) { super() } } export class IYield extends Base { readonly _tag = "Yield" constructor() { super() } } export class IRead extends Base { readonly _tag = "Read" constructor(readonly f: (_: R0) => Effect, readonly trace?: string) { super() } } export class IPlatform extends Base { readonly _tag = "Platform" constructor( readonly f: (_: Platform) => Effect, readonly trace?: string ) { super() } } export class ITracer extends Base { readonly _tag = "Tracer" constructor( readonly f: (tracer: (trace?: string) => void) => Effect, readonly trace?: string ) { super() } } export class IProvide extends Base { readonly _tag = "Provide" constructor(readonly r: R, readonly next: Effect, readonly trace?: string) { super() } } export class ISuspend extends Base { readonly _tag = "Suspend" constructor( readonly factory: (platform: Platform, id: FiberID) => Effect, readonly trace?: string ) { super() } } export class ISuspendPartial extends Base { readonly _tag = "SuspendPartial" constructor( readonly factory: (platform: Platform, id: FiberID) => Effect, readonly onThrow: (u: unknown) => E2, readonly trace?: string ) { super() } } export class IFiberRefNew extends Base> { readonly _tag = "FiberRefNew" constructor( readonly initial: A, readonly onFork: (a: A) => A, readonly onJoin: (a: A, a2: A) => A ) { super() } } export class IFiberRefModify extends Base { readonly _tag = "FiberRefModify" constructor( readonly fiberRef: Runtime, readonly f: (a: A) => Tuple<[B, A]>, readonly trace?: string ) { super() } } export class IRaceWith extends Base< R & R1 & R2 & R3, E2 | E3, A2 | A3 > { readonly _tag = "RaceWith" constructor( readonly left: Effect, readonly right: Effect, readonly leftWins: ( exit: Exit.Exit, fiber: Fiber.Fiber ) => Effect, readonly rightWins: ( exit: Exit.Exit, fiber: Fiber.Fiber ) => Effect, readonly scope: O.Option>>, readonly trace?: string ) { super() } } export class ISupervise extends Base { readonly _tag = "Supervise" constructor( readonly effect: Effect, readonly supervisor: Supervisor, readonly trace?: string ) { super() } } export class IGetForkScope extends Base { readonly _tag = "GetForkScope" constructor( readonly f: (_: Scope>) => Effect, readonly trace?: string ) { super() } } export class IOverrideForkScope extends Base { readonly _tag = "OverrideForkScope" constructor( readonly effect: Effect, readonly forkScope: O.Option>>, readonly trace?: string ) { super() } } export * from "./effect.js"