@matechs/effect
Advanced tools
Comparing version 5.0.20 to 5.0.21
@@ -5,3 +5,3 @@ import { either as E, function as F } from "fp-ts"; | ||
import * as T from "./effect"; | ||
import * as L from "./list"; | ||
import { DoublyLinkedList } from "./listc"; | ||
export declare type RegionFrameType = InterruptFrame; | ||
@@ -65,3 +65,3 @@ export declare type FrameType = Frame | FoldFrame | RegionFrameType | MapFrame; | ||
cancelAsync: T.AsyncCancelContFn | undefined; | ||
envStack: L.List<any>; | ||
envStack: DoublyLinkedList<any>; | ||
constructor(runtime?: Runtime); | ||
@@ -68,0 +68,0 @@ set(a: Exit<E, A>): void; |
@@ -8,3 +8,3 @@ /* | ||
import * as T from "./effect"; | ||
import * as L from "./list"; | ||
import { DoublyLinkedList } from "./listc"; | ||
class Frame { | ||
@@ -50,3 +50,3 @@ constructor(apply, prev) { | ||
this.currentFrame = undefined; | ||
this.envStack = L.empty(); | ||
this.envStack = new DoublyLinkedList(); | ||
} | ||
@@ -188,12 +188,12 @@ set(a) { | ||
case T.EffectTag.AccessEnv: | ||
const env = L.isNotEmpty(this.envStack) ? L.lastUnsafe(this.envStack) : {}; | ||
const env = !this.envStack.empty() ? this.envStack.tail.value : {}; | ||
current = this.next(env); | ||
break; | ||
case T.EffectTag.ProvideEnv: | ||
L.push(this.envStack, current.f1); | ||
this.envStack.append(current.f1); | ||
current = T.EffectIO.fromEffect(T.effect.foldExit(current.f0, (e) => T.effect.chain(T.sync(() => { | ||
L.popLastUnsafe(this.envStack); | ||
this.envStack.deleteTail(); | ||
return {}; | ||
}), (_) => T.raised(e)), (r) => T.sync(() => { | ||
L.popLastUnsafe(this.envStack); | ||
this.envStack.deleteTail(); | ||
return r; | ||
@@ -200,0 +200,0 @@ }))); |
@@ -14,16 +14,16 @@ // Copyright 2019 Ryan Zeigler | ||
// limitations under the License. | ||
/* istanbul ignore file */ | ||
import * as L from "../list"; | ||
import { LinkedList } from "../listc"; | ||
class RuntimeImpl { | ||
constructor() { | ||
this.running = false; | ||
this.array = L.empty(); | ||
this.array = new LinkedList(); | ||
this.isRunning = () => this.running; | ||
} | ||
run() { | ||
var _a, _b; | ||
this.running = true; | ||
let next = L.popUnsafe(this.array); | ||
let next = (_a = this.array.deleteHead()) === null || _a === void 0 ? void 0 : _a.value; | ||
while (next) { | ||
next[0](next[1]); | ||
next = L.popUnsafe(this.array); | ||
next = (_b = this.array.deleteHead()) === null || _b === void 0 ? void 0 : _b.value; | ||
} | ||
@@ -33,3 +33,3 @@ this.running = false; | ||
dispatch(thunk, a) { | ||
L.push(this.array, [thunk, a]); | ||
this.array.append([thunk, a]); | ||
if (!this.running) { | ||
@@ -36,0 +36,0 @@ this.run(); |
@@ -5,3 +5,3 @@ import { either as E, function as F } from "fp-ts"; | ||
import * as T from "./effect"; | ||
import * as L from "./list"; | ||
import { DoublyLinkedList } from "./listc"; | ||
export declare type RegionFrameType = InterruptFrame; | ||
@@ -65,3 +65,3 @@ export declare type FrameType = Frame | FoldFrame | RegionFrameType | MapFrame; | ||
cancelAsync: T.AsyncCancelContFn | undefined; | ||
envStack: L.List<any>; | ||
envStack: DoublyLinkedList<any>; | ||
constructor(runtime?: Runtime); | ||
@@ -68,0 +68,0 @@ set(a: Exit<E, A>): void; |
@@ -17,3 +17,3 @@ "use strict"; | ||
var T = __importStar(require("./effect")); | ||
var L = __importStar(require("./list")); | ||
var listc_1 = require("./listc"); | ||
var Frame = /** @class */ (function () { | ||
@@ -63,3 +63,3 @@ function Frame(apply, prev) { | ||
this.currentFrame = undefined; | ||
this.envStack = L.empty(); | ||
this.envStack = new listc_1.DoublyLinkedList(); | ||
} | ||
@@ -206,10 +206,10 @@ DriverImpl.prototype.set = function (a) { | ||
case T.EffectTag.AccessEnv: | ||
var env = L.isNotEmpty(this.envStack) ? L.lastUnsafe(this.envStack) : {}; | ||
var env = !this.envStack.empty() ? this.envStack.tail.value : {}; | ||
current = this.next(env); | ||
break; | ||
case T.EffectTag.ProvideEnv: | ||
L.push(this.envStack, current.f1); | ||
this.envStack.append(current.f1); | ||
current = T.EffectIO.fromEffect(T.effect.foldExit(current.f0, function (e) { | ||
return T.effect.chain(T.sync(function () { | ||
L.popLastUnsafe(_this.envStack); | ||
_this.envStack.deleteTail(); | ||
return {}; | ||
@@ -219,3 +219,3 @@ }), function (_) { return T.raised(e); }); | ||
return T.sync(function () { | ||
L.popLastUnsafe(_this.envStack); | ||
_this.envStack.deleteTail(); | ||
return r; | ||
@@ -222,0 +222,0 @@ }); |
@@ -15,12 +15,4 @@ "use strict"; | ||
// limitations under the License. | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
exports.__esModule = true; | ||
/* istanbul ignore file */ | ||
var L = __importStar(require("../list")); | ||
var listc_1 = require("../listc"); | ||
var RuntimeImpl = /** @class */ (function () { | ||
@@ -30,11 +22,12 @@ function RuntimeImpl() { | ||
this.running = false; | ||
this.array = L.empty(); | ||
this.array = new listc_1.LinkedList(); | ||
this.isRunning = function () { return _this.running; }; | ||
} | ||
RuntimeImpl.prototype.run = function () { | ||
var _a, _b; | ||
this.running = true; | ||
var next = L.popUnsafe(this.array); | ||
var next = (_a = this.array.deleteHead()) === null || _a === void 0 ? void 0 : _a.value; | ||
while (next) { | ||
next[0](next[1]); | ||
next = L.popUnsafe(this.array); | ||
next = (_b = this.array.deleteHead()) === null || _b === void 0 ? void 0 : _b.value; | ||
} | ||
@@ -44,3 +37,3 @@ this.running = false; | ||
RuntimeImpl.prototype.dispatch = function (thunk, a) { | ||
L.push(this.array, [thunk, a]); | ||
this.array.append([thunk, a]); | ||
if (!this.running) { | ||
@@ -47,0 +40,0 @@ this.run(); |
{ | ||
"name": "@matechs/effect", | ||
"version": "5.0.20", | ||
"version": "5.0.21", | ||
"license": "MIT", | ||
@@ -41,3 +41,3 @@ "private": false, | ||
}, | ||
"gitHead": "bb6e2275a6609a6958ea6862ea6559c2b0af20de" | ||
"gitHead": "acf48ccb0a04c568657baf02d56934f21ffd2029" | ||
} |
626807
143
15393