@matechs/effect
Advanced tools
Comparing version 6.1.0 to 6.2.0
@@ -19,3 +19,2 @@ export declare enum EffectTag { | ||
export interface Effect<S, R, E, A> { | ||
_tag: EffectTag; | ||
_TAG: () => "Effect"; | ||
@@ -22,0 +21,0 @@ _E: () => E; |
import { either as E, function as F } from "fp-ts"; | ||
import { Cause, Exit } from "./original/exit"; | ||
import { Runtime } from "./original/runtime"; | ||
import * as T from "./effect"; | ||
@@ -8,22 +7,13 @@ import { DoublyLinkedList } from "./listc"; | ||
export declare type FrameType = Frame | FoldFrame | RegionFrameType | MapFrame; | ||
interface Frame { | ||
readonly _tag: "frame"; | ||
readonly prev: FrameType | undefined; | ||
export declare const FrameTag: "Frame"; | ||
export declare class Frame implements Frame { | ||
readonly apply: (u: unknown) => T.Instructions; | ||
} | ||
declare class Frame implements Frame { | ||
readonly apply: (u: unknown) => T.Instructions; | ||
readonly prev: FrameType | undefined; | ||
constructor(apply: (u: unknown) => T.Instructions, prev: FrameType | undefined); | ||
readonly _tag: "frame"; | ||
tag(): "Frame"; | ||
} | ||
interface FoldFrame { | ||
readonly _tag: "fold-frame"; | ||
readonly prev: FrameType | undefined; | ||
export declare const FoldFrameTag: "FoldFrame"; | ||
export declare class FoldFrame implements FoldFrame { | ||
readonly apply: (u: unknown) => T.Instructions; | ||
readonly recover: (cause: Cause<unknown>) => T.Instructions; | ||
} | ||
declare class FoldFrame implements FoldFrame { | ||
readonly apply: (u: unknown) => T.Instructions; | ||
readonly recover: (cause: Cause<unknown>) => T.Instructions; | ||
readonly prev: FrameType | undefined; | ||
@@ -35,20 +25,19 @@ constructor( | ||
); | ||
readonly _tag: "fold-frame"; | ||
tag(): "FoldFrame"; | ||
} | ||
interface MapFrame { | ||
readonly _tag: "map-frame"; | ||
readonly prev: FrameType | undefined; | ||
export declare const MapFrameTag: "MapFrame"; | ||
export declare class MapFrame implements MapFrame { | ||
readonly apply: (u: unknown) => unknown; | ||
} | ||
declare class MapFrame implements MapFrame { | ||
readonly apply: (u: unknown) => unknown; | ||
readonly prev: FrameType | undefined; | ||
constructor(apply: (u: unknown) => unknown, prev: FrameType | undefined); | ||
readonly _tag: "map-frame"; | ||
tag(): "MapFrame"; | ||
} | ||
interface InterruptFrame { | ||
readonly _tag: "interrupt-frame"; | ||
export declare const InterruptFrameTag: "InterruptFrame"; | ||
export declare class InterruptFrame { | ||
readonly interruptStatus: boolean[]; | ||
readonly prev: FrameType | undefined; | ||
readonly apply: (u: unknown) => T.Instructions; | ||
readonly exitRegion: () => void; | ||
constructor(interruptStatus: boolean[], prev: FrameType | undefined); | ||
apply(u: unknown): T.IPure<unknown>; | ||
exitRegion(): void; | ||
tag(): "InterruptFrame"; | ||
} | ||
@@ -62,6 +51,4 @@ export interface Driver<E, A> { | ||
export declare class DriverImpl<E, A> implements Driver<E, A> { | ||
readonly runtime: Runtime; | ||
completed: Exit<E, A> | null; | ||
listeners: F.FunctionN<[Exit<E, A>], void>[] | undefined; | ||
started: boolean; | ||
interrupted: boolean; | ||
@@ -72,3 +59,2 @@ currentFrame: FrameType | undefined; | ||
envStack: DoublyLinkedList<any>; | ||
constructor(runtime?: Runtime); | ||
set(a: Exit<E, A>): void; | ||
@@ -87,2 +73,125 @@ isComplete(): boolean; | ||
contextSwitch(op: T.AsyncFn<unknown, unknown>): void; | ||
IAccessEnv( | ||
_: T.IAccessEnv<any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
IProvideEnv(_: T.IProvideEnv<any, any, any, any>): any; | ||
IPure( | ||
_: T.IPure<A> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
IPureOption( | ||
_: T.IPureOption<any, any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
IPureEither( | ||
_: T.IPureEither<any, any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
IRaised( | ||
_: T.IRaised<any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
ICompleted( | ||
_: T.ICompleted<any, any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
ISuspended(_: T.ISuspended<any, any, any, any>): T.Effect<any, any, any, any>; | ||
IAsync(_: T.IAsync<any, any>): undefined; | ||
IChain(_: T.IChain<any, any, any, any, any, any, any, any>): any; | ||
IMap(_: T.IMap<any, any, any, any, any>): any; | ||
ICollapse(_: T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any>): any; | ||
IInterruptibleRegion(_: T.IInterruptibleRegion<any, any, any, any>): any; | ||
IAccessRuntime(_: T.IAccessRuntime<any>): T.IPure<any>; | ||
IAccessInterruptible(_: T.IAccessInterruptible<any>): T.IPure<any>; | ||
loop(go: T.Instructions): void; | ||
@@ -92,2 +201,1 @@ start(run: T.AsyncRE<{}, E, A>): void; | ||
} | ||
export {}; |
/* | ||
based on: https://github.com/rzeigler/waveguide/blob/master/src/driver.ts | ||
*/ | ||
import { either as E, option as O } from "fp-ts"; | ||
import { done, interruptWithError, raise, interruptWithErrorAndOthers } from "./original/exit"; | ||
@@ -9,10 +8,14 @@ import { defaultRuntime } from "./original/runtime"; | ||
import { DoublyLinkedList } from "./listc"; | ||
class Frame { | ||
export const FrameTag = "Frame"; | ||
export class Frame { | ||
constructor(apply, prev) { | ||
this.apply = apply; | ||
this.prev = prev; | ||
this._tag = "frame"; | ||
} | ||
tag() { | ||
return FrameTag; | ||
} | ||
} | ||
class FoldFrame { | ||
export const FoldFrameTag = "FoldFrame"; | ||
export class FoldFrame { | ||
constructor(apply, recover, prev) { | ||
@@ -22,28 +25,37 @@ this.apply = apply; | ||
this.prev = prev; | ||
this._tag = "fold-frame"; | ||
} | ||
tag() { | ||
return FoldFrameTag; | ||
} | ||
} | ||
class MapFrame { | ||
export const MapFrameTag = "MapFrame"; | ||
export class MapFrame { | ||
constructor(apply, prev) { | ||
this.apply = apply; | ||
this.prev = prev; | ||
this._tag = "map-frame"; | ||
} | ||
tag() { | ||
return MapFrameTag; | ||
} | ||
} | ||
const makeInterruptFrame = (interruptStatus, prev) => ({ | ||
prev, | ||
_tag: "interrupt-frame", | ||
export const InterruptFrameTag = "InterruptFrame"; | ||
export class InterruptFrame { | ||
constructor(interruptStatus, prev) { | ||
this.interruptStatus = interruptStatus; | ||
this.prev = prev; | ||
} | ||
apply(u) { | ||
interruptStatus.pop(); | ||
return T.Implementation.fromEffect(T.pure(u)); | ||
}, | ||
this.interruptStatus.pop(); | ||
return new T.IPure(u); | ||
} | ||
exitRegion() { | ||
interruptStatus.pop(); | ||
this.interruptStatus.pop(); | ||
} | ||
}); | ||
tag() { | ||
return InterruptFrameTag; | ||
} | ||
} | ||
export class DriverImpl { | ||
constructor(runtime = defaultRuntime) { | ||
this.runtime = runtime; | ||
constructor() { | ||
this.completed = null; | ||
this.started = false; | ||
this.interrupted = false; | ||
@@ -102,7 +114,7 @@ this.currentFrame = undefined; | ||
while (frame) { | ||
if (frame._tag === "fold-frame" && (e._tag !== "Interrupt" || !this.isInterruptible())) { | ||
if (frame.tag() === FoldFrameTag && (e._tag !== "Interrupt" || !this.isInterruptible())) { | ||
return frame.recover(e); | ||
} | ||
// We need to make sure we leave an interrupt region or environment provision region while unwinding on errors | ||
if (frame._tag === "interrupt-frame") { | ||
if (frame.tag() === InterruptFrameTag) { | ||
frame.exitRegion(); | ||
@@ -127,3 +139,3 @@ } | ||
resumeInterrupt(err, others) { | ||
this.runtime.dispatch(this.dispatchResumeInterrupt.bind(this), { err, others }); | ||
defaultRuntime.dispatch(this.dispatchResumeInterrupt.bind(this), { err, others }); | ||
} | ||
@@ -135,13 +147,12 @@ next(value) { | ||
if (frame) { | ||
switch (frame._tag) { | ||
case "map-frame": { | ||
if (this.currentFrame === undefined) { | ||
this.complete(done(frame.apply(value))); | ||
return; | ||
} | ||
return new T.Implementation(T.EffectTag.Pure, frame.apply(value)); | ||
if (frame.tag() === MapFrameTag) { | ||
if (this.currentFrame === undefined) { | ||
this.complete(done(frame.apply(value))); | ||
return; | ||
} | ||
default: | ||
return frame.apply(value); | ||
return new T.IPure(frame.apply(value)); | ||
} | ||
else { | ||
return frame.apply(value); | ||
} | ||
} | ||
@@ -152,4 +163,4 @@ this.complete(done(value)); | ||
foldResume(status) { | ||
E.fold((cause) => { | ||
const go = this.handle(raise(cause)); | ||
if (status._tag === "Right") { | ||
const go = this.next(status.right); | ||
if (go) { | ||
@@ -159,4 +170,5 @@ /* eslint-disable-next-line */ | ||
} | ||
}, (value) => { | ||
const go = this.next(value); | ||
} | ||
else { | ||
const go = this.handle(raise(status.left)); | ||
if (go) { | ||
@@ -166,7 +178,7 @@ /* eslint-disable-next-line */ | ||
} | ||
})(status); | ||
} | ||
} | ||
resume(status) { | ||
this.cancelAsync = undefined; | ||
this.runtime.dispatch(this.foldResume.bind(this), status); | ||
defaultRuntime.dispatch(this.foldResume.bind(this), status); | ||
} | ||
@@ -189,2 +201,84 @@ contextSwitch(op) { | ||
} | ||
IAccessEnv(_) { | ||
const env = !this.envStack.empty() ? this.envStack.tail.value : {}; | ||
return this.next(env); | ||
} | ||
IProvideEnv(_) { | ||
this.envStack.append(_.r); | ||
return T.effect.foldExit(_.e, (e) => T.effect.chain(T.sync(() => { | ||
this.envStack.deleteTail(); | ||
return {}; | ||
}), (_) => T.raised(e)), (r) => T.sync(() => { | ||
this.envStack.deleteTail(); | ||
return r; | ||
})); | ||
} | ||
IPure(_) { | ||
return this.next(_.a); | ||
} | ||
IPureOption(_) { | ||
if (_.a._tag === "Some") { | ||
return this.next(_.a.value); | ||
} | ||
else { | ||
return this.handle(raise(_.onEmpty())); | ||
} | ||
} | ||
IPureEither(_) { | ||
if (_.a._tag === "Right") { | ||
return this.next(_.a.right); | ||
} | ||
else { | ||
return this.handle(raise(_.a.left)); | ||
} | ||
} | ||
IRaised(_) { | ||
if (_.e._tag === "Interrupt") { | ||
this.interrupted = true; | ||
} | ||
return this.handle(_.e); | ||
} | ||
ICompleted(_) { | ||
if (_.e._tag === "Done") { | ||
return this.next(_.e.value); | ||
} | ||
else { | ||
return this.handle(_.e); | ||
} | ||
} | ||
ISuspended(_) { | ||
return _.e(); | ||
} | ||
IAsync(_) { | ||
this.contextSwitch(_.e); | ||
return undefined; | ||
} | ||
IChain(_) { | ||
this.currentFrame = new Frame(_.f, this.currentFrame); | ||
return _.e; | ||
} | ||
IMap(_) { | ||
this.currentFrame = new MapFrame(_.f, this.currentFrame); | ||
return _.e; | ||
} | ||
ICollapse(_) { | ||
this.currentFrame = new FoldFrame(_.success, _.failure, this.currentFrame); | ||
return _.inner; | ||
} | ||
IInterruptibleRegion(_) { | ||
if (this.interruptRegionStack === undefined) { | ||
this.interruptRegionStack = [_.int]; | ||
} | ||
else { | ||
this.interruptRegionStack.push(_.int); | ||
} | ||
this.currentFrame = new InterruptFrame(this.interruptRegionStack, this.currentFrame); | ||
return _.e; | ||
} | ||
IAccessRuntime(_) { | ||
return new T.IPure(_.f(defaultRuntime)); | ||
} | ||
IAccessInterruptible(_) { | ||
return new T.IPure(_.f(this.isInterruptible())); | ||
} | ||
// tslint:disable-next-line: cyclomatic-complexity | ||
@@ -195,94 +289,6 @@ loop(go) { | ||
try { | ||
switch (current._tag) { | ||
case T.EffectTag.AccessEnv: | ||
const env = !this.envStack.empty() ? this.envStack.tail.value : {}; | ||
current = this.next(env); | ||
break; | ||
case T.EffectTag.ProvideEnv: | ||
this.envStack.append(current.f1); | ||
current = T.Implementation.fromEffect(T.effect.foldExit(current.f0, (e) => T.effect.chain(T.sync(() => { | ||
this.envStack.deleteTail(); | ||
return {}; | ||
}), (_) => T.raised(e)), (r) => T.sync(() => { | ||
this.envStack.deleteTail(); | ||
return r; | ||
}))); | ||
break; | ||
case T.EffectTag.Pure: | ||
current = this.next(current.f0); | ||
break; | ||
case T.EffectTag.PureOption: { | ||
if (O.isSome(current.f0)) { | ||
current = this.next(current.f0.value); | ||
} | ||
else { | ||
current = this.handle(raise(current.f1())); | ||
} | ||
break; | ||
} | ||
case T.EffectTag.PureEither: { | ||
if (E.isRight(current.f0)) { | ||
current = this.next(current.f0.right); | ||
} | ||
else { | ||
current = this.handle(raise(current.f0.left)); | ||
} | ||
break; | ||
} | ||
case T.EffectTag.Raised: | ||
if (current.f0._tag === "Interrupt") { | ||
this.interrupted = true; | ||
} | ||
current = this.handle(current.f0); | ||
break; | ||
case T.EffectTag.Completed: | ||
if (current.f0._tag === "Done") { | ||
current = this.next(current.f0.value); | ||
} | ||
else { | ||
current = this.handle(current.f0); | ||
} | ||
break; | ||
case T.EffectTag.Suspended: | ||
current = current.f0(); | ||
break; | ||
case T.EffectTag.Async: | ||
this.contextSwitch(current.f0); | ||
current = undefined; | ||
break; | ||
case T.EffectTag.Chain: | ||
this.currentFrame = new Frame(current.f1, this.currentFrame); | ||
current = current.f0; | ||
break; | ||
case T.EffectTag.Map: | ||
this.currentFrame = new MapFrame(current.f1, this.currentFrame); | ||
current = current.f0; | ||
break; | ||
case T.EffectTag.Collapse: | ||
this.currentFrame = new FoldFrame(current.f2, current.f1, this.currentFrame); | ||
current = current.f0; | ||
break; | ||
case T.EffectTag.InterruptibleRegion: | ||
if (this.interruptRegionStack === undefined) { | ||
this.interruptRegionStack = [current.f0]; | ||
} | ||
else { | ||
this.interruptRegionStack.push(current.f0); | ||
} | ||
this.currentFrame = makeInterruptFrame(this.interruptRegionStack, this.currentFrame); | ||
current = current.f1; | ||
break; | ||
case T.EffectTag.AccessRuntime: | ||
current = T.Implementation.fromEffect(T.pure(current.f0(this.runtime))); | ||
break; | ||
case T.EffectTag.AccessInterruptible: | ||
current = T.Implementation.fromEffect(T.pure(current.f0(this.isInterruptible()))); | ||
break; | ||
default: | ||
/* istanbul ignore next */ | ||
throw new Error(`Die: Unrecognized current type ${current}`); | ||
} | ||
current = this[current.tag()](current); | ||
} | ||
catch (e) { | ||
current = T.Implementation.fromEffect(T.raiseAbort(e)); | ||
current = new T.IRaised({ _tag: "Abort", abortedWith: e }); | ||
} | ||
@@ -296,8 +302,3 @@ } | ||
start(run) { | ||
if (this.started) { | ||
/* istanbul ignore next */ | ||
throw new Error("Bug: Runtime may not be started multiple times"); | ||
} | ||
this.started = true; | ||
this.runtime.dispatch(this.loop.bind(this), run); | ||
defaultRuntime.dispatch(this.loop.bind(this), run); | ||
} | ||
@@ -304,0 +305,0 @@ interrupt() { |
import { either as E, function as F } from "fp-ts"; | ||
import { Cause, Exit } from "./original/exit"; | ||
import { Runtime } from "./original/runtime"; | ||
import * as T from "./effect"; | ||
import * as L from "./list"; | ||
export declare type RegionFrameType = InterruptFrame; | ||
export declare type FrameType = Frame | FoldFrame | RegionFrameType | MapFrame; | ||
interface Frame { | ||
readonly _tag: "frame"; | ||
readonly prev: FrameType | undefined; | ||
readonly apply: (u: unknown) => T.Instructions; | ||
} | ||
declare class Frame implements Frame { | ||
readonly apply: (u: unknown) => T.Instructions; | ||
readonly prev: FrameType | undefined; | ||
constructor(apply: (u: unknown) => T.Instructions, prev: FrameType | undefined); | ||
readonly _tag: "frame"; | ||
} | ||
interface FoldFrame { | ||
readonly _tag: "fold-frame"; | ||
readonly prev: FrameType | undefined; | ||
readonly apply: (u: unknown) => T.Instructions; | ||
readonly recover: (cause: Cause<unknown>) => T.Instructions; | ||
} | ||
declare class FoldFrame implements FoldFrame { | ||
readonly apply: (u: unknown) => T.Instructions; | ||
readonly recover: (cause: Cause<unknown>) => T.Instructions; | ||
readonly prev: FrameType | undefined; | ||
constructor( | ||
apply: (u: unknown) => T.Instructions, | ||
recover: (cause: Cause<unknown>) => T.Instructions, | ||
prev: FrameType | undefined | ||
); | ||
readonly _tag: "fold-frame"; | ||
} | ||
interface MapFrame { | ||
readonly _tag: "map-frame"; | ||
readonly prev: FrameType | undefined; | ||
readonly apply: (u: unknown) => unknown; | ||
} | ||
declare class MapFrame implements MapFrame { | ||
readonly apply: (u: unknown) => unknown; | ||
readonly prev: FrameType | undefined; | ||
constructor(apply: (u: unknown) => unknown, prev: FrameType | undefined); | ||
readonly _tag: "map-frame"; | ||
} | ||
interface InterruptFrame { | ||
readonly _tag: "interrupt-frame"; | ||
readonly prev: FrameType | undefined; | ||
readonly apply: (u: unknown) => T.Instructions; | ||
readonly exitRegion: () => void; | ||
} | ||
import { DoublyLinkedList } from "./listc"; | ||
import { FrameType } from "./driver"; | ||
export interface DriverSync<E, A> { | ||
@@ -57,11 +10,8 @@ start(run: T.SyncE<E, A>): E.Either<Error, Exit<E, A>>; | ||
export declare class DriverSyncImpl<E, A> implements DriverSync<E, A> { | ||
readonly runtime: Runtime; | ||
completed: Exit<E, A> | null; | ||
listeners: F.FunctionN<[Exit<E, A>], void>[] | undefined; | ||
started: boolean; | ||
interrupted: boolean; | ||
currentFrame: FrameType | undefined; | ||
interruptRegionStack: boolean[] | undefined; | ||
envStack: L.List<any>; | ||
constructor(runtime?: Runtime); | ||
envStack: DoublyLinkedList<any>; | ||
set(a: Exit<E, A>): void; | ||
@@ -77,2 +27,125 @@ isComplete(): boolean; | ||
resume(status: E.Either<unknown, unknown>): void; | ||
IAccessEnv( | ||
_: T.IAccessEnv<any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
IProvideEnv(_: T.IProvideEnv<any, any, any, any>): any; | ||
IPure( | ||
_: T.IPure<A> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
IPureOption( | ||
_: T.IPureOption<any, any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
IPureEither( | ||
_: T.IPureEither<any, any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
IRaised( | ||
_: T.IRaised<any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
ICompleted( | ||
_: T.ICompleted<any, any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
ISuspended(_: T.ISuspended<any, any, any, any>): T.Effect<any, any, any, any>; | ||
IAsync(_: T.IAsync<any, any>): undefined; | ||
IChain(_: T.IChain<any, any, any, any, any, any, any, any>): any; | ||
IMap(_: T.IMap<any, any, any, any, any>): any; | ||
ICollapse(_: T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any>): any; | ||
IInterruptibleRegion(_: T.IInterruptibleRegion<any, any, any, any>): any; | ||
IAccessRuntime(_: T.IAccessRuntime<any>): T.IPure<any>; | ||
IAccessInterruptible(_: T.IAccessInterruptible<any>): T.IPure<any>; | ||
loop(go: T.Instructions): void; | ||
@@ -82,2 +155,1 @@ start(run: T.SyncRE<{}, E, A>): E.Either<Error, Exit<E, A>>; | ||
} | ||
export {}; |
/* | ||
based on: https://github.com/rzeigler/waveguide/blob/master/src/driver.ts | ||
*/ | ||
import { option as O, either as E } from "fp-ts"; | ||
import { either as E } from "fp-ts"; | ||
import { done, interrupt as interruptExit, raise } from "./original/exit"; | ||
import { defaultRuntime } from "./original/runtime"; | ||
import * as T from "./effect"; | ||
import * as L from "./list"; | ||
class Frame { | ||
constructor(apply, prev) { | ||
this.apply = apply; | ||
this.prev = prev; | ||
this._tag = "frame"; | ||
} | ||
} | ||
class FoldFrame { | ||
constructor(apply, recover, prev) { | ||
this.apply = apply; | ||
this.recover = recover; | ||
this.prev = prev; | ||
this._tag = "fold-frame"; | ||
} | ||
} | ||
class MapFrame { | ||
constructor(apply, prev) { | ||
this.apply = apply; | ||
this.prev = prev; | ||
this._tag = "map-frame"; | ||
} | ||
} | ||
const makeInterruptFrame = (interruptStatus, prev) => ({ | ||
prev, | ||
_tag: "interrupt-frame", | ||
apply(u) { | ||
interruptStatus.pop(); | ||
return T.Implementation.fromEffect(T.pure(u)); | ||
}, | ||
exitRegion() { | ||
interruptStatus.pop(); | ||
} | ||
}); | ||
import { DoublyLinkedList } from "./listc"; | ||
import { Frame, MapFrame, FoldFrame, InterruptFrame, FoldFrameTag, InterruptFrameTag, MapFrameTag } from "./driver"; | ||
export class DriverSyncImpl { | ||
constructor(runtime = defaultRuntime) { | ||
this.runtime = runtime; | ||
constructor() { | ||
this.completed = null; | ||
this.started = false; | ||
this.interrupted = false; | ||
this.currentFrame = undefined; | ||
this.envStack = L.empty(); | ||
this.envStack = new DoublyLinkedList(); | ||
} | ||
@@ -79,7 +45,7 @@ set(a) { | ||
while (frame) { | ||
if (frame._tag === "fold-frame" && (e._tag !== "Interrupt" || !this.isInterruptible())) { | ||
if (frame.tag() === FoldFrameTag && (e._tag !== "Interrupt" || !this.isInterruptible())) { | ||
return frame.recover(e); | ||
} | ||
// We need to make sure we leave an interrupt region or environment provision region while unwinding on errors | ||
if (frame._tag === "interrupt-frame") { | ||
if (frame.tag() === InterruptFrameTag) { | ||
frame.exitRegion(); | ||
@@ -109,13 +75,12 @@ } | ||
if (frame) { | ||
switch (frame._tag) { | ||
case "map-frame": { | ||
if (this.currentFrame === undefined) { | ||
this.complete(done(frame.apply(value))); | ||
return; | ||
} | ||
return new T.Implementation(T.EffectTag.Pure, frame.apply(value)); | ||
if (frame.tag() === MapFrameTag) { | ||
if (this.currentFrame === undefined) { | ||
this.complete(done(frame.apply(value))); | ||
return; | ||
} | ||
default: | ||
return frame.apply(value); | ||
return new T.IPure(frame.apply(value)); | ||
} | ||
else { | ||
return frame.apply(value); | ||
} | ||
} | ||
@@ -126,4 +91,4 @@ this.complete(done(value)); | ||
foldResume(status) { | ||
E.fold((cause) => { | ||
const go = this.handle(raise(cause)); | ||
if (status._tag === "Right") { | ||
const go = this.next(status.right); | ||
if (go) { | ||
@@ -133,4 +98,5 @@ /* eslint-disable-next-line */ | ||
} | ||
}, (value) => { | ||
const go = this.next(value); | ||
} | ||
else { | ||
const go = this.handle(raise(status.left)); | ||
if (go) { | ||
@@ -140,3 +106,3 @@ /* eslint-disable-next-line */ | ||
} | ||
})(status); | ||
} | ||
} | ||
@@ -146,2 +112,83 @@ resume(status) { | ||
} | ||
IAccessEnv(_) { | ||
const env = !this.envStack.empty() ? this.envStack.tail.value : {}; | ||
return this.next(env); | ||
} | ||
IProvideEnv(_) { | ||
this.envStack.append(_.r); | ||
return T.effect.foldExit(_.e, (e) => T.effect.chain(T.sync(() => { | ||
this.envStack.deleteTail(); | ||
return {}; | ||
}), (_) => T.raised(e)), (r) => T.sync(() => { | ||
this.envStack.deleteTail(); | ||
return r; | ||
})); | ||
} | ||
IPure(_) { | ||
return this.next(_.a); | ||
} | ||
IPureOption(_) { | ||
if (_.a._tag === "Some") { | ||
return this.next(_.a.value); | ||
} | ||
else { | ||
return this.handle(raise(_.onEmpty())); | ||
} | ||
} | ||
IPureEither(_) { | ||
if (_.a._tag === "Right") { | ||
return this.next(_.a.right); | ||
} | ||
else { | ||
return this.handle(raise(_.a.left)); | ||
} | ||
} | ||
IRaised(_) { | ||
if (_.e._tag === "Interrupt") { | ||
this.interrupted = true; | ||
} | ||
return this.handle(_.e); | ||
} | ||
ICompleted(_) { | ||
if (_.e._tag === "Done") { | ||
return this.next(_.e.value); | ||
} | ||
else { | ||
return this.handle(_.e); | ||
} | ||
} | ||
ISuspended(_) { | ||
return _.e(); | ||
} | ||
IAsync(_) { | ||
return undefined; | ||
} | ||
IChain(_) { | ||
this.currentFrame = new Frame(_.f, this.currentFrame); | ||
return _.e; | ||
} | ||
IMap(_) { | ||
this.currentFrame = new MapFrame(_.f, this.currentFrame); | ||
return _.e; | ||
} | ||
ICollapse(_) { | ||
this.currentFrame = new FoldFrame(_.success, _.failure, this.currentFrame); | ||
return _.inner; | ||
} | ||
IInterruptibleRegion(_) { | ||
if (this.interruptRegionStack === undefined) { | ||
this.interruptRegionStack = [_.int]; | ||
} | ||
else { | ||
this.interruptRegionStack.push(_.int); | ||
} | ||
this.currentFrame = new InterruptFrame(this.interruptRegionStack, this.currentFrame); | ||
return _.e; | ||
} | ||
IAccessRuntime(_) { | ||
return new T.IPure(_.f(defaultRuntime)); | ||
} | ||
IAccessInterruptible(_) { | ||
return new T.IPure(_.f(this.isInterruptible())); | ||
} | ||
// tslint:disable-next-line: cyclomatic-complexity | ||
@@ -152,93 +199,6 @@ loop(go) { | ||
try { | ||
switch (current._tag) { | ||
case T.EffectTag.AccessEnv: | ||
const env = L.isNotEmpty(this.envStack) ? L.lastUnsafe(this.envStack) : {}; | ||
current = this.next(env); | ||
break; | ||
case T.EffectTag.ProvideEnv: | ||
L.push(this.envStack, current.f1); | ||
current = T.Implementation.fromEffect(T.effect.foldExit(current.f0, (e) => T.effect.chain(T.sync(() => { | ||
L.popLastUnsafe(this.envStack); | ||
return {}; | ||
}), (_) => T.raised(e)), (r) => T.sync(() => { | ||
L.popLastUnsafe(this.envStack); | ||
return r; | ||
}))); | ||
break; | ||
case T.EffectTag.Pure: | ||
current = this.next(current.f0); | ||
break; | ||
case T.EffectTag.PureOption: { | ||
if (O.isSome(current.f0)) { | ||
current = this.next(current.f0.value); | ||
} | ||
else { | ||
current = this.handle(raise(current.f1())); | ||
} | ||
break; | ||
} | ||
case T.EffectTag.PureEither: { | ||
if (E.isRight(current.f0)) { | ||
current = this.next(current.f0.right); | ||
} | ||
else { | ||
current = this.handle(raise(current.f0.left)); | ||
} | ||
break; | ||
} | ||
case T.EffectTag.Raised: | ||
if (current.f0._tag === "Interrupt") { | ||
this.interrupted = true; | ||
} | ||
current = this.handle(current.f0); | ||
break; | ||
case T.EffectTag.Completed: | ||
if (current.f0._tag === "Done") { | ||
current = this.next(current.f0.value); | ||
} | ||
else { | ||
current = this.handle(current.f0); | ||
} | ||
break; | ||
case T.EffectTag.Suspended: | ||
current = current.f0(); | ||
break; | ||
case T.EffectTag.Async: | ||
current = undefined; | ||
break; | ||
case T.EffectTag.Chain: | ||
this.currentFrame = new Frame(current.f1, this.currentFrame); | ||
current = current.f0; | ||
break; | ||
case T.EffectTag.Map: | ||
this.currentFrame = new MapFrame(current.f1, this.currentFrame); | ||
current = current.f0; | ||
break; | ||
case T.EffectTag.Collapse: | ||
this.currentFrame = new FoldFrame(current.f2, current.f1, this.currentFrame); | ||
current = current.f0; | ||
break; | ||
case T.EffectTag.InterruptibleRegion: | ||
if (this.interruptRegionStack === undefined) { | ||
this.interruptRegionStack = [current.f0]; | ||
} | ||
else { | ||
this.interruptRegionStack.push(current.f0); | ||
} | ||
this.currentFrame = makeInterruptFrame(this.interruptRegionStack, this.currentFrame); | ||
current = current.f1; | ||
break; | ||
case T.EffectTag.AccessRuntime: | ||
current = T.Implementation.fromEffect(T.pure(current.f0(this.runtime))); | ||
break; | ||
case T.EffectTag.AccessInterruptible: | ||
current = T.Implementation.fromEffect(T.pure(current.f0(this.isInterruptible()))); | ||
break; | ||
default: | ||
/* istanbul ignore next */ | ||
throw new Error(`Die: Unrecognized current type ${current}`); | ||
} | ||
current = this[current.tag()](current); | ||
} | ||
catch (e) { | ||
current = T.Implementation.fromEffect(T.raiseAbort(e)); | ||
current = new T.IRaised({ _tag: "Abort", abortedWith: e }); | ||
} | ||
@@ -245,0 +205,0 @@ } |
@@ -47,41 +47,47 @@ import { | ||
export declare type Instructions = | ||
| Pure | ||
| PureOption | ||
| PureEither | ||
| Raised | ||
| Completed | ||
| Suspended | ||
| IAsync | ||
| IChain | ||
| ICollapse | ||
| IInterruptibleRegion | ||
| IAccessInterruptible | ||
| IAccessRuntime | ||
| IAccessEnv | ||
| IProvideEnv | ||
| IMap; | ||
export interface Pure<A = unknown> { | ||
readonly _tag: EffectTag.Pure; | ||
readonly f0: A; | ||
| IPure<any> | ||
| IPureOption<any, any> | ||
| IPureEither<any, any> | ||
| IRaised<any> | ||
| ICompleted<any, any> | ||
| ISuspended<any, any, any, any> | ||
| IAsync<any, any> | ||
| IChain<any, any, any, any, any, any, any, any> | ||
| ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| IInterruptibleRegion<any, any, any, any> | ||
| IAccessInterruptible<any> | ||
| IAccessRuntime<any> | ||
| IAccessEnv<any> | ||
| IProvideEnv<any, any, any, any> | ||
| IMap<any, any, any, any, any>; | ||
export declare class IPure<A> { | ||
readonly a: A; | ||
constructor(a: A); | ||
tag(): "IPure"; | ||
} | ||
export interface PureOption<A = unknown, E = never> { | ||
readonly _tag: EffectTag.PureOption; | ||
readonly f0: Op.Option<A>; | ||
readonly f1: F.Lazy<E>; | ||
export declare class IPureOption<E, A> { | ||
readonly a: Op.Option<A>; | ||
readonly onEmpty: () => E; | ||
constructor(a: Op.Option<A>, onEmpty: () => E); | ||
tag(): "IPureOption"; | ||
} | ||
export interface PureEither<A = unknown, E = never> { | ||
readonly _tag: EffectTag.PureEither; | ||
readonly f0: Ei.Either<E, A>; | ||
export declare class IPureEither<E, A> { | ||
readonly a: Ei.Either<E, A>; | ||
constructor(a: Ei.Either<E, A>); | ||
tag(): "IPureEither"; | ||
} | ||
export interface Raised<E = unknown> { | ||
readonly _tag: EffectTag.Raised; | ||
readonly f0: ex.Cause<E>; | ||
export declare class IRaised<E> { | ||
readonly e: ex.Cause<E>; | ||
constructor(e: ex.Cause<E>); | ||
tag(): "IRaised"; | ||
} | ||
export interface Completed<E = unknown, A = unknown> { | ||
readonly _tag: EffectTag.Completed; | ||
readonly f0: ex.Exit<E, A>; | ||
export declare class ICompleted<E, A> { | ||
readonly e: ex.Exit<E, A>; | ||
constructor(e: ex.Exit<E, A>); | ||
tag(): "ICompleted"; | ||
} | ||
export interface Suspended { | ||
readonly _tag: EffectTag.Suspended; | ||
readonly f0: F.Lazy<Instructions>; | ||
export declare class ISuspended<S, R, E, A> { | ||
readonly e: F.Lazy<Effect<S, R, E, A>>; | ||
constructor(e: F.Lazy<Effect<S, R, E, A>>); | ||
tag(): "ISuspended"; | ||
} | ||
@@ -94,57 +100,55 @@ export declare type AsyncContFn<E, A> = F.FunctionN<[Ei.Either<E, A>], void>; | ||
export declare type AsyncFn<E, A> = F.FunctionN<[AsyncContFn<E, A>], AsyncCancelContFn>; | ||
export interface IAsync<E = unknown, A = unknown> { | ||
readonly _tag: EffectTag.Async; | ||
readonly f0: AsyncFn<E, A>; | ||
export declare class IAsync<E, A> { | ||
readonly e: AsyncFn<E, A>; | ||
constructor(e: AsyncFn<E, A>); | ||
tag(): "IAsync"; | ||
} | ||
export interface IChain<Z = unknown> { | ||
readonly _tag: EffectTag.Chain; | ||
readonly f0: Instructions; | ||
readonly f1: F.FunctionN<[Z], Instructions>; | ||
export declare class IChain<S, R, E, A, S1, R1, E1, B> { | ||
readonly e: Effect<S, R, E, A>; | ||
readonly f: (a: A) => Effect<S1, R1, E1, B>; | ||
constructor(e: Effect<S, R, E, A>, f: (a: A) => Effect<S1, R1, E1, B>); | ||
tag(): "IChain"; | ||
} | ||
export interface IMap<A = unknown, B = unknown> { | ||
readonly _tag: EffectTag.Map; | ||
readonly f0: Instructions; | ||
readonly f1: F.FunctionN<[A], B>; | ||
export declare class IMap<S, R, E, A, B> { | ||
readonly e: Effect<S, R, E, A>; | ||
readonly f: (a: A) => B; | ||
constructor(e: Effect<S, R, E, A>, f: (a: A) => B); | ||
tag(): "IMap"; | ||
} | ||
export interface ICollapse<E1 = unknown, A1 = unknown> { | ||
readonly _tag: EffectTag.Collapse; | ||
readonly f0: Instructions; | ||
readonly f1: F.FunctionN<[ex.Cause<E1>], Instructions>; | ||
readonly f2: F.FunctionN<[A1], Instructions>; | ||
export declare class ICollapse<S1, S2, S3, R, R2, R3, E1, E2, E3, A1, A2, A3> { | ||
readonly inner: Effect<S1, R, E1, A1>; | ||
readonly failure: F.FunctionN<[ex.Cause<E1>], Effect<S2, R2, E2, A2>>; | ||
readonly success: F.FunctionN<[A1], Effect<S3, R3, E3, A3>>; | ||
constructor( | ||
inner: Effect<S1, R, E1, A1>, | ||
failure: F.FunctionN<[ex.Cause<E1>], Effect<S2, R2, E2, A2>>, | ||
success: F.FunctionN<[A1], Effect<S3, R3, E3, A3>> | ||
); | ||
tag(): "ICollapse"; | ||
} | ||
export interface IInterruptibleRegion { | ||
readonly _tag: EffectTag.InterruptibleRegion; | ||
readonly f0: boolean; | ||
readonly f1: Instructions; | ||
export declare class IInterruptibleRegion<S, R, E, A> { | ||
readonly e: Effect<S, R, E, A>; | ||
readonly int: boolean; | ||
constructor(e: Effect<S, R, E, A>, int: boolean); | ||
tag(): "IInterruptibleRegion"; | ||
} | ||
export interface IAccessInterruptible<A = unknown> { | ||
readonly _tag: EffectTag.AccessInterruptible; | ||
readonly f0: F.FunctionN<[boolean], A>; | ||
export declare class IAccessInterruptible<A> { | ||
readonly f: (_: boolean) => A; | ||
constructor(f: (_: boolean) => A); | ||
tag(): "IAccessInterruptible"; | ||
} | ||
export interface IAccessRuntime<A = unknown> { | ||
readonly _tag: EffectTag.AccessRuntime; | ||
readonly f0: F.FunctionN<[Runtime], A>; | ||
export declare class IAccessRuntime<A> { | ||
readonly f: (_: Runtime) => A; | ||
constructor(f: (_: Runtime) => A); | ||
tag(): "IAccessRuntime"; | ||
} | ||
export interface IProvideEnv<R = unknown> { | ||
readonly _tag: EffectTag.ProvideEnv; | ||
readonly f0: Instructions; | ||
readonly f1: R; | ||
export declare class IProvideEnv<S, R, E, A> { | ||
readonly e: Effect<S, R, E, A>; | ||
readonly r: R; | ||
constructor(e: Effect<S, R, E, A>, r: R); | ||
tag(): "IProvideEnv"; | ||
} | ||
export interface IAccessEnv<R = unknown> { | ||
readonly _tag: EffectTag.AccessEnv; | ||
readonly f0: R; | ||
export declare class IAccessEnv<R> { | ||
tag(): "IAccessEnv"; | ||
} | ||
export declare class Implementation<S, R, E, A> implements Effect<S, R, E, A> { | ||
readonly _tag: EffectTag; | ||
readonly f0: any; | ||
readonly f1: any; | ||
readonly f2: any; | ||
static fromEffect<S, R, E, A>(eff: Effect<S, R, E, A>): Implementation<S, R, E, A>; | ||
constructor(_tag: EffectTag, f0?: any, f1?: any, f2?: any); | ||
_TAG(): "Effect"; | ||
_A(): A; | ||
_E(): E; | ||
_S(): S; | ||
_R(_: R): void; | ||
} | ||
/** | ||
@@ -151,0 +155,0 @@ * An IO has succeeded |
@@ -16,33 +16,141 @@ import { either as Ei, function as F, option as Op, array as Ar, tree as TR, record as RE } from "fp-ts"; | ||
export const URI = "matechs/Effect"; | ||
export class Implementation { | ||
constructor(_tag, f0 = undefined, f1 = undefined, f2 = undefined) { | ||
this._tag = _tag; | ||
this.f0 = f0; | ||
this.f1 = f1; | ||
this.f2 = f2; | ||
const IPureTag = "IPure"; | ||
export class IPure { | ||
constructor(a) { | ||
this.a = a; | ||
} | ||
static fromEffect(eff) { | ||
return eff; | ||
tag() { | ||
return IPureTag; | ||
} | ||
/* istanbul ignore next */ | ||
_TAG() { | ||
return undefined; | ||
} | ||
const IPureOptionTag = "IPureOption"; | ||
export class IPureOption { | ||
constructor(a, onEmpty) { | ||
this.a = a; | ||
this.onEmpty = onEmpty; | ||
} | ||
/* istanbul ignore next */ | ||
_A() { | ||
return undefined; | ||
tag() { | ||
return IPureOptionTag; | ||
} | ||
/* istanbul ignore next */ | ||
_E() { | ||
return undefined; | ||
} | ||
const IPureEitherTag = "IPureEither"; | ||
export class IPureEither { | ||
constructor(a) { | ||
this.a = a; | ||
} | ||
/* istanbul ignore next */ | ||
_S() { | ||
return undefined; | ||
tag() { | ||
return IPureEitherTag; | ||
} | ||
/* istanbul ignore next */ | ||
_R(_) { | ||
return undefined; | ||
} | ||
const IRaisedTag = "IRaised"; | ||
export class IRaised { | ||
constructor(e) { | ||
this.e = e; | ||
} | ||
tag() { | ||
return IRaisedTag; | ||
} | ||
} | ||
const ICompletedTag = "ICompleted"; | ||
export class ICompleted { | ||
constructor(e) { | ||
this.e = e; | ||
} | ||
tag() { | ||
return ICompletedTag; | ||
} | ||
} | ||
const ISuspendedTag = "ISuspended"; | ||
export class ISuspended { | ||
constructor(e) { | ||
this.e = e; | ||
} | ||
tag() { | ||
return ISuspendedTag; | ||
} | ||
} | ||
const IAsyncTag = "IAsync"; | ||
export class IAsync { | ||
constructor(e) { | ||
this.e = e; | ||
} | ||
tag() { | ||
return IAsyncTag; | ||
} | ||
} | ||
const IChainTag = "IChain"; | ||
export class IChain { | ||
constructor(e, f) { | ||
this.e = e; | ||
this.f = f; | ||
} | ||
tag() { | ||
return IChainTag; | ||
} | ||
} | ||
const IMapTag = "IMap"; | ||
export class IMap { | ||
constructor(e, f) { | ||
this.e = e; | ||
this.f = f; | ||
} | ||
tag() { | ||
return IMapTag; | ||
} | ||
} | ||
const ICollapseTag = "ICollapse"; | ||
export class ICollapse { | ||
constructor(inner, failure, success) { | ||
this.inner = inner; | ||
this.failure = failure; | ||
this.success = success; | ||
} | ||
tag() { | ||
return ICollapseTag; | ||
} | ||
} | ||
const IInterruptibleRegionTag = "IInterruptibleRegion"; | ||
export class IInterruptibleRegion { | ||
constructor(e, int) { | ||
this.e = e; | ||
this.int = int; | ||
} | ||
tag() { | ||
return IInterruptibleRegionTag; | ||
} | ||
} | ||
const IAccessInterruptibleTag = "IAccessInterruptible"; | ||
export class IAccessInterruptible { | ||
constructor(f) { | ||
this.f = f; | ||
} | ||
tag() { | ||
return IAccessInterruptibleTag; | ||
} | ||
} | ||
const IAccessRuntimeTag = "IAccessRuntime"; | ||
export class IAccessRuntime { | ||
constructor(f) { | ||
this.f = f; | ||
} | ||
tag() { | ||
return IAccessRuntimeTag; | ||
} | ||
} | ||
const IProvideEnvTag = "IProvideEnv"; | ||
export class IProvideEnv { | ||
constructor(e, r) { | ||
this.e = e; | ||
this.r = r; | ||
} | ||
tag() { | ||
return IProvideEnvTag; | ||
} | ||
} | ||
const IAccessEnvTag = "IAccessEnv"; | ||
export class IAccessEnv { | ||
tag() { | ||
return IAccessEnvTag; | ||
} | ||
} | ||
/** | ||
@@ -53,3 +161,3 @@ * An IO has succeeded | ||
export function pure(a) { | ||
return new Implementation(EffectTag.Pure, a); | ||
return new IPure(a); | ||
} | ||
@@ -63,3 +171,3 @@ /** | ||
export function raised(e) { | ||
return new Implementation(EffectTag.Raised, e); | ||
return new IRaised(e); | ||
} | ||
@@ -89,3 +197,3 @@ /** | ||
export function completed(exit) { | ||
return new Implementation(EffectTag.Completed, exit); | ||
return new ICompleted(exit); | ||
} | ||
@@ -99,3 +207,3 @@ /** | ||
export function suspended(thunk) { | ||
return new Implementation(EffectTag.Suspended, thunk); | ||
return new ISuspended(thunk); | ||
} | ||
@@ -146,3 +254,3 @@ /** | ||
export function async(op) { | ||
return new Implementation(EffectTag.Async, op); | ||
return new IAsync(op); | ||
} | ||
@@ -164,3 +272,3 @@ /** | ||
export function interruptibleRegion(inner, flag) { | ||
return new Implementation(EffectTag.InterruptibleRegion, flag, inner); | ||
return new IInterruptibleRegion(inner, flag); | ||
} | ||
@@ -173,5 +281,5 @@ /** | ||
function chain_(inner, bind) { | ||
return inner._tag === EffectTag.Pure | ||
? bind(inner.f0) | ||
: new Implementation(EffectTag.Chain, inner, bind); | ||
return (inner.tag() === IPureTag | ||
? bind(inner.a) | ||
: new IChain(inner, bind)); | ||
} | ||
@@ -195,3 +303,3 @@ export function chainOption(onEmpty) { | ||
export function encaseEither(e) { | ||
return new Implementation(EffectTag.PureEither, e); | ||
return new IPureEither(e); | ||
} | ||
@@ -204,3 +312,3 @@ /** | ||
export function encaseOption(o, onError) { | ||
return new Implementation(EffectTag.PureOption, o, onError); | ||
return new IPureOption(o, onError); | ||
} | ||
@@ -218,7 +326,7 @@ /** | ||
*/ | ||
export const accessInterruptible = new Implementation(EffectTag.AccessInterruptible, F.identity); | ||
export const accessInterruptible = new IAccessInterruptible(F.identity); | ||
/** | ||
* Get the runtime of the current fiber | ||
*/ | ||
export const accessRuntime = new Implementation(EffectTag.AccessRuntime, F.identity); | ||
export const accessRuntime = new IAccessRuntime(F.identity); | ||
/** | ||
@@ -232,3 +340,3 @@ * Access the runtime then provide it to the provided function | ||
export function accessEnvironment() { | ||
return new Implementation(EffectTag.AccessEnv); | ||
return new IAccessEnv(); | ||
} | ||
@@ -257,3 +365,3 @@ export function accessM(f) { | ||
} | ||
const provideR = (f) => (ma) => accessM((r2) => new Implementation(EffectTag.ProvideEnv, ma, f(r2))); | ||
const provideR = (f) => (ma) => accessM((r2) => new IProvideEnv(ma, f(r2))); | ||
/** | ||
@@ -265,5 +373,5 @@ * Map the value produced by an IO | ||
function map_(base, f) { | ||
return base._tag === EffectTag.Pure | ||
? new Implementation(EffectTag.Pure, f(base.f0)) | ||
: new Implementation(EffectTag.Map, base, f); | ||
return (base.tag() === IPureTag | ||
? new IPure(f(base.a)) | ||
: new IMap(base, f)); | ||
} | ||
@@ -674,8 +782,8 @@ /** | ||
export function makeFiber(init, name) { | ||
return accessM((r) => chain_(accessRuntime, (runtime) => sync(() => { | ||
const driver = new DriverImpl(runtime); | ||
return access((r) => { | ||
const driver = new DriverImpl(); | ||
const fiber = new FiberImpl(driver, name); | ||
driver.start(provide(r)(init)); | ||
return fiber; | ||
}))); | ||
}); | ||
} | ||
@@ -928,3 +1036,3 @@ /** | ||
} | ||
const foldExit_ = (inner, failure, success) => new Implementation(EffectTag.Collapse, inner, failure, success); | ||
const foldExit_ = (inner, failure, success) => new ICollapse(inner, failure, success); | ||
const mapLeft_ = (io, f) => chainError_(io, F.flow(f, raiseError)); | ||
@@ -931,0 +1039,0 @@ const alt_ = chainError_; |
@@ -19,3 +19,2 @@ export declare enum EffectTag { | ||
export interface Effect<S, R, E, A> { | ||
_tag: EffectTag; | ||
_TAG: () => "Effect"; | ||
@@ -22,0 +21,0 @@ _E: () => E; |
import { either as E, function as F } from "fp-ts"; | ||
import { Cause, Exit } from "./original/exit"; | ||
import { Runtime } from "./original/runtime"; | ||
import * as T from "./effect"; | ||
@@ -8,22 +7,13 @@ import { DoublyLinkedList } from "./listc"; | ||
export declare type FrameType = Frame | FoldFrame | RegionFrameType | MapFrame; | ||
interface Frame { | ||
readonly _tag: "frame"; | ||
readonly prev: FrameType | undefined; | ||
export declare const FrameTag: "Frame"; | ||
export declare class Frame implements Frame { | ||
readonly apply: (u: unknown) => T.Instructions; | ||
} | ||
declare class Frame implements Frame { | ||
readonly apply: (u: unknown) => T.Instructions; | ||
readonly prev: FrameType | undefined; | ||
constructor(apply: (u: unknown) => T.Instructions, prev: FrameType | undefined); | ||
readonly _tag: "frame"; | ||
tag(): "Frame"; | ||
} | ||
interface FoldFrame { | ||
readonly _tag: "fold-frame"; | ||
readonly prev: FrameType | undefined; | ||
export declare const FoldFrameTag: "FoldFrame"; | ||
export declare class FoldFrame implements FoldFrame { | ||
readonly apply: (u: unknown) => T.Instructions; | ||
readonly recover: (cause: Cause<unknown>) => T.Instructions; | ||
} | ||
declare class FoldFrame implements FoldFrame { | ||
readonly apply: (u: unknown) => T.Instructions; | ||
readonly recover: (cause: Cause<unknown>) => T.Instructions; | ||
readonly prev: FrameType | undefined; | ||
@@ -35,20 +25,19 @@ constructor( | ||
); | ||
readonly _tag: "fold-frame"; | ||
tag(): "FoldFrame"; | ||
} | ||
interface MapFrame { | ||
readonly _tag: "map-frame"; | ||
readonly prev: FrameType | undefined; | ||
export declare const MapFrameTag: "MapFrame"; | ||
export declare class MapFrame implements MapFrame { | ||
readonly apply: (u: unknown) => unknown; | ||
} | ||
declare class MapFrame implements MapFrame { | ||
readonly apply: (u: unknown) => unknown; | ||
readonly prev: FrameType | undefined; | ||
constructor(apply: (u: unknown) => unknown, prev: FrameType | undefined); | ||
readonly _tag: "map-frame"; | ||
tag(): "MapFrame"; | ||
} | ||
interface InterruptFrame { | ||
readonly _tag: "interrupt-frame"; | ||
export declare const InterruptFrameTag: "InterruptFrame"; | ||
export declare class InterruptFrame { | ||
readonly interruptStatus: boolean[]; | ||
readonly prev: FrameType | undefined; | ||
readonly apply: (u: unknown) => T.Instructions; | ||
readonly exitRegion: () => void; | ||
constructor(interruptStatus: boolean[], prev: FrameType | undefined); | ||
apply(u: unknown): T.IPure<unknown>; | ||
exitRegion(): void; | ||
tag(): "InterruptFrame"; | ||
} | ||
@@ -62,6 +51,4 @@ export interface Driver<E, A> { | ||
export declare class DriverImpl<E, A> implements Driver<E, A> { | ||
readonly runtime: Runtime; | ||
completed: Exit<E, A> | null; | ||
listeners: F.FunctionN<[Exit<E, A>], void>[] | undefined; | ||
started: boolean; | ||
interrupted: boolean; | ||
@@ -72,3 +59,2 @@ currentFrame: FrameType | undefined; | ||
envStack: DoublyLinkedList<any>; | ||
constructor(runtime?: Runtime); | ||
set(a: Exit<E, A>): void; | ||
@@ -87,2 +73,125 @@ isComplete(): boolean; | ||
contextSwitch(op: T.AsyncFn<unknown, unknown>): void; | ||
IAccessEnv( | ||
_: T.IAccessEnv<any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
IProvideEnv(_: T.IProvideEnv<any, any, any, any>): any; | ||
IPure( | ||
_: T.IPure<A> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
IPureOption( | ||
_: T.IPureOption<any, any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
IPureEither( | ||
_: T.IPureEither<any, any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
IRaised( | ||
_: T.IRaised<any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
ICompleted( | ||
_: T.ICompleted<any, any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
ISuspended(_: T.ISuspended<any, any, any, any>): T.Effect<any, any, any, any>; | ||
IAsync(_: T.IAsync<any, any>): undefined; | ||
IChain(_: T.IChain<any, any, any, any, any, any, any, any>): any; | ||
IMap(_: T.IMap<any, any, any, any, any>): any; | ||
ICollapse(_: T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any>): any; | ||
IInterruptibleRegion(_: T.IInterruptibleRegion<any, any, any, any>): any; | ||
IAccessRuntime(_: T.IAccessRuntime<any>): T.IPure<any>; | ||
IAccessInterruptible(_: T.IAccessInterruptible<any>): T.IPure<any>; | ||
loop(go: T.Instructions): void; | ||
@@ -92,2 +201,1 @@ start(run: T.AsyncRE<{}, E, A>): void; | ||
} | ||
export {}; |
@@ -13,3 +13,2 @@ "use strict"; | ||
exports.__esModule = true; | ||
var fp_ts_1 = require("fp-ts"); | ||
var exit_1 = require("./original/exit"); | ||
@@ -19,2 +18,3 @@ var runtime_1 = require("./original/runtime"); | ||
var listc_1 = require("./listc"); | ||
exports.FrameTag = "Frame"; | ||
var Frame = /** @class */ (function () { | ||
@@ -24,6 +24,10 @@ function Frame(apply, prev) { | ||
this.prev = prev; | ||
this._tag = "frame"; | ||
} | ||
Frame.prototype.tag = function () { | ||
return exports.FrameTag; | ||
}; | ||
return Frame; | ||
}()); | ||
exports.Frame = Frame; | ||
exports.FoldFrameTag = "FoldFrame"; | ||
var FoldFrame = /** @class */ (function () { | ||
@@ -34,6 +38,10 @@ function FoldFrame(apply, recover, prev) { | ||
this.prev = prev; | ||
this._tag = "fold-frame"; | ||
} | ||
FoldFrame.prototype.tag = function () { | ||
return exports.FoldFrameTag; | ||
}; | ||
return FoldFrame; | ||
}()); | ||
exports.FoldFrame = FoldFrame; | ||
exports.MapFrameTag = "MapFrame"; | ||
var MapFrame = /** @class */ (function () { | ||
@@ -43,23 +51,31 @@ function MapFrame(apply, prev) { | ||
this.prev = prev; | ||
this._tag = "map-frame"; | ||
} | ||
MapFrame.prototype.tag = function () { | ||
return exports.MapFrameTag; | ||
}; | ||
return MapFrame; | ||
}()); | ||
var makeInterruptFrame = function (interruptStatus, prev) { return ({ | ||
prev: prev, | ||
_tag: "interrupt-frame", | ||
apply: function (u) { | ||
interruptStatus.pop(); | ||
return T.Implementation.fromEffect(T.pure(u)); | ||
}, | ||
exitRegion: function () { | ||
interruptStatus.pop(); | ||
exports.MapFrame = MapFrame; | ||
exports.InterruptFrameTag = "InterruptFrame"; | ||
var InterruptFrame = /** @class */ (function () { | ||
function InterruptFrame(interruptStatus, prev) { | ||
this.interruptStatus = interruptStatus; | ||
this.prev = prev; | ||
} | ||
}); }; | ||
InterruptFrame.prototype.apply = function (u) { | ||
this.interruptStatus.pop(); | ||
return new T.IPure(u); | ||
}; | ||
InterruptFrame.prototype.exitRegion = function () { | ||
this.interruptStatus.pop(); | ||
}; | ||
InterruptFrame.prototype.tag = function () { | ||
return exports.InterruptFrameTag; | ||
}; | ||
return InterruptFrame; | ||
}()); | ||
exports.InterruptFrame = InterruptFrame; | ||
var DriverImpl = /** @class */ (function () { | ||
function DriverImpl(runtime) { | ||
if (runtime === void 0) { runtime = runtime_1.defaultRuntime; } | ||
this.runtime = runtime; | ||
function DriverImpl() { | ||
this.completed = null; | ||
this.started = false; | ||
this.interrupted = false; | ||
@@ -120,7 +136,7 @@ this.currentFrame = undefined; | ||
while (frame) { | ||
if (frame._tag === "fold-frame" && (e._tag !== "Interrupt" || !this.isInterruptible())) { | ||
if (frame.tag() === exports.FoldFrameTag && (e._tag !== "Interrupt" || !this.isInterruptible())) { | ||
return frame.recover(e); | ||
} | ||
// We need to make sure we leave an interrupt region or environment provision region while unwinding on errors | ||
if (frame._tag === "interrupt-frame") { | ||
if (frame.tag() === exports.InterruptFrameTag) { | ||
frame.exitRegion(); | ||
@@ -145,3 +161,3 @@ } | ||
DriverImpl.prototype.resumeInterrupt = function (err, others) { | ||
this.runtime.dispatch(this.dispatchResumeInterrupt.bind(this), { err: err, others: others }); | ||
runtime_1.defaultRuntime.dispatch(this.dispatchResumeInterrupt.bind(this), { err: err, others: others }); | ||
}; | ||
@@ -153,13 +169,12 @@ DriverImpl.prototype.next = function (value) { | ||
if (frame) { | ||
switch (frame._tag) { | ||
case "map-frame": { | ||
if (this.currentFrame === undefined) { | ||
this.complete(exit_1.done(frame.apply(value))); | ||
return; | ||
} | ||
return new T.Implementation(T.EffectTag.Pure, frame.apply(value)); | ||
if (frame.tag() === exports.MapFrameTag) { | ||
if (this.currentFrame === undefined) { | ||
this.complete(exit_1.done(frame.apply(value))); | ||
return; | ||
} | ||
default: | ||
return frame.apply(value); | ||
return new T.IPure(frame.apply(value)); | ||
} | ||
else { | ||
return frame.apply(value); | ||
} | ||
} | ||
@@ -170,20 +185,20 @@ this.complete(exit_1.done(value)); | ||
DriverImpl.prototype.foldResume = function (status) { | ||
var _this = this; | ||
fp_ts_1.either.fold(function (cause) { | ||
var go = _this.handle(exit_1.raise(cause)); | ||
if (status._tag === "Right") { | ||
var go = this.next(status.right); | ||
if (go) { | ||
/* eslint-disable-next-line */ | ||
_this.loop(go); | ||
this.loop(go); | ||
} | ||
}, function (value) { | ||
var go = _this.next(value); | ||
} | ||
else { | ||
var go = this.handle(exit_1.raise(status.left)); | ||
if (go) { | ||
/* eslint-disable-next-line */ | ||
_this.loop(go); | ||
this.loop(go); | ||
} | ||
})(status); | ||
} | ||
}; | ||
DriverImpl.prototype.resume = function (status) { | ||
this.cancelAsync = undefined; | ||
this.runtime.dispatch(this.foldResume.bind(this), status); | ||
runtime_1.defaultRuntime.dispatch(this.foldResume.bind(this), status); | ||
}; | ||
@@ -207,104 +222,98 @@ DriverImpl.prototype.contextSwitch = function (op) { | ||
}; | ||
DriverImpl.prototype.IAccessEnv = function (_) { | ||
var env = !this.envStack.empty() ? this.envStack.tail.value : {}; | ||
return this.next(env); | ||
}; | ||
DriverImpl.prototype.IProvideEnv = function (_) { | ||
var _this = this; | ||
this.envStack.append(_.r); | ||
return T.effect.foldExit(_.e, function (e) { | ||
return T.effect.chain(T.sync(function () { | ||
_this.envStack.deleteTail(); | ||
return {}; | ||
}), function (_) { return T.raised(e); }); | ||
}, function (r) { | ||
return T.sync(function () { | ||
_this.envStack.deleteTail(); | ||
return r; | ||
}); | ||
}); | ||
}; | ||
DriverImpl.prototype.IPure = function (_) { | ||
return this.next(_.a); | ||
}; | ||
DriverImpl.prototype.IPureOption = function (_) { | ||
if (_.a._tag === "Some") { | ||
return this.next(_.a.value); | ||
} | ||
else { | ||
return this.handle(exit_1.raise(_.onEmpty())); | ||
} | ||
}; | ||
DriverImpl.prototype.IPureEither = function (_) { | ||
if (_.a._tag === "Right") { | ||
return this.next(_.a.right); | ||
} | ||
else { | ||
return this.handle(exit_1.raise(_.a.left)); | ||
} | ||
}; | ||
DriverImpl.prototype.IRaised = function (_) { | ||
if (_.e._tag === "Interrupt") { | ||
this.interrupted = true; | ||
} | ||
return this.handle(_.e); | ||
}; | ||
DriverImpl.prototype.ICompleted = function (_) { | ||
if (_.e._tag === "Done") { | ||
return this.next(_.e.value); | ||
} | ||
else { | ||
return this.handle(_.e); | ||
} | ||
}; | ||
DriverImpl.prototype.ISuspended = function (_) { | ||
return _.e(); | ||
}; | ||
DriverImpl.prototype.IAsync = function (_) { | ||
this.contextSwitch(_.e); | ||
return undefined; | ||
}; | ||
DriverImpl.prototype.IChain = function (_) { | ||
this.currentFrame = new Frame(_.f, this.currentFrame); | ||
return _.e; | ||
}; | ||
DriverImpl.prototype.IMap = function (_) { | ||
this.currentFrame = new MapFrame(_.f, this.currentFrame); | ||
return _.e; | ||
}; | ||
DriverImpl.prototype.ICollapse = function (_) { | ||
this.currentFrame = new FoldFrame(_.success, _.failure, this.currentFrame); | ||
return _.inner; | ||
}; | ||
DriverImpl.prototype.IInterruptibleRegion = function (_) { | ||
if (this.interruptRegionStack === undefined) { | ||
this.interruptRegionStack = [_.int]; | ||
} | ||
else { | ||
this.interruptRegionStack.push(_.int); | ||
} | ||
this.currentFrame = new InterruptFrame(this.interruptRegionStack, this.currentFrame); | ||
return _.e; | ||
}; | ||
DriverImpl.prototype.IAccessRuntime = function (_) { | ||
return new T.IPure(_.f(runtime_1.defaultRuntime)); | ||
}; | ||
DriverImpl.prototype.IAccessInterruptible = function (_) { | ||
return new T.IPure(_.f(this.isInterruptible())); | ||
}; | ||
// tslint:disable-next-line: cyclomatic-complexity | ||
DriverImpl.prototype.loop = function (go) { | ||
var _this = this; | ||
var current = go; | ||
while (current && (!this.interrupted || !this.isInterruptible())) { | ||
try { | ||
switch (current._tag) { | ||
case T.EffectTag.AccessEnv: | ||
var env = !this.envStack.empty() ? this.envStack.tail.value : {}; | ||
current = this.next(env); | ||
break; | ||
case T.EffectTag.ProvideEnv: | ||
this.envStack.append(current.f1); | ||
current = T.Implementation.fromEffect(T.effect.foldExit(current.f0, function (e) { | ||
return T.effect.chain(T.sync(function () { | ||
_this.envStack.deleteTail(); | ||
return {}; | ||
}), function (_) { return T.raised(e); }); | ||
}, function (r) { | ||
return T.sync(function () { | ||
_this.envStack.deleteTail(); | ||
return r; | ||
}); | ||
})); | ||
break; | ||
case T.EffectTag.Pure: | ||
current = this.next(current.f0); | ||
break; | ||
case T.EffectTag.PureOption: { | ||
if (fp_ts_1.option.isSome(current.f0)) { | ||
current = this.next(current.f0.value); | ||
} | ||
else { | ||
current = this.handle(exit_1.raise(current.f1())); | ||
} | ||
break; | ||
} | ||
case T.EffectTag.PureEither: { | ||
if (fp_ts_1.either.isRight(current.f0)) { | ||
current = this.next(current.f0.right); | ||
} | ||
else { | ||
current = this.handle(exit_1.raise(current.f0.left)); | ||
} | ||
break; | ||
} | ||
case T.EffectTag.Raised: | ||
if (current.f0._tag === "Interrupt") { | ||
this.interrupted = true; | ||
} | ||
current = this.handle(current.f0); | ||
break; | ||
case T.EffectTag.Completed: | ||
if (current.f0._tag === "Done") { | ||
current = this.next(current.f0.value); | ||
} | ||
else { | ||
current = this.handle(current.f0); | ||
} | ||
break; | ||
case T.EffectTag.Suspended: | ||
current = current.f0(); | ||
break; | ||
case T.EffectTag.Async: | ||
this.contextSwitch(current.f0); | ||
current = undefined; | ||
break; | ||
case T.EffectTag.Chain: | ||
this.currentFrame = new Frame(current.f1, this.currentFrame); | ||
current = current.f0; | ||
break; | ||
case T.EffectTag.Map: | ||
this.currentFrame = new MapFrame(current.f1, this.currentFrame); | ||
current = current.f0; | ||
break; | ||
case T.EffectTag.Collapse: | ||
this.currentFrame = new FoldFrame(current.f2, current.f1, this.currentFrame); | ||
current = current.f0; | ||
break; | ||
case T.EffectTag.InterruptibleRegion: | ||
if (this.interruptRegionStack === undefined) { | ||
this.interruptRegionStack = [current.f0]; | ||
} | ||
else { | ||
this.interruptRegionStack.push(current.f0); | ||
} | ||
this.currentFrame = makeInterruptFrame(this.interruptRegionStack, this.currentFrame); | ||
current = current.f1; | ||
break; | ||
case T.EffectTag.AccessRuntime: | ||
current = T.Implementation.fromEffect(T.pure(current.f0(this.runtime))); | ||
break; | ||
case T.EffectTag.AccessInterruptible: | ||
current = T.Implementation.fromEffect(T.pure(current.f0(this.isInterruptible()))); | ||
break; | ||
default: | ||
/* istanbul ignore next */ | ||
throw new Error("Die: Unrecognized current type " + current); | ||
} | ||
current = this[current.tag()](current); | ||
} | ||
catch (e) { | ||
current = T.Implementation.fromEffect(T.raiseAbort(e)); | ||
current = new T.IRaised({ _tag: "Abort", abortedWith: e }); | ||
} | ||
@@ -318,8 +327,3 @@ } | ||
DriverImpl.prototype.start = function (run) { | ||
if (this.started) { | ||
/* istanbul ignore next */ | ||
throw new Error("Bug: Runtime may not be started multiple times"); | ||
} | ||
this.started = true; | ||
this.runtime.dispatch(this.loop.bind(this), run); | ||
runtime_1.defaultRuntime.dispatch(this.loop.bind(this), run); | ||
}; | ||
@@ -326,0 +330,0 @@ DriverImpl.prototype.interrupt = function () { |
import { either as E, function as F } from "fp-ts"; | ||
import { Cause, Exit } from "./original/exit"; | ||
import { Runtime } from "./original/runtime"; | ||
import * as T from "./effect"; | ||
import * as L from "./list"; | ||
export declare type RegionFrameType = InterruptFrame; | ||
export declare type FrameType = Frame | FoldFrame | RegionFrameType | MapFrame; | ||
interface Frame { | ||
readonly _tag: "frame"; | ||
readonly prev: FrameType | undefined; | ||
readonly apply: (u: unknown) => T.Instructions; | ||
} | ||
declare class Frame implements Frame { | ||
readonly apply: (u: unknown) => T.Instructions; | ||
readonly prev: FrameType | undefined; | ||
constructor(apply: (u: unknown) => T.Instructions, prev: FrameType | undefined); | ||
readonly _tag: "frame"; | ||
} | ||
interface FoldFrame { | ||
readonly _tag: "fold-frame"; | ||
readonly prev: FrameType | undefined; | ||
readonly apply: (u: unknown) => T.Instructions; | ||
readonly recover: (cause: Cause<unknown>) => T.Instructions; | ||
} | ||
declare class FoldFrame implements FoldFrame { | ||
readonly apply: (u: unknown) => T.Instructions; | ||
readonly recover: (cause: Cause<unknown>) => T.Instructions; | ||
readonly prev: FrameType | undefined; | ||
constructor( | ||
apply: (u: unknown) => T.Instructions, | ||
recover: (cause: Cause<unknown>) => T.Instructions, | ||
prev: FrameType | undefined | ||
); | ||
readonly _tag: "fold-frame"; | ||
} | ||
interface MapFrame { | ||
readonly _tag: "map-frame"; | ||
readonly prev: FrameType | undefined; | ||
readonly apply: (u: unknown) => unknown; | ||
} | ||
declare class MapFrame implements MapFrame { | ||
readonly apply: (u: unknown) => unknown; | ||
readonly prev: FrameType | undefined; | ||
constructor(apply: (u: unknown) => unknown, prev: FrameType | undefined); | ||
readonly _tag: "map-frame"; | ||
} | ||
interface InterruptFrame { | ||
readonly _tag: "interrupt-frame"; | ||
readonly prev: FrameType | undefined; | ||
readonly apply: (u: unknown) => T.Instructions; | ||
readonly exitRegion: () => void; | ||
} | ||
import { DoublyLinkedList } from "./listc"; | ||
import { FrameType } from "./driver"; | ||
export interface DriverSync<E, A> { | ||
@@ -57,11 +10,8 @@ start(run: T.SyncE<E, A>): E.Either<Error, Exit<E, A>>; | ||
export declare class DriverSyncImpl<E, A> implements DriverSync<E, A> { | ||
readonly runtime: Runtime; | ||
completed: Exit<E, A> | null; | ||
listeners: F.FunctionN<[Exit<E, A>], void>[] | undefined; | ||
started: boolean; | ||
interrupted: boolean; | ||
currentFrame: FrameType | undefined; | ||
interruptRegionStack: boolean[] | undefined; | ||
envStack: L.List<any>; | ||
constructor(runtime?: Runtime); | ||
envStack: DoublyLinkedList<any>; | ||
set(a: Exit<E, A>): void; | ||
@@ -77,2 +27,125 @@ isComplete(): boolean; | ||
resume(status: E.Either<unknown, unknown>): void; | ||
IAccessEnv( | ||
_: T.IAccessEnv<any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
IProvideEnv(_: T.IProvideEnv<any, any, any, any>): any; | ||
IPure( | ||
_: T.IPure<A> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
IPureOption( | ||
_: T.IPureOption<any, any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
IPureEither( | ||
_: T.IPureEither<any, any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
IRaised( | ||
_: T.IRaised<any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
ICompleted( | ||
_: T.ICompleted<any, any> | ||
): | ||
| T.IPure<any> | ||
| T.IPureOption<any, any> | ||
| T.IPureEither<any, any> | ||
| T.IRaised<any> | ||
| T.ICompleted<any, any> | ||
| T.ISuspended<any, any, any, any> | ||
| T.IAsync<any, any> | ||
| T.IChain<any, any, any, any, any, any, any, any> | ||
| T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| T.IInterruptibleRegion<any, any, any, any> | ||
| T.IAccessInterruptible<any> | ||
| T.IAccessRuntime<any> | ||
| T.IAccessEnv<any> | ||
| T.IProvideEnv<any, any, any, any> | ||
| T.IMap<any, any, any, any, any> | ||
| undefined; | ||
ISuspended(_: T.ISuspended<any, any, any, any>): T.Effect<any, any, any, any>; | ||
IAsync(_: T.IAsync<any, any>): undefined; | ||
IChain(_: T.IChain<any, any, any, any, any, any, any, any>): any; | ||
IMap(_: T.IMap<any, any, any, any, any>): any; | ||
ICollapse(_: T.ICollapse<any, any, any, any, any, any, any, any, any, any, any, any>): any; | ||
IInterruptibleRegion(_: T.IInterruptibleRegion<any, any, any, any>): any; | ||
IAccessRuntime(_: T.IAccessRuntime<any>): T.IPure<any>; | ||
IAccessInterruptible(_: T.IAccessInterruptible<any>): T.IPure<any>; | ||
loop(go: T.Instructions): void; | ||
@@ -82,2 +155,1 @@ start(run: T.SyncRE<{}, E, A>): E.Either<Error, Exit<E, A>>; | ||
} | ||
export {}; |
@@ -17,48 +17,10 @@ "use strict"; | ||
var T = __importStar(require("./effect")); | ||
var L = __importStar(require("./list")); | ||
var Frame = /** @class */ (function () { | ||
function Frame(apply, prev) { | ||
this.apply = apply; | ||
this.prev = prev; | ||
this._tag = "frame"; | ||
} | ||
return Frame; | ||
}()); | ||
var FoldFrame = /** @class */ (function () { | ||
function FoldFrame(apply, recover, prev) { | ||
this.apply = apply; | ||
this.recover = recover; | ||
this.prev = prev; | ||
this._tag = "fold-frame"; | ||
} | ||
return FoldFrame; | ||
}()); | ||
var MapFrame = /** @class */ (function () { | ||
function MapFrame(apply, prev) { | ||
this.apply = apply; | ||
this.prev = prev; | ||
this._tag = "map-frame"; | ||
} | ||
return MapFrame; | ||
}()); | ||
var makeInterruptFrame = function (interruptStatus, prev) { return ({ | ||
prev: prev, | ||
_tag: "interrupt-frame", | ||
apply: function (u) { | ||
interruptStatus.pop(); | ||
return T.Implementation.fromEffect(T.pure(u)); | ||
}, | ||
exitRegion: function () { | ||
interruptStatus.pop(); | ||
} | ||
}); }; | ||
var listc_1 = require("./listc"); | ||
var driver_1 = require("./driver"); | ||
var DriverSyncImpl = /** @class */ (function () { | ||
function DriverSyncImpl(runtime) { | ||
if (runtime === void 0) { runtime = runtime_1.defaultRuntime; } | ||
this.runtime = runtime; | ||
function DriverSyncImpl() { | ||
this.completed = null; | ||
this.started = false; | ||
this.interrupted = false; | ||
this.currentFrame = undefined; | ||
this.envStack = L.empty(); | ||
this.envStack = new listc_1.DoublyLinkedList(); | ||
} | ||
@@ -94,7 +56,7 @@ DriverSyncImpl.prototype.set = function (a) { | ||
while (frame) { | ||
if (frame._tag === "fold-frame" && (e._tag !== "Interrupt" || !this.isInterruptible())) { | ||
if (frame.tag() === driver_1.FoldFrameTag && (e._tag !== "Interrupt" || !this.isInterruptible())) { | ||
return frame.recover(e); | ||
} | ||
// We need to make sure we leave an interrupt region or environment provision region while unwinding on errors | ||
if (frame._tag === "interrupt-frame") { | ||
if (frame.tag() === driver_1.InterruptFrameTag) { | ||
frame.exitRegion(); | ||
@@ -124,13 +86,12 @@ } | ||
if (frame) { | ||
switch (frame._tag) { | ||
case "map-frame": { | ||
if (this.currentFrame === undefined) { | ||
this.complete(exit_1.done(frame.apply(value))); | ||
return; | ||
} | ||
return new T.Implementation(T.EffectTag.Pure, frame.apply(value)); | ||
if (frame.tag() === driver_1.MapFrameTag) { | ||
if (this.currentFrame === undefined) { | ||
this.complete(exit_1.done(frame.apply(value))); | ||
return; | ||
} | ||
default: | ||
return frame.apply(value); | ||
return new T.IPure(frame.apply(value)); | ||
} | ||
else { | ||
return frame.apply(value); | ||
} | ||
} | ||
@@ -141,16 +102,16 @@ this.complete(exit_1.done(value)); | ||
DriverSyncImpl.prototype.foldResume = function (status) { | ||
var _this = this; | ||
fp_ts_1.either.fold(function (cause) { | ||
var go = _this.handle(exit_1.raise(cause)); | ||
if (status._tag === "Right") { | ||
var go = this.next(status.right); | ||
if (go) { | ||
/* eslint-disable-next-line */ | ||
_this.loop(go); | ||
this.loop(go); | ||
} | ||
}, function (value) { | ||
var go = _this.next(value); | ||
} | ||
else { | ||
var go = this.handle(exit_1.raise(status.left)); | ||
if (go) { | ||
/* eslint-disable-next-line */ | ||
_this.loop(go); | ||
this.loop(go); | ||
} | ||
})(status); | ||
} | ||
}; | ||
@@ -160,103 +121,97 @@ DriverSyncImpl.prototype.resume = function (status) { | ||
}; | ||
DriverSyncImpl.prototype.IAccessEnv = function (_) { | ||
var env = !this.envStack.empty() ? this.envStack.tail.value : {}; | ||
return this.next(env); | ||
}; | ||
DriverSyncImpl.prototype.IProvideEnv = function (_) { | ||
var _this = this; | ||
this.envStack.append(_.r); | ||
return T.effect.foldExit(_.e, function (e) { | ||
return T.effect.chain(T.sync(function () { | ||
_this.envStack.deleteTail(); | ||
return {}; | ||
}), function (_) { return T.raised(e); }); | ||
}, function (r) { | ||
return T.sync(function () { | ||
_this.envStack.deleteTail(); | ||
return r; | ||
}); | ||
}); | ||
}; | ||
DriverSyncImpl.prototype.IPure = function (_) { | ||
return this.next(_.a); | ||
}; | ||
DriverSyncImpl.prototype.IPureOption = function (_) { | ||
if (_.a._tag === "Some") { | ||
return this.next(_.a.value); | ||
} | ||
else { | ||
return this.handle(exit_1.raise(_.onEmpty())); | ||
} | ||
}; | ||
DriverSyncImpl.prototype.IPureEither = function (_) { | ||
if (_.a._tag === "Right") { | ||
return this.next(_.a.right); | ||
} | ||
else { | ||
return this.handle(exit_1.raise(_.a.left)); | ||
} | ||
}; | ||
DriverSyncImpl.prototype.IRaised = function (_) { | ||
if (_.e._tag === "Interrupt") { | ||
this.interrupted = true; | ||
} | ||
return this.handle(_.e); | ||
}; | ||
DriverSyncImpl.prototype.ICompleted = function (_) { | ||
if (_.e._tag === "Done") { | ||
return this.next(_.e.value); | ||
} | ||
else { | ||
return this.handle(_.e); | ||
} | ||
}; | ||
DriverSyncImpl.prototype.ISuspended = function (_) { | ||
return _.e(); | ||
}; | ||
DriverSyncImpl.prototype.IAsync = function (_) { | ||
return undefined; | ||
}; | ||
DriverSyncImpl.prototype.IChain = function (_) { | ||
this.currentFrame = new driver_1.Frame(_.f, this.currentFrame); | ||
return _.e; | ||
}; | ||
DriverSyncImpl.prototype.IMap = function (_) { | ||
this.currentFrame = new driver_1.MapFrame(_.f, this.currentFrame); | ||
return _.e; | ||
}; | ||
DriverSyncImpl.prototype.ICollapse = function (_) { | ||
this.currentFrame = new driver_1.FoldFrame(_.success, _.failure, this.currentFrame); | ||
return _.inner; | ||
}; | ||
DriverSyncImpl.prototype.IInterruptibleRegion = function (_) { | ||
if (this.interruptRegionStack === undefined) { | ||
this.interruptRegionStack = [_.int]; | ||
} | ||
else { | ||
this.interruptRegionStack.push(_.int); | ||
} | ||
this.currentFrame = new driver_1.InterruptFrame(this.interruptRegionStack, this.currentFrame); | ||
return _.e; | ||
}; | ||
DriverSyncImpl.prototype.IAccessRuntime = function (_) { | ||
return new T.IPure(_.f(runtime_1.defaultRuntime)); | ||
}; | ||
DriverSyncImpl.prototype.IAccessInterruptible = function (_) { | ||
return new T.IPure(_.f(this.isInterruptible())); | ||
}; | ||
// tslint:disable-next-line: cyclomatic-complexity | ||
DriverSyncImpl.prototype.loop = function (go) { | ||
var _this = this; | ||
var current = go; | ||
while (current && (!this.interrupted || !this.isInterruptible())) { | ||
try { | ||
switch (current._tag) { | ||
case T.EffectTag.AccessEnv: | ||
var env = L.isNotEmpty(this.envStack) ? L.lastUnsafe(this.envStack) : {}; | ||
current = this.next(env); | ||
break; | ||
case T.EffectTag.ProvideEnv: | ||
L.push(this.envStack, current.f1); | ||
current = T.Implementation.fromEffect(T.effect.foldExit(current.f0, function (e) { | ||
return T.effect.chain(T.sync(function () { | ||
L.popLastUnsafe(_this.envStack); | ||
return {}; | ||
}), function (_) { return T.raised(e); }); | ||
}, function (r) { | ||
return T.sync(function () { | ||
L.popLastUnsafe(_this.envStack); | ||
return r; | ||
}); | ||
})); | ||
break; | ||
case T.EffectTag.Pure: | ||
current = this.next(current.f0); | ||
break; | ||
case T.EffectTag.PureOption: { | ||
if (fp_ts_1.option.isSome(current.f0)) { | ||
current = this.next(current.f0.value); | ||
} | ||
else { | ||
current = this.handle(exit_1.raise(current.f1())); | ||
} | ||
break; | ||
} | ||
case T.EffectTag.PureEither: { | ||
if (fp_ts_1.either.isRight(current.f0)) { | ||
current = this.next(current.f0.right); | ||
} | ||
else { | ||
current = this.handle(exit_1.raise(current.f0.left)); | ||
} | ||
break; | ||
} | ||
case T.EffectTag.Raised: | ||
if (current.f0._tag === "Interrupt") { | ||
this.interrupted = true; | ||
} | ||
current = this.handle(current.f0); | ||
break; | ||
case T.EffectTag.Completed: | ||
if (current.f0._tag === "Done") { | ||
current = this.next(current.f0.value); | ||
} | ||
else { | ||
current = this.handle(current.f0); | ||
} | ||
break; | ||
case T.EffectTag.Suspended: | ||
current = current.f0(); | ||
break; | ||
case T.EffectTag.Async: | ||
current = undefined; | ||
break; | ||
case T.EffectTag.Chain: | ||
this.currentFrame = new Frame(current.f1, this.currentFrame); | ||
current = current.f0; | ||
break; | ||
case T.EffectTag.Map: | ||
this.currentFrame = new MapFrame(current.f1, this.currentFrame); | ||
current = current.f0; | ||
break; | ||
case T.EffectTag.Collapse: | ||
this.currentFrame = new FoldFrame(current.f2, current.f1, this.currentFrame); | ||
current = current.f0; | ||
break; | ||
case T.EffectTag.InterruptibleRegion: | ||
if (this.interruptRegionStack === undefined) { | ||
this.interruptRegionStack = [current.f0]; | ||
} | ||
else { | ||
this.interruptRegionStack.push(current.f0); | ||
} | ||
this.currentFrame = makeInterruptFrame(this.interruptRegionStack, this.currentFrame); | ||
current = current.f1; | ||
break; | ||
case T.EffectTag.AccessRuntime: | ||
current = T.Implementation.fromEffect(T.pure(current.f0(this.runtime))); | ||
break; | ||
case T.EffectTag.AccessInterruptible: | ||
current = T.Implementation.fromEffect(T.pure(current.f0(this.isInterruptible()))); | ||
break; | ||
default: | ||
/* istanbul ignore next */ | ||
throw new Error("Die: Unrecognized current type " + current); | ||
} | ||
current = this[current.tag()](current); | ||
} | ||
catch (e) { | ||
current = T.Implementation.fromEffect(T.raiseAbort(e)); | ||
current = new T.IRaised({ _tag: "Abort", abortedWith: e }); | ||
} | ||
@@ -263,0 +218,0 @@ } |
@@ -47,41 +47,47 @@ import { | ||
export declare type Instructions = | ||
| Pure | ||
| PureOption | ||
| PureEither | ||
| Raised | ||
| Completed | ||
| Suspended | ||
| IAsync | ||
| IChain | ||
| ICollapse | ||
| IInterruptibleRegion | ||
| IAccessInterruptible | ||
| IAccessRuntime | ||
| IAccessEnv | ||
| IProvideEnv | ||
| IMap; | ||
export interface Pure<A = unknown> { | ||
readonly _tag: EffectTag.Pure; | ||
readonly f0: A; | ||
| IPure<any> | ||
| IPureOption<any, any> | ||
| IPureEither<any, any> | ||
| IRaised<any> | ||
| ICompleted<any, any> | ||
| ISuspended<any, any, any, any> | ||
| IAsync<any, any> | ||
| IChain<any, any, any, any, any, any, any, any> | ||
| ICollapse<any, any, any, any, any, any, any, any, any, any, any, any> | ||
| IInterruptibleRegion<any, any, any, any> | ||
| IAccessInterruptible<any> | ||
| IAccessRuntime<any> | ||
| IAccessEnv<any> | ||
| IProvideEnv<any, any, any, any> | ||
| IMap<any, any, any, any, any>; | ||
export declare class IPure<A> { | ||
readonly a: A; | ||
constructor(a: A); | ||
tag(): "IPure"; | ||
} | ||
export interface PureOption<A = unknown, E = never> { | ||
readonly _tag: EffectTag.PureOption; | ||
readonly f0: Op.Option<A>; | ||
readonly f1: F.Lazy<E>; | ||
export declare class IPureOption<E, A> { | ||
readonly a: Op.Option<A>; | ||
readonly onEmpty: () => E; | ||
constructor(a: Op.Option<A>, onEmpty: () => E); | ||
tag(): "IPureOption"; | ||
} | ||
export interface PureEither<A = unknown, E = never> { | ||
readonly _tag: EffectTag.PureEither; | ||
readonly f0: Ei.Either<E, A>; | ||
export declare class IPureEither<E, A> { | ||
readonly a: Ei.Either<E, A>; | ||
constructor(a: Ei.Either<E, A>); | ||
tag(): "IPureEither"; | ||
} | ||
export interface Raised<E = unknown> { | ||
readonly _tag: EffectTag.Raised; | ||
readonly f0: ex.Cause<E>; | ||
export declare class IRaised<E> { | ||
readonly e: ex.Cause<E>; | ||
constructor(e: ex.Cause<E>); | ||
tag(): "IRaised"; | ||
} | ||
export interface Completed<E = unknown, A = unknown> { | ||
readonly _tag: EffectTag.Completed; | ||
readonly f0: ex.Exit<E, A>; | ||
export declare class ICompleted<E, A> { | ||
readonly e: ex.Exit<E, A>; | ||
constructor(e: ex.Exit<E, A>); | ||
tag(): "ICompleted"; | ||
} | ||
export interface Suspended { | ||
readonly _tag: EffectTag.Suspended; | ||
readonly f0: F.Lazy<Instructions>; | ||
export declare class ISuspended<S, R, E, A> { | ||
readonly e: F.Lazy<Effect<S, R, E, A>>; | ||
constructor(e: F.Lazy<Effect<S, R, E, A>>); | ||
tag(): "ISuspended"; | ||
} | ||
@@ -94,57 +100,55 @@ export declare type AsyncContFn<E, A> = F.FunctionN<[Ei.Either<E, A>], void>; | ||
export declare type AsyncFn<E, A> = F.FunctionN<[AsyncContFn<E, A>], AsyncCancelContFn>; | ||
export interface IAsync<E = unknown, A = unknown> { | ||
readonly _tag: EffectTag.Async; | ||
readonly f0: AsyncFn<E, A>; | ||
export declare class IAsync<E, A> { | ||
readonly e: AsyncFn<E, A>; | ||
constructor(e: AsyncFn<E, A>); | ||
tag(): "IAsync"; | ||
} | ||
export interface IChain<Z = unknown> { | ||
readonly _tag: EffectTag.Chain; | ||
readonly f0: Instructions; | ||
readonly f1: F.FunctionN<[Z], Instructions>; | ||
export declare class IChain<S, R, E, A, S1, R1, E1, B> { | ||
readonly e: Effect<S, R, E, A>; | ||
readonly f: (a: A) => Effect<S1, R1, E1, B>; | ||
constructor(e: Effect<S, R, E, A>, f: (a: A) => Effect<S1, R1, E1, B>); | ||
tag(): "IChain"; | ||
} | ||
export interface IMap<A = unknown, B = unknown> { | ||
readonly _tag: EffectTag.Map; | ||
readonly f0: Instructions; | ||
readonly f1: F.FunctionN<[A], B>; | ||
export declare class IMap<S, R, E, A, B> { | ||
readonly e: Effect<S, R, E, A>; | ||
readonly f: (a: A) => B; | ||
constructor(e: Effect<S, R, E, A>, f: (a: A) => B); | ||
tag(): "IMap"; | ||
} | ||
export interface ICollapse<E1 = unknown, A1 = unknown> { | ||
readonly _tag: EffectTag.Collapse; | ||
readonly f0: Instructions; | ||
readonly f1: F.FunctionN<[ex.Cause<E1>], Instructions>; | ||
readonly f2: F.FunctionN<[A1], Instructions>; | ||
export declare class ICollapse<S1, S2, S3, R, R2, R3, E1, E2, E3, A1, A2, A3> { | ||
readonly inner: Effect<S1, R, E1, A1>; | ||
readonly failure: F.FunctionN<[ex.Cause<E1>], Effect<S2, R2, E2, A2>>; | ||
readonly success: F.FunctionN<[A1], Effect<S3, R3, E3, A3>>; | ||
constructor( | ||
inner: Effect<S1, R, E1, A1>, | ||
failure: F.FunctionN<[ex.Cause<E1>], Effect<S2, R2, E2, A2>>, | ||
success: F.FunctionN<[A1], Effect<S3, R3, E3, A3>> | ||
); | ||
tag(): "ICollapse"; | ||
} | ||
export interface IInterruptibleRegion { | ||
readonly _tag: EffectTag.InterruptibleRegion; | ||
readonly f0: boolean; | ||
readonly f1: Instructions; | ||
export declare class IInterruptibleRegion<S, R, E, A> { | ||
readonly e: Effect<S, R, E, A>; | ||
readonly int: boolean; | ||
constructor(e: Effect<S, R, E, A>, int: boolean); | ||
tag(): "IInterruptibleRegion"; | ||
} | ||
export interface IAccessInterruptible<A = unknown> { | ||
readonly _tag: EffectTag.AccessInterruptible; | ||
readonly f0: F.FunctionN<[boolean], A>; | ||
export declare class IAccessInterruptible<A> { | ||
readonly f: (_: boolean) => A; | ||
constructor(f: (_: boolean) => A); | ||
tag(): "IAccessInterruptible"; | ||
} | ||
export interface IAccessRuntime<A = unknown> { | ||
readonly _tag: EffectTag.AccessRuntime; | ||
readonly f0: F.FunctionN<[Runtime], A>; | ||
export declare class IAccessRuntime<A> { | ||
readonly f: (_: Runtime) => A; | ||
constructor(f: (_: Runtime) => A); | ||
tag(): "IAccessRuntime"; | ||
} | ||
export interface IProvideEnv<R = unknown> { | ||
readonly _tag: EffectTag.ProvideEnv; | ||
readonly f0: Instructions; | ||
readonly f1: R; | ||
export declare class IProvideEnv<S, R, E, A> { | ||
readonly e: Effect<S, R, E, A>; | ||
readonly r: R; | ||
constructor(e: Effect<S, R, E, A>, r: R); | ||
tag(): "IProvideEnv"; | ||
} | ||
export interface IAccessEnv<R = unknown> { | ||
readonly _tag: EffectTag.AccessEnv; | ||
readonly f0: R; | ||
export declare class IAccessEnv<R> { | ||
tag(): "IAccessEnv"; | ||
} | ||
export declare class Implementation<S, R, E, A> implements Effect<S, R, E, A> { | ||
readonly _tag: EffectTag; | ||
readonly f0: any; | ||
readonly f1: any; | ||
readonly f2: any; | ||
static fromEffect<S, R, E, A>(eff: Effect<S, R, E, A>): Implementation<S, R, E, A>; | ||
constructor(_tag: EffectTag, f0?: any, f1?: any, f2?: any); | ||
_TAG(): "Effect"; | ||
_A(): A; | ||
_E(): E; | ||
_S(): S; | ||
_R(_: R): void; | ||
} | ||
/** | ||
@@ -151,0 +155,0 @@ * An IO has succeeded |
@@ -41,38 +41,173 @@ "use strict"; | ||
exports.URI = "matechs/Effect"; | ||
var Implementation = /** @class */ (function () { | ||
function Implementation(_tag, f0, f1, f2) { | ||
if (f0 === void 0) { f0 = undefined; } | ||
if (f1 === void 0) { f1 = undefined; } | ||
if (f2 === void 0) { f2 = undefined; } | ||
this._tag = _tag; | ||
this.f0 = f0; | ||
this.f1 = f1; | ||
this.f2 = f2; | ||
var IPureTag = "IPure"; | ||
var IPure = /** @class */ (function () { | ||
function IPure(a) { | ||
this.a = a; | ||
} | ||
Implementation.fromEffect = function (eff) { | ||
return eff; | ||
IPure.prototype.tag = function () { | ||
return IPureTag; | ||
}; | ||
/* istanbul ignore next */ | ||
Implementation.prototype._TAG = function () { | ||
return undefined; | ||
return IPure; | ||
}()); | ||
exports.IPure = IPure; | ||
var IPureOptionTag = "IPureOption"; | ||
var IPureOption = /** @class */ (function () { | ||
function IPureOption(a, onEmpty) { | ||
this.a = a; | ||
this.onEmpty = onEmpty; | ||
} | ||
IPureOption.prototype.tag = function () { | ||
return IPureOptionTag; | ||
}; | ||
/* istanbul ignore next */ | ||
Implementation.prototype._A = function () { | ||
return undefined; | ||
return IPureOption; | ||
}()); | ||
exports.IPureOption = IPureOption; | ||
var IPureEitherTag = "IPureEither"; | ||
var IPureEither = /** @class */ (function () { | ||
function IPureEither(a) { | ||
this.a = a; | ||
} | ||
IPureEither.prototype.tag = function () { | ||
return IPureEitherTag; | ||
}; | ||
/* istanbul ignore next */ | ||
Implementation.prototype._E = function () { | ||
return undefined; | ||
return IPureEither; | ||
}()); | ||
exports.IPureEither = IPureEither; | ||
var IRaisedTag = "IRaised"; | ||
var IRaised = /** @class */ (function () { | ||
function IRaised(e) { | ||
this.e = e; | ||
} | ||
IRaised.prototype.tag = function () { | ||
return IRaisedTag; | ||
}; | ||
/* istanbul ignore next */ | ||
Implementation.prototype._S = function () { | ||
return undefined; | ||
return IRaised; | ||
}()); | ||
exports.IRaised = IRaised; | ||
var ICompletedTag = "ICompleted"; | ||
var ICompleted = /** @class */ (function () { | ||
function ICompleted(e) { | ||
this.e = e; | ||
} | ||
ICompleted.prototype.tag = function () { | ||
return ICompletedTag; | ||
}; | ||
/* istanbul ignore next */ | ||
Implementation.prototype._R = function (_) { | ||
return undefined; | ||
return ICompleted; | ||
}()); | ||
exports.ICompleted = ICompleted; | ||
var ISuspendedTag = "ISuspended"; | ||
var ISuspended = /** @class */ (function () { | ||
function ISuspended(e) { | ||
this.e = e; | ||
} | ||
ISuspended.prototype.tag = function () { | ||
return ISuspendedTag; | ||
}; | ||
return Implementation; | ||
return ISuspended; | ||
}()); | ||
exports.Implementation = Implementation; | ||
exports.ISuspended = ISuspended; | ||
var IAsyncTag = "IAsync"; | ||
var IAsync = /** @class */ (function () { | ||
function IAsync(e) { | ||
this.e = e; | ||
} | ||
IAsync.prototype.tag = function () { | ||
return IAsyncTag; | ||
}; | ||
return IAsync; | ||
}()); | ||
exports.IAsync = IAsync; | ||
var IChainTag = "IChain"; | ||
var IChain = /** @class */ (function () { | ||
function IChain(e, f) { | ||
this.e = e; | ||
this.f = f; | ||
} | ||
IChain.prototype.tag = function () { | ||
return IChainTag; | ||
}; | ||
return IChain; | ||
}()); | ||
exports.IChain = IChain; | ||
var IMapTag = "IMap"; | ||
var IMap = /** @class */ (function () { | ||
function IMap(e, f) { | ||
this.e = e; | ||
this.f = f; | ||
} | ||
IMap.prototype.tag = function () { | ||
return IMapTag; | ||
}; | ||
return IMap; | ||
}()); | ||
exports.IMap = IMap; | ||
var ICollapseTag = "ICollapse"; | ||
var ICollapse = /** @class */ (function () { | ||
function ICollapse(inner, failure, success) { | ||
this.inner = inner; | ||
this.failure = failure; | ||
this.success = success; | ||
} | ||
ICollapse.prototype.tag = function () { | ||
return ICollapseTag; | ||
}; | ||
return ICollapse; | ||
}()); | ||
exports.ICollapse = ICollapse; | ||
var IInterruptibleRegionTag = "IInterruptibleRegion"; | ||
var IInterruptibleRegion = /** @class */ (function () { | ||
function IInterruptibleRegion(e, int) { | ||
this.e = e; | ||
this.int = int; | ||
} | ||
IInterruptibleRegion.prototype.tag = function () { | ||
return IInterruptibleRegionTag; | ||
}; | ||
return IInterruptibleRegion; | ||
}()); | ||
exports.IInterruptibleRegion = IInterruptibleRegion; | ||
var IAccessInterruptibleTag = "IAccessInterruptible"; | ||
var IAccessInterruptible = /** @class */ (function () { | ||
function IAccessInterruptible(f) { | ||
this.f = f; | ||
} | ||
IAccessInterruptible.prototype.tag = function () { | ||
return IAccessInterruptibleTag; | ||
}; | ||
return IAccessInterruptible; | ||
}()); | ||
exports.IAccessInterruptible = IAccessInterruptible; | ||
var IAccessRuntimeTag = "IAccessRuntime"; | ||
var IAccessRuntime = /** @class */ (function () { | ||
function IAccessRuntime(f) { | ||
this.f = f; | ||
} | ||
IAccessRuntime.prototype.tag = function () { | ||
return IAccessRuntimeTag; | ||
}; | ||
return IAccessRuntime; | ||
}()); | ||
exports.IAccessRuntime = IAccessRuntime; | ||
var IProvideEnvTag = "IProvideEnv"; | ||
var IProvideEnv = /** @class */ (function () { | ||
function IProvideEnv(e, r) { | ||
this.e = e; | ||
this.r = r; | ||
} | ||
IProvideEnv.prototype.tag = function () { | ||
return IProvideEnvTag; | ||
}; | ||
return IProvideEnv; | ||
}()); | ||
exports.IProvideEnv = IProvideEnv; | ||
var IAccessEnvTag = "IAccessEnv"; | ||
var IAccessEnv = /** @class */ (function () { | ||
function IAccessEnv() { | ||
} | ||
IAccessEnv.prototype.tag = function () { | ||
return IAccessEnvTag; | ||
}; | ||
return IAccessEnv; | ||
}()); | ||
exports.IAccessEnv = IAccessEnv; | ||
/** | ||
@@ -83,3 +218,3 @@ * An IO has succeeded | ||
function pure(a) { | ||
return new Implementation(defs_1.EffectTag.Pure, a); | ||
return new IPure(a); | ||
} | ||
@@ -94,3 +229,3 @@ exports.pure = pure; | ||
function raised(e) { | ||
return new Implementation(defs_1.EffectTag.Raised, e); | ||
return new IRaised(e); | ||
} | ||
@@ -123,3 +258,3 @@ exports.raised = raised; | ||
function completed(exit) { | ||
return new Implementation(defs_1.EffectTag.Completed, exit); | ||
return new ICompleted(exit); | ||
} | ||
@@ -134,3 +269,3 @@ exports.completed = completed; | ||
function suspended(thunk) { | ||
return new Implementation(defs_1.EffectTag.Suspended, thunk); | ||
return new ISuspended(thunk); | ||
} | ||
@@ -189,3 +324,3 @@ exports.suspended = suspended; | ||
function async(op) { | ||
return new Implementation(defs_1.EffectTag.Async, op); | ||
return new IAsync(op); | ||
} | ||
@@ -209,3 +344,3 @@ exports.async = async; | ||
function interruptibleRegion(inner, flag) { | ||
return new Implementation(defs_1.EffectTag.InterruptibleRegion, flag, inner); | ||
return new IInterruptibleRegion(inner, flag); | ||
} | ||
@@ -219,5 +354,5 @@ exports.interruptibleRegion = interruptibleRegion; | ||
function chain_(inner, bind) { | ||
return inner._tag === defs_1.EffectTag.Pure | ||
? bind(inner.f0) | ||
: new Implementation(defs_1.EffectTag.Chain, inner, bind); | ||
return (inner.tag() === IPureTag | ||
? bind(inner.a) | ||
: new IChain(inner, bind)); | ||
} | ||
@@ -245,3 +380,3 @@ function chainOption(onEmpty) { | ||
function encaseEither(e) { | ||
return new Implementation(defs_1.EffectTag.PureEither, e); | ||
return new IPureEither(e); | ||
} | ||
@@ -255,3 +390,3 @@ exports.encaseEither = encaseEither; | ||
function encaseOption(o, onError) { | ||
return new Implementation(defs_1.EffectTag.PureOption, o, onError); | ||
return new IPureOption(o, onError); | ||
} | ||
@@ -271,7 +406,7 @@ exports.encaseOption = encaseOption; | ||
*/ | ||
exports.accessInterruptible = new Implementation(defs_1.EffectTag.AccessInterruptible, fp_ts_1["function"].identity); | ||
exports.accessInterruptible = new IAccessInterruptible(fp_ts_1["function"].identity); | ||
/** | ||
* Get the runtime of the current fiber | ||
*/ | ||
exports.accessRuntime = new Implementation(defs_1.EffectTag.AccessRuntime, fp_ts_1["function"].identity); | ||
exports.accessRuntime = new IAccessRuntime(fp_ts_1["function"].identity); | ||
/** | ||
@@ -286,3 +421,3 @@ * Access the runtime then provide it to the provided function | ||
function accessEnvironment() { | ||
return new Implementation(defs_1.EffectTag.AccessEnv); | ||
return new IAccessEnv(); | ||
} | ||
@@ -324,5 +459,3 @@ exports.accessEnvironment = accessEnvironment; | ||
exports.provideM = provideM; | ||
var provideR = function (f) { return function (ma) { | ||
return accessM(function (r2) { return new Implementation(defs_1.EffectTag.ProvideEnv, ma, f(r2)); }); | ||
}; }; | ||
var provideR = function (f) { return function (ma) { return accessM(function (r2) { return new IProvideEnv(ma, f(r2)); }); }; }; | ||
/** | ||
@@ -334,5 +467,5 @@ * Map the value produced by an IO | ||
function map_(base, f) { | ||
return base._tag === defs_1.EffectTag.Pure | ||
? new Implementation(defs_1.EffectTag.Pure, f(base.f0)) | ||
: new Implementation(defs_1.EffectTag.Map, base, f); | ||
return (base.tag() === IPureTag | ||
? new IPure(f(base.a)) | ||
: new IMap(base, f)); | ||
} | ||
@@ -806,11 +939,7 @@ /** | ||
function makeFiber(init, name) { | ||
return accessM(function (r) { | ||
return chain_(exports.accessRuntime, function (runtime) { | ||
return sync(function () { | ||
var driver = new driver_1.DriverImpl(runtime); | ||
var fiber = new FiberImpl(driver, name); | ||
driver.start(provide(r)(init)); | ||
return fiber; | ||
}); | ||
}); | ||
return access(function (r) { | ||
var driver = new driver_1.DriverImpl(); | ||
var fiber = new FiberImpl(driver, name); | ||
driver.start(provide(r)(init)); | ||
return fiber; | ||
}); | ||
@@ -1108,3 +1237,3 @@ } | ||
var foldExit_ = function (inner, failure, success) { | ||
return new Implementation(defs_1.EffectTag.Collapse, inner, failure, success); | ||
return new ICollapse(inner, failure, success); | ||
}; | ||
@@ -1111,0 +1240,0 @@ var mapLeft_ = function (io, f) { return chainError_(io, fp_ts_1["function"].flow(f, raiseError)); }; |
{ | ||
"name": "@matechs/effect", | ||
"version": "6.1.0", | ||
"version": "6.2.0", | ||
"license": "MIT", | ||
@@ -43,3 +43,3 @@ "private": false, | ||
}, | ||
"gitHead": "192c7b95548e48c62f3cb0937cef3cc20f9f585f" | ||
"gitHead": "505584dc43a051c72aad8a3af619288b0cf1ca4a" | ||
} |
661637
19331