@fncts/io 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- package/Differ/api.d.ts +24 -0
- package/Differ/definition.d.ts +15 -0
- package/FiberRef/unsafe.d.ts +12 -6
- package/IOEnv/services.d.ts +2 -2
- package/Supervisor/api.d.ts +11 -5
- package/Supervisor/definition.d.ts +28 -0
- package/SupervisorPatch.d.ts +61 -0
- package/_cjs/Differ/api.cjs +108 -0
- package/_cjs/Differ/api.cjs.map +1 -0
- package/_cjs/Differ/definition.cjs +23 -0
- package/_cjs/Differ/definition.cjs.map +1 -0
- package/_cjs/FiberRef/unsafe.cjs +35 -21
- package/_cjs/FiberRef/unsafe.cjs.map +1 -1
- package/_cjs/IOEnv/definition.cjs.map +1 -1
- package/_cjs/IOEnv/services.cjs.map +1 -1
- package/_cjs/Supervisor/api.cjs +44 -33
- package/_cjs/Supervisor/api.cjs.map +1 -1
- package/_cjs/Supervisor/definition.cjs +66 -1
- package/_cjs/Supervisor/definition.cjs.map +1 -1
- package/_cjs/SupervisorPatch.cjs +172 -0
- package/_cjs/SupervisorPatch.cjs.map +1 -0
- package/_mjs/Differ/api.mjs +90 -0
- package/_mjs/Differ/api.mjs.map +1 -0
- package/_mjs/Differ/definition.mjs +13 -0
- package/_mjs/Differ/definition.mjs.map +1 -0
- package/_mjs/FiberRef/unsafe.mjs +31 -20
- package/_mjs/FiberRef/unsafe.mjs.map +1 -1
- package/_mjs/IOEnv/definition.mjs.map +1 -1
- package/_mjs/IOEnv/services.mjs.map +1 -1
- package/_mjs/Supervisor/api.mjs +39 -32
- package/_mjs/Supervisor/api.mjs.map +1 -1
- package/_mjs/Supervisor/definition.mjs +55 -0
- package/_mjs/Supervisor/definition.mjs.map +1 -1
- package/_mjs/SupervisorPatch.mjs +131 -0
- package/_mjs/SupervisorPatch.mjs.map +1 -0
- package/_src/Differ/api.ts +72 -0
- package/_src/Differ/definition.ts +16 -0
- package/_src/FiberRef/unsafe.ts +24 -22
- package/_src/IOEnv/definition.ts +0 -2
- package/_src/IOEnv/services.ts +5 -4
- package/_src/Supervisor/api.ts +33 -29
- package/_src/Supervisor/definition.ts +59 -0
- package/_src/SupervisorPatch.ts +107 -0
- package/_src/global.ts +4 -0
- package/global.d.ts +4 -0
- package/package.json +2 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"services.mjs","mappings":";AAEA,SAASA,WAAT,QAA4B,4BAA5B;AAEA;;;;AAGA,OAAO,MAAMC,QAAQ,
|
1
|
+
{"version":3,"file":"services.mjs","mappings":";AAEA,SAASA,WAAT,QAA4B,4BAA5B;AAEA;;;;AAGA,OAAO,MAAMC,QAAQ,gBAGjBC,sCAA+BF,WAA/B,CAHG","names":["environment","services","tsplus_module_1"],"sourceRoot":"","sources":["../../_src/IOEnv/services.ts"],"sourcesContent":[null]}
|
package/_mjs/Supervisor/api.mjs
CHANGED
@@ -1,45 +1,52 @@
|
|
1
|
-
|
2
|
-
import * as
|
3
|
-
|
1
|
+
import * as tsplus_module_1 from "@fncts/io/Supervisor/constructors";
|
2
|
+
import * as tsplus_module_2 from "@fncts/base/collection/immutable/HashSet/api";
|
3
|
+
export const zip_ = zip_1;
|
4
|
+
export const toSet = toSet_1;
|
5
|
+
export const removeSupervisor = removeSupervisor_1;
|
6
|
+
import { concrete, Zip } from "@fncts/io/Supervisor/definition";
|
4
7
|
/**
|
5
8
|
* @tsplus fluent fncts.io.Supervisor zip
|
6
9
|
*/
|
7
10
|
|
8
|
-
|
9
|
-
return new
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
function zip_1(fa, fb) {
|
12
|
+
return new Zip(fa, fb);
|
13
|
+
}
|
14
|
+
/**
|
15
|
+
* @tsplus getter fncts.io.Supervisor toSet
|
16
|
+
*/
|
14
17
|
|
15
|
-
unsafeOnStart(environment, effect, parent, fiber) {
|
16
|
-
try {
|
17
|
-
fa.unsafeOnStart(environment, effect, parent, fiber);
|
18
|
-
} finally {
|
19
|
-
fb.unsafeOnStart(environment, effect, parent, fiber);
|
20
|
-
}
|
21
|
-
}
|
22
18
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
function toSet_1(self) {
|
20
|
+
void 0;
|
21
|
+
if (self === tsplus_module_1.none) return tsplus_module_2.makeDefault();else {
|
22
|
+
switch (self._tag) {
|
23
|
+
case 2
|
24
|
+
/* SupervisorTag.Zip */
|
25
|
+
:
|
26
|
+
return tsplus_module_2.union_(toSet_1(self.first), toSet_1(self.second));
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
fb.unsafeOnEffect(fiber, effect);
|
28
|
+
default:
|
29
|
+
return tsplus_module_2.add_(tsplus_module_2.makeDefault(), self);
|
31
30
|
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
/**
|
34
|
+
* @tsplus fluent fncts.io.Supervisor removeSupervisor
|
35
|
+
*/
|
32
36
|
|
33
|
-
unsafeOnSuspend(fiber) {
|
34
|
-
fa.unsafeOnSuspend(fiber);
|
35
|
-
fb.unsafeOnSuspend(fiber);
|
36
|
-
}
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
function removeSupervisor_1(self, that) {
|
39
|
+
void 0;
|
40
|
+
if (self === that) return tsplus_module_1.none;else {
|
41
|
+
switch (self._tag) {
|
42
|
+
case 2
|
43
|
+
/* SupervisorTag.Zip */
|
44
|
+
:
|
45
|
+
return zip_1(removeSupervisor_1(self.first, that), removeSupervisor_1(self.second, that));
|
42
46
|
|
43
|
-
|
47
|
+
default:
|
48
|
+
return self;
|
49
|
+
}
|
50
|
+
}
|
44
51
|
}
|
45
52
|
//# sourceMappingURL=api.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"api.mjs","mappings":"
|
1
|
+
{"version":3,"file":"api.mjs","mappings":";;aAKgBA,IAAI;aAOJC,KAAK;aAgBLC,gBAAgB;AA5BhC,SAASC,QAAT,EAAkCC,GAAlC,QAA6C,iCAA7C;AAEA;;;;AAGA,eAA2BC,EAA3B,EAA8CC,EAA9C,EAA+D;EAC7D,OAAO,IAAIF,GAAJ,CAAQC,EAAR,EAAYC,EAAZ,CAAP;AACD;AAED;;;;;AAGA,iBAAsBC,IAAtB,EAA2C;EACzC;EACA,IAAIA,IAAI,yBAAR,EAA8B,OAAOC,6BAAP,CAA9B,KACK;IACH,QAAQD,IAAI,CAACE,IAAb;MACE;MAAA;MAAA;QACE,OAAOD,mCAAI,CAACE,KAAL,GAAUC,QAAaJ,IAAI,CAACK,MAAlB,CAAV,CAAP;;MACF;QACE,OAAOJ,oDAA2CD,IAA3C,CAAP;IAJJ;EAMD;AACF;AAED;;;;;AAGA,4BAAiCA,IAAjC,EAAwDM,IAAxD,EAA6E;EAC3E;EACA,IAAIN,IAAI,KAAKM,IAAb,EAAmB,4BAAnB,KACK;IACH,QAAQN,IAAI,CAACE,IAAb;MACE;MAAA;MAAA;QACE,OAAOK,6BAAI,CAACJ,KAAL,EAA4BG,IAA5B,GAAsCE,uBAAI,CAACH,MAAL,EAA6BC,IAA7B,CAAtC,CAAP;;MACF;QACE,OAAON,IAAP;IAJJ;EAMD;AACF","names":["zip_","toSet","removeSupervisor","concrete","Zip","fa","fb","self","tsplus_module_2","_tag","first","toSet_1","second","that","zip_1","removeSupervisor_1"],"sourceRoot":"","sources":["../../_src/Supervisor/api.ts"],"sourcesContent":[null]}
|
@@ -1,7 +1,10 @@
|
|
1
|
+
const fileName_1 = "(@fncts/io) src/Supervisor/definition.ts";
|
2
|
+
import * as tsplus_module_1 from "@fncts/io/IO/api";
|
1
3
|
/**
|
2
4
|
* @tsplus type fncts.io.Supervisor
|
3
5
|
* @tsplus companion fncts.io.SupervisorOps
|
4
6
|
*/
|
7
|
+
|
5
8
|
export class Supervisor {
|
6
9
|
unsafeOnEffect(_fiber, _effect) {
|
7
10
|
return;
|
@@ -20,6 +23,9 @@ export class ConstSupervisor extends Supervisor {
|
|
20
23
|
constructor(value) {
|
21
24
|
super();
|
22
25
|
this.value = value;
|
26
|
+
this._tag = 0
|
27
|
+
/* SupervisorTag.Const */
|
28
|
+
;
|
23
29
|
}
|
24
30
|
|
25
31
|
unsafeOnStart() {
|
@@ -48,6 +54,9 @@ export class ProxySupervisor extends Supervisor {
|
|
48
54
|
super();
|
49
55
|
this.value = value;
|
50
56
|
this.underlying = underlying;
|
57
|
+
this._tag = 1
|
58
|
+
/* SupervisorTag.Proxy */
|
59
|
+
;
|
51
60
|
}
|
52
61
|
|
53
62
|
unsafeOnStart(environment, effect, parent, fiber) {
|
@@ -70,5 +79,51 @@ export class ProxySupervisor extends Supervisor {
|
|
70
79
|
this.underlying.unsafeOnResume(fiber);
|
71
80
|
}
|
72
81
|
|
82
|
+
}
|
83
|
+
export class Zip extends Supervisor {
|
84
|
+
constructor(first, second) {
|
85
|
+
super();
|
86
|
+
this.first = first;
|
87
|
+
this.second = second;
|
88
|
+
this._tag = 2
|
89
|
+
/* SupervisorTag.Zip */
|
90
|
+
;
|
91
|
+
this.value = tsplus_module_1.zip_(this.first.value, this.second.value, fileName_1 + ":91:31");
|
92
|
+
}
|
93
|
+
|
94
|
+
unsafeOnStart(environment, effect, parent, fiber) {
|
95
|
+
try {
|
96
|
+
this.first.unsafeOnStart(environment, effect, parent, fiber);
|
97
|
+
} finally {
|
98
|
+
this.second.unsafeOnStart(environment, effect, parent, fiber);
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
unsafeOnEnd(value, fiber) {
|
103
|
+
this.first.unsafeOnEnd(value, fiber);
|
104
|
+
this.second.unsafeOnEnd(value, fiber);
|
105
|
+
}
|
106
|
+
|
107
|
+
unsafeOnEffect(fiber, effect) {
|
108
|
+
this.first.unsafeOnEffect(fiber, effect);
|
109
|
+
this.second.unsafeOnEffect(fiber, effect);
|
110
|
+
}
|
111
|
+
|
112
|
+
unsafeOnSuspend(fiber) {
|
113
|
+
this.first.unsafeOnSuspend(fiber);
|
114
|
+
this.second.unsafeOnSuspend(fiber);
|
115
|
+
}
|
116
|
+
|
117
|
+
unsafeOnResume(fiber) {
|
118
|
+
this.first.unsafeOnResume(fiber);
|
119
|
+
this.second.unsafeOnResume(fiber);
|
120
|
+
}
|
121
|
+
|
122
|
+
}
|
123
|
+
/**
|
124
|
+
* @tsplus macro remove
|
125
|
+
*/
|
126
|
+
|
127
|
+
export function concrete(_) {//
|
73
128
|
}
|
74
129
|
//# sourceMappingURL=definition.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"definition.mjs","mappings":"
|
1
|
+
{"version":3,"file":"definition.mjs","mappings":";;AAQA;;;;;AAIA,OAAM,MAAgBA,UAAhB,CAA0B;EAS9BC,cAAc,CAAOC,MAAP,EAAoCC,OAApC,EAA8D;IAC1E;EACD;;EACDC,eAAe,CAAOF,MAAP,EAAkC;IAC/C;EACD;;EACDG,cAAc,CAAOH,MAAP,EAAkC;IAC9C;EACD;;AAjB6B;AAwBhC,OAAM,MAAOI,eAAP,SAAkCN,UAAlC,CAA+C;EAEnDO,YAAqBC,KAArB,EAAkC;IAChC;IADmB;IADZ,YAAI;IAAA;IAAJ;EAGR;;EACDC,aAAa;IACX;EACD;;EACDC,WAAW;IACT;EACD;;EACDT,cAAc;IACZ;EACD;;EACDG,eAAe;IACb;EACD;;EACDC,cAAc;IACZ;EACD;;AAnBkD;AAsBrD,OAAM,MAAOM,eAAP,SAAkCX,UAAlC,CAA+C;EAEnDO,YAAqBC,KAArB,EAA6CI,UAA7C,EAAwE;IACtE;IADmB;IAAwB;IADpC,YAAI;IAAA;IAAJ;EAGR;;EACDH,aAAa,CACXI,WADW,EAEXC,MAFW,EAGXC,MAHW,EAIXC,KAJW,EAIe;IAE1B,KAAKJ,UAAL,CAAgBH,aAAhB,CAA8BI,WAA9B,EAA2CC,MAA3C,EAAmDC,MAAnD,EAA2DC,KAA3D;EACD;;EACDN,WAAW,CAAOF,KAAP,EAA0BQ,KAA1B,EAAoD;IAC7D,KAAKJ,UAAL,CAAgBF,WAAhB,CAA4BF,KAA5B,EAAmCQ,KAAnC;EACD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ACDV,eAAe,CAAOY,KAAP,EAAiC;IAC9C,KAAKE,KAAL,CAAWd,eAAX,CAA2BY,KAA3B;IACA,KAAKG,MAAL,CAAYf,eAAZ,CAA4BY,KAA5B;EACD;;EACDX,cAAc,CAAOW,KAAP,EAAiC;IAC7C,KAAKE,KAAL,CAAWb,cAAX,CAA0BW,KAA1B;IACA,KAAKG,MAAL,CAAYd,cAAZ,CAA2BW,KAA3B;EACD;;AAjCuD;AAsC1D;;;;AAGA,OAAM,SAAUM,QAAV,CAAmBC,CAAnB,EAAqC,CACzC;AACD","names":["Supervisor","unsafeOnEffect","_fiber","_effect","unsafeOnSuspend","unsafeOnResume","ConstSupervisor","constructor","value","unsafeOnStart","unsafeOnEnd","ProxySupervisor","underlying","environment","effect","parent","fiber","Zip","first","second","tsplus_module_1","fileName_1","concrete","_"],"sourceRoot":"","sources":["../../_src/Supervisor/definition.ts"],"sourcesContent":[null]}
|
@@ -0,0 +1,131 @@
|
|
1
|
+
import * as tsplus_module_1 from "@fncts/io/Supervisor/api";
|
2
|
+
import * as tsplus_module_2 from "@fncts/base/collection/immutable/HashSet/api";
|
3
|
+
import * as tsplus_module_3 from "@fncts/base/collection/immutable/List/definition";
|
4
|
+
import * as tsplus_module_4 from "@fncts/base/collection/immutable/List/constructors";
|
5
|
+
export const combine = combine_1;
|
6
|
+
export const SupervisorPatchTypeId = /*#__PURE__*/Symbol.for("fncts.io.Supervisor.Patch");
|
7
|
+
/**
|
8
|
+
* @tsplus type fncts.io.SupervisorPatch
|
9
|
+
* @tsplus companion fncts.io.SupervisorPatchOps
|
10
|
+
*/
|
11
|
+
|
12
|
+
export class SupervisorPatch {
|
13
|
+
constructor() {
|
14
|
+
this._typeId = SupervisorPatchTypeId;
|
15
|
+
}
|
16
|
+
|
17
|
+
}
|
18
|
+
export class AddSupervisor extends SupervisorPatch {
|
19
|
+
constructor(supervisor) {
|
20
|
+
super();
|
21
|
+
this.supervisor = supervisor;
|
22
|
+
this._tag = 0
|
23
|
+
/* SupervisorPatchTag.AddSupervisor */
|
24
|
+
;
|
25
|
+
}
|
26
|
+
|
27
|
+
}
|
28
|
+
export class Combine extends SupervisorPatch {
|
29
|
+
constructor(first, second) {
|
30
|
+
super();
|
31
|
+
this.first = first;
|
32
|
+
this.second = second;
|
33
|
+
this._tag = 1
|
34
|
+
/* SupervisorPatchTag.Combine */
|
35
|
+
;
|
36
|
+
}
|
37
|
+
|
38
|
+
}
|
39
|
+
export class Empty extends SupervisorPatch {
|
40
|
+
constructor() {
|
41
|
+
super(...arguments);
|
42
|
+
this._tag = 2
|
43
|
+
/* SupervisorPatchTag.Empty */
|
44
|
+
;
|
45
|
+
}
|
46
|
+
|
47
|
+
}
|
48
|
+
export class RemoveSupervisor extends SupervisorPatch {
|
49
|
+
constructor(supervisor) {
|
50
|
+
super();
|
51
|
+
this.supervisor = supervisor;
|
52
|
+
this._tag = 3
|
53
|
+
/* SupervisorPatchTag.RemoveSupervisor */
|
54
|
+
;
|
55
|
+
}
|
56
|
+
|
57
|
+
}
|
58
|
+
/**
|
59
|
+
* @tsplus macro remove
|
60
|
+
*/
|
61
|
+
|
62
|
+
export function concrete(_) {//
|
63
|
+
}
|
64
|
+
/**
|
65
|
+
* @tsplus static fncts.io.SupervisorPatchOps empty
|
66
|
+
*/
|
67
|
+
|
68
|
+
const empty_1 = /*#__PURE__*/new Empty();
|
69
|
+
export const empty = empty_1;
|
70
|
+
/**
|
71
|
+
* @tsplus fluent fncts.io.SupervisorPatch combine
|
72
|
+
*/
|
73
|
+
|
74
|
+
function combine_1(first, second) {
|
75
|
+
return new Combine(first, second);
|
76
|
+
}
|
77
|
+
/**
|
78
|
+
* @tsplus static fncts.io.SupervisorPatchOps diff
|
79
|
+
*/
|
80
|
+
|
81
|
+
|
82
|
+
export function diff(oldValue, newValue) {
|
83
|
+
if (oldValue === newValue) return new Empty();else {
|
84
|
+
const oldSupervisors = tsplus_module_1.toSet(oldValue);
|
85
|
+
const newSupervisors = tsplus_module_1.toSet(newValue);
|
86
|
+
const added = tsplus_module_2.foldLeft_(tsplus_module_2.difference_(newSupervisors, oldSupervisors), empty_1, (patch, supervisor) => combine_1(patch, new AddSupervisor(supervisor)));
|
87
|
+
const removed = tsplus_module_2.foldLeft_(tsplus_module_2.difference_(oldSupervisors, newSupervisors), empty_1, (patch, supervisor) => combine_1(patch, new RemoveSupervisor(supervisor)));
|
88
|
+
return combine_1(added, removed);
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
function applyLoop(supervisor, patches) {
|
93
|
+
if (tsplus_module_3.isEmpty(patches)) {
|
94
|
+
return supervisor;
|
95
|
+
}
|
96
|
+
|
97
|
+
const head = patches.head;
|
98
|
+
const tail = patches.tail;
|
99
|
+
void 0;
|
100
|
+
|
101
|
+
switch (head._tag) {
|
102
|
+
case 0
|
103
|
+
/* SupervisorPatchTag.AddSupervisor */
|
104
|
+
:
|
105
|
+
return applyLoop(tsplus_module_1.zip_(supervisor, head.supervisor), tail);
|
106
|
+
|
107
|
+
case 1
|
108
|
+
/* SupervisorPatchTag.Combine */
|
109
|
+
:
|
110
|
+
return applyLoop(supervisor, tsplus_module_4.cons(head.first, tsplus_module_4.cons(head.second, patches)));
|
111
|
+
|
112
|
+
case 2
|
113
|
+
/* SupervisorPatchTag.Empty */
|
114
|
+
:
|
115
|
+
return applyLoop(supervisor, tail);
|
116
|
+
|
117
|
+
case 3
|
118
|
+
/* SupervisorPatchTag.RemoveSupervisor */
|
119
|
+
:
|
120
|
+
return applyLoop(tsplus_module_1.removeSupervisor(supervisor, head.supervisor), tail);
|
121
|
+
}
|
122
|
+
}
|
123
|
+
/**
|
124
|
+
* @tsplus fluent fncts.io.SupervisorPatch __call
|
125
|
+
*/
|
126
|
+
|
127
|
+
|
128
|
+
export function apply(self, supervisor) {
|
129
|
+
return applyLoop(supervisor, tsplus_module_4.cons(self));
|
130
|
+
}
|
131
|
+
//# sourceMappingURL=SupervisorPatch.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{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G,KAAK,GAAYC,sEACTH,cADS,GACML,OADN,EAEY,CAACS,KAAD,EAAQjB,UAAR,KAAuBkB,iBAAc,IAAInB,aAAJ,CAAkBC,UAAlB,CAAd,CAFnC,CAAvB;IAGA,MAAMmB,OAAO,GAAGH,sEACFF,cADE,GACaN,OADb,EAEmB,CAACS,KAAD,EAAQjB,UAAR,KAAuBkB,iBAAc,IAAIb,gBAAJ,CAAqBL,UAArB,CAAd,CAF1C,CAAhB;IAGA,OAAOkB,iBAAcC,OAAd,CAAP;EACD;AACF;;AAED,SAASC,SAAT,CAAmBpB,UAAnB,EAAgDqB,OAAhD,EAA8E;EAC5E,IAAIC,gCAAJ,EAAuB;IACrB,OAAOtB,UAAP;EACD;;EACD,MAAMuB,IAAI,GAAGF,OAAO,CAACE,IAArB;EACA,MAAMC,IAAI,GAAGH,OAAO,CAACG,IAArB;EACA;;EACA,QAAQD,IAAI,CAACE,IAAb;IACE;IAAA;IAAA;MACE,OAAOL,SAAS,CAACM,iCAAeH,IAAI,CAACvB,UAApB,CAAD,EAAkCwB,IAAlC,CAAhB;;IACF;IAAA;IAAA;MACE,OAAOJ,SAAS,CAACpB,UAAD,EAAa2B,qBAAKJ,IAAI,CAACrB,KAAV,EAAiByB,qBAAKJ,IAAI,CAACpB,MAAV,EAAkBkB,OAAlB,CAAjB,CAAb,CAAhB;;IACF;IAAA;IAAA;MACE,OAAOD,SAAS,CAACpB,UAAD,EAAawB,IAAb,CAAhB;;IACF;IAAA;IAAA;MACE,OAAOJ,SAAS,CAACM,6CAA4BH,IAAI,CAACvB,UAAjC,CAAD,EAA+CwB,IAA/C,CAAhB;EARJ;AAUD;AAED;;;;;AAGA,OAAM,SAAUI,KAAV,CAAgBC,IAAhB,EAAuC7B,UAAvC,EAAkE;EACtE,OAAOoB,SAAS,CAACpB,UAAD,EAAa2B,qBAAKE,IAAL,CAAb,CAAhB;AACD","names":["combine","SupervisorPatchTypeId","Symbol","for","SupervisorPatch","constructor","AddSupervisor","supervisor","Combine","first","second","Empty","RemoveSupervisor","concrete","_","empty_1","empty","diff","oldValue","newValue","oldSupervisors","newSupervisors","added","tsplus_module_2","patch","combine_1","removed","applyLoop","patches","tsplus_module_3","head","tail","_tag","tsplus_module_1","tsplus_module_4","apply","self"],"sourceRoot":"","sources":["../_src/SupervisorPatch.ts"],"sourcesContent":[null]}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import type { Environment } from "@fncts/base/data/Environment";
|
2
|
+
import type { Supervisor } from "@fncts/io/Supervisor";
|
3
|
+
|
4
|
+
import { SupervisorPatch } from "@fncts/io/SupervisorPatch";
|
5
|
+
|
6
|
+
import { Differ } from "./definition.js";
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Constructs a differ that just diffs two values by returning a function that
|
10
|
+
* sets the value to the new value. This differ does not support combining
|
11
|
+
* multiple updates to the value compositionally and should only be used when
|
12
|
+
* there is no compositional way to update them.
|
13
|
+
*
|
14
|
+
* @tsplus static fncts.io.DifferOps update
|
15
|
+
*/
|
16
|
+
export function update<A>(): Differ<A, (_: A) => A> {
|
17
|
+
return new (class extends Differ<A, (_: A) => A> {
|
18
|
+
combine(first: (_: A) => A, second: (_: A) => A): (_: A) => A {
|
19
|
+
if (first === this.empty) return second;
|
20
|
+
else if (second === this.empty) return first;
|
21
|
+
return first.compose(second);
|
22
|
+
}
|
23
|
+
diff(oldValue: A, newValue: A): (_: A) => A {
|
24
|
+
if (oldValue === newValue) return this.empty;
|
25
|
+
else return () => newValue;
|
26
|
+
}
|
27
|
+
empty = Function.identity;
|
28
|
+
patch(patch: (_: A) => A): (oldValue: A) => A {
|
29
|
+
return patch;
|
30
|
+
}
|
31
|
+
})();
|
32
|
+
}
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Constructs a differ that knows how to diff `Environment` values.
|
36
|
+
*
|
37
|
+
* @tsplus static fncts.io.DifferOps environment
|
38
|
+
*/
|
39
|
+
export function environment<A>(): Differ<Environment<A>, Environment.Patch<A, A>> {
|
40
|
+
return new (class extends Differ<Environment<A>, Environment.Patch<A, A>> {
|
41
|
+
combine(first: Environment.Patch<A, A>, second: Environment.Patch<A, A>): Environment.Patch<A, A> {
|
42
|
+
return first.combine(second);
|
43
|
+
}
|
44
|
+
diff(oldValue: Environment<A>, newValue: Environment<A>): Environment.Patch<A, A> {
|
45
|
+
return EnvironmentPatch.diff(oldValue, newValue);
|
46
|
+
}
|
47
|
+
empty = EnvironmentPatch.empty<A>();
|
48
|
+
patch(patch: Environment.Patch<A, A>): (oldValue: Environment<A>) => Environment<A> {
|
49
|
+
return (oldValue) => patch(oldValue);
|
50
|
+
}
|
51
|
+
})();
|
52
|
+
}
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Constructs a differ that knows how to diff `Supervisor` values.
|
56
|
+
*
|
57
|
+
* @tsplus static fncts.io.DifferOps supervisor
|
58
|
+
*/
|
59
|
+
export function supervisor(): Differ<Supervisor<any>, Supervisor.Patch> {
|
60
|
+
return new (class extends Differ<Supervisor<any>, Supervisor.Patch> {
|
61
|
+
combine(first: SupervisorPatch, second: SupervisorPatch): SupervisorPatch {
|
62
|
+
return first.combine(second);
|
63
|
+
}
|
64
|
+
diff(oldValue: Supervisor<any>, newValue: Supervisor<any>): SupervisorPatch {
|
65
|
+
return SupervisorPatch.diff(oldValue, newValue);
|
66
|
+
}
|
67
|
+
empty: SupervisorPatch = SupervisorPatch.empty;
|
68
|
+
patch(patch: SupervisorPatch): (oldValue: Supervisor<any>) => Supervisor<any> {
|
69
|
+
return (oldValue) => patch(oldValue);
|
70
|
+
}
|
71
|
+
})();
|
72
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
export const DifferTypeId = Symbol.for("fncts.io.Differ");
|
2
|
+
export type DifferTypeId = typeof DifferTypeId;
|
3
|
+
|
4
|
+
/**
|
5
|
+
* @tsplus type fncts.io.Differ
|
6
|
+
* @tsplus companion fncts.io.DifferOps
|
7
|
+
*/
|
8
|
+
export abstract class Differ<Value, Patch> {
|
9
|
+
readonly _typeId: DifferTypeId = DifferTypeId;
|
10
|
+
declare _Value: Value;
|
11
|
+
declare _Patch: Patch;
|
12
|
+
abstract readonly empty: Patch;
|
13
|
+
abstract combine(first: Patch, second: Patch): Patch;
|
14
|
+
abstract diff(oldValue: Value, newValue: Value): Patch;
|
15
|
+
abstract patch(patch: Patch): (oldValue: Value) => Value;
|
16
|
+
}
|
package/_src/FiberRef/unsafe.ts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
import type { LogSpan } from "../LogSpan.js";
|
2
2
|
import type { Scheduler } from "@fncts/io/internal/Scheduler.js";
|
3
3
|
|
4
|
+
import { EnvironmentPatch } from "@fncts/base/data/EnvironmentPatch";
|
4
5
|
import { identity } from "@fncts/base/data/function";
|
5
|
-
import {
|
6
|
+
import { Differ } from "@fncts/io/Differ/definition";
|
6
7
|
import { defaultScheduler } from "@fncts/io/internal/Scheduler";
|
7
8
|
|
8
9
|
import { IsFatal } from "../internal/IsFatal.js";
|
@@ -13,26 +14,34 @@ import { FiberRefInternal } from "./definition.js";
|
|
13
14
|
*/
|
14
15
|
export function unsafeMakePatch<Value, Patch>(
|
15
16
|
initial: Value,
|
16
|
-
|
17
|
-
combine: (first: Patch, second: Patch) => Patch,
|
18
|
-
patch: (patch: Patch) => (oldValue: Value) => Value,
|
17
|
+
differ: Differ<Value, Patch>,
|
19
18
|
fork: Patch,
|
20
19
|
join: (oldValue: Value, newValue: Value) => Value = (_, newValue) => newValue,
|
21
20
|
): FiberRef.WithPatch<Value, Patch> {
|
22
|
-
return new FiberRefInternal(
|
21
|
+
return new FiberRefInternal(
|
22
|
+
initial,
|
23
|
+
(oldValue, newValue) => differ.diff(oldValue, newValue),
|
24
|
+
(first, second) => differ.combine(first, second),
|
25
|
+
(patch) => (oldValue) => differ.patch(patch)(oldValue),
|
26
|
+
fork,
|
27
|
+
join,
|
28
|
+
);
|
23
29
|
}
|
24
30
|
|
25
31
|
/**
|
26
32
|
* @tsplus static fncts.io.FiberRefOps unsafeMakeEnvironment
|
27
33
|
*/
|
28
|
-
export function unsafeMakeEnvironment<A>(
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
export function unsafeMakeEnvironment<A>(
|
35
|
+
initial: Environment<A>,
|
36
|
+
): FiberRef.WithPatch<Environment<A>, Environment.Patch<A, A>> {
|
37
|
+
return FiberRef.unsafeMakePatch(initial, Differ.environment(), EnvironmentPatch.empty());
|
38
|
+
}
|
39
|
+
|
40
|
+
/**
|
41
|
+
* @tsplus static fncts.io.FiberRefOps unsafeMakeSupervisor
|
42
|
+
*/
|
43
|
+
export function unsafeMakeSupervisor(initial: Supervisor<any>): FiberRef.WithPatch<Supervisor<any>, SupervisorPatch> {
|
44
|
+
return FiberRef.unsafeMakePatch(initial, Differ.supervisor(), SupervisorPatch.empty);
|
36
45
|
}
|
37
46
|
|
38
47
|
/**
|
@@ -43,14 +52,7 @@ export function unsafeMake<A>(
|
|
43
52
|
fork: (a: A) => A = identity,
|
44
53
|
join: (a0: A, a1: A) => A = (_, a) => a,
|
45
54
|
): FiberRef.WithPatch<A, (_: A) => A> {
|
46
|
-
return FiberRef.unsafeMakePatch(
|
47
|
-
initial,
|
48
|
-
(_, newValue) => () => newValue,
|
49
|
-
(first, second) => (value) => second(first(value)),
|
50
|
-
(patch) => (value) => patch(value),
|
51
|
-
fork,
|
52
|
-
join,
|
53
|
-
);
|
55
|
+
return FiberRef.unsafeMakePatch(initial, Differ.update(), fork, join);
|
54
56
|
}
|
55
57
|
|
56
58
|
/**
|
@@ -95,7 +97,7 @@ export const currentScheduler = FiberRef.unsafeMake<Scheduler>(defaultScheduler)
|
|
95
97
|
/**
|
96
98
|
* @tsplus static fncts.io.FiberRefOps currentSupervisor
|
97
99
|
*/
|
98
|
-
export const currentSupervisor = FiberRef.
|
100
|
+
export const currentSupervisor = FiberRef.unsafeMakeSupervisor(Supervisor.none);
|
99
101
|
|
100
102
|
/**
|
101
103
|
* @tsplus static fncts.io.FiberRefOps currentIsFatal
|
package/_src/IOEnv/definition.ts
CHANGED
package/_src/IOEnv/services.ts
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
import type {
|
1
|
+
import type { EnvironmentPatch } from "@fncts/base/data/EnvironmentPatch";
|
2
2
|
|
3
3
|
import { environment } from "@fncts/io/IOEnv/definition";
|
4
4
|
|
5
5
|
/**
|
6
6
|
* @tsplus static fncts.io.IOEnvOps services
|
7
7
|
*/
|
8
|
-
export const services: FiberRef.WithPatch<
|
9
|
-
|
10
|
-
|
8
|
+
export const services: FiberRef.WithPatch<
|
9
|
+
Environment<IOEnv>,
|
10
|
+
EnvironmentPatch<IOEnv, IOEnv>
|
11
|
+
> = FiberRef.unsafeMakeEnvironment(environment);
|
package/_src/Supervisor/api.ts
CHANGED
@@ -1,36 +1,40 @@
|
|
1
|
+
import { concrete, SupervisorTag, Zip } from "@fncts/io/Supervisor/definition";
|
2
|
+
|
1
3
|
/**
|
2
4
|
* @tsplus fluent fncts.io.Supervisor zip
|
3
5
|
*/
|
4
6
|
export function zip_<A, B>(fa: Supervisor<A>, fb: Supervisor<B>): Supervisor<readonly [A, B]> {
|
5
|
-
return new (
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
fa.unsafeOnEnd(value, fiber);
|
21
|
-
fb.unsafeOnEnd(value, fiber);
|
22
|
-
}
|
23
|
-
unsafeOnEffect<E, A>(fiber: Fiber.Runtime<E, A>, effect: IO<any, any, any>) {
|
24
|
-
fa.unsafeOnEffect(fiber, effect);
|
25
|
-
fb.unsafeOnEffect(fiber, effect);
|
26
|
-
}
|
27
|
-
unsafeOnSuspend<E, A>(fiber: Fiber.Runtime<E, A>) {
|
28
|
-
fa.unsafeOnSuspend(fiber);
|
29
|
-
fb.unsafeOnSuspend(fiber);
|
7
|
+
return new Zip(fa, fb);
|
8
|
+
}
|
9
|
+
|
10
|
+
/**
|
11
|
+
* @tsplus getter fncts.io.Supervisor toSet
|
12
|
+
*/
|
13
|
+
export function toSet(self: Supervisor<any>): HashSet<Supervisor<any>> {
|
14
|
+
concrete(self);
|
15
|
+
if (self === Supervisor.none) return HashSet.makeDefault();
|
16
|
+
else {
|
17
|
+
switch (self._tag) {
|
18
|
+
case SupervisorTag.Zip:
|
19
|
+
return self.first.toSet.union(self.second.toSet);
|
20
|
+
default:
|
21
|
+
return HashSet.makeDefault<Supervisor<any>>().add(self);
|
30
22
|
}
|
31
|
-
|
32
|
-
|
33
|
-
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
/**
|
27
|
+
* @tsplus fluent fncts.io.Supervisor removeSupervisor
|
28
|
+
*/
|
29
|
+
export function removeSupervisor(self: Supervisor<any>, that: Supervisor<any>): Supervisor<any> {
|
30
|
+
concrete(self);
|
31
|
+
if (self === that) return Supervisor.none;
|
32
|
+
else {
|
33
|
+
switch (self._tag) {
|
34
|
+
case SupervisorTag.Zip:
|
35
|
+
return self.first.removeSupervisor(that).zip(self.second.removeSupervisor(that));
|
36
|
+
default:
|
37
|
+
return self;
|
34
38
|
}
|
35
|
-
}
|
39
|
+
}
|
36
40
|
}
|