@barnum/barnum 0.0.0-main-e8b82cff → 0.0.0-main-d605f564

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barnum/barnum",
3
- "version": "0.0.0-main-e8b82cff",
3
+ "version": "0.0.0-main-d605f564",
4
4
  "description": "Barnum workflow engine",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/all.ts CHANGED
@@ -8,217 +8,79 @@ import { constant } from "./builtins.js";
8
8
 
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
10
  export function all(): TypedAction<any, []>;
11
- export function all<In, O1, R1 extends string>(
12
- a1: Pipeable<In, O1, R1>,
13
- ): TypedAction<In, [O1], R1>;
14
- export function all<In, O1, O2, R1 extends string, R2 extends string>(
15
- a1: Pipeable<In, O1, R1>,
16
- a2: Pipeable<In, O2, R2>,
17
- ): TypedAction<In, [O1, O2], R1 | R2>;
18
- export function all<
19
- In,
20
- O1,
21
- O2,
22
- O3,
23
- R1 extends string,
24
- R2 extends string,
25
- R3 extends string,
26
- >(
27
- a1: Pipeable<In, O1, R1>,
28
- a2: Pipeable<In, O2, R2>,
29
- a3: Pipeable<In, O3, R3>,
30
- ): TypedAction<In, [O1, O2, O3], R1 | R2 | R3>;
31
- export function all<
32
- In,
33
- O1,
34
- O2,
35
- O3,
36
- O4,
37
- R1 extends string,
38
- R2 extends string,
39
- R3 extends string,
40
- R4 extends string,
41
- >(
42
- a1: Pipeable<In, O1, R1>,
43
- a2: Pipeable<In, O2, R2>,
44
- a3: Pipeable<In, O3, R3>,
45
- a4: Pipeable<In, O4, R4>,
46
- ): TypedAction<In, [O1, O2, O3, O4], R1 | R2 | R3 | R4>;
47
- export function all<
48
- In,
49
- O1,
50
- O2,
51
- O3,
52
- O4,
53
- O5,
54
- R1 extends string,
55
- R2 extends string,
56
- R3 extends string,
57
- R4 extends string,
58
- R5 extends string,
59
- >(
60
- a1: Pipeable<In, O1, R1>,
61
- a2: Pipeable<In, O2, R2>,
62
- a3: Pipeable<In, O3, R3>,
63
- a4: Pipeable<In, O4, R4>,
64
- a5: Pipeable<In, O5, R5>,
65
- ): TypedAction<In, [O1, O2, O3, O4, O5], R1 | R2 | R3 | R4 | R5>;
66
- export function all<
67
- In,
68
- O1,
69
- O2,
70
- O3,
71
- O4,
72
- O5,
73
- O6,
74
- R1 extends string,
75
- R2 extends string,
76
- R3 extends string,
77
- R4 extends string,
78
- R5 extends string,
79
- R6 extends string,
80
- >(
81
- a1: Pipeable<In, O1, R1>,
82
- a2: Pipeable<In, O2, R2>,
83
- a3: Pipeable<In, O3, R3>,
84
- a4: Pipeable<In, O4, R4>,
85
- a5: Pipeable<In, O5, R5>,
86
- a6: Pipeable<In, O6, R6>,
87
- ): TypedAction<In, [O1, O2, O3, O4, O5, O6], R1 | R2 | R3 | R4 | R5 | R6>;
88
- export function all<
89
- In,
90
- O1,
91
- O2,
92
- O3,
93
- O4,
94
- O5,
95
- O6,
96
- O7,
97
- R1 extends string,
98
- R2 extends string,
99
- R3 extends string,
100
- R4 extends string,
101
- R5 extends string,
102
- R6 extends string,
103
- R7 extends string,
104
- >(
105
- a1: Pipeable<In, O1, R1>,
106
- a2: Pipeable<In, O2, R2>,
107
- a3: Pipeable<In, O3, R3>,
108
- a4: Pipeable<In, O4, R4>,
109
- a5: Pipeable<In, O5, R5>,
110
- a6: Pipeable<In, O6, R6>,
111
- a7: Pipeable<In, O7, R7>,
112
- ): TypedAction<
113
- In,
114
- [O1, O2, O3, O4, O5, O6, O7],
115
- R1 | R2 | R3 | R4 | R5 | R6 | R7
116
- >;
117
- export function all<
118
- In,
119
- O1,
120
- O2,
121
- O3,
122
- O4,
123
- O5,
124
- O6,
125
- O7,
126
- O8,
127
- R1 extends string,
128
- R2 extends string,
129
- R3 extends string,
130
- R4 extends string,
131
- R5 extends string,
132
- R6 extends string,
133
- R7 extends string,
134
- R8 extends string,
135
- >(
136
- a1: Pipeable<In, O1, R1>,
137
- a2: Pipeable<In, O2, R2>,
138
- a3: Pipeable<In, O3, R3>,
139
- a4: Pipeable<In, O4, R4>,
140
- a5: Pipeable<In, O5, R5>,
141
- a6: Pipeable<In, O6, R6>,
142
- a7: Pipeable<In, O7, R7>,
143
- a8: Pipeable<In, O8, R8>,
144
- ): TypedAction<
145
- In,
146
- [O1, O2, O3, O4, O5, O6, O7, O8],
147
- R1 | R2 | R3 | R4 | R5 | R6 | R7 | R8
148
- >;
149
- export function all<
150
- In,
151
- O1,
152
- O2,
153
- O3,
154
- O4,
155
- O5,
156
- O6,
157
- O7,
158
- O8,
159
- O9,
160
- R1 extends string,
161
- R2 extends string,
162
- R3 extends string,
163
- R4 extends string,
164
- R5 extends string,
165
- R6 extends string,
166
- R7 extends string,
167
- R8 extends string,
168
- R9 extends string,
169
- >(
170
- a1: Pipeable<In, O1, R1>,
171
- a2: Pipeable<In, O2, R2>,
172
- a3: Pipeable<In, O3, R3>,
173
- a4: Pipeable<In, O4, R4>,
174
- a5: Pipeable<In, O5, R5>,
175
- a6: Pipeable<In, O6, R6>,
176
- a7: Pipeable<In, O7, R7>,
177
- a8: Pipeable<In, O8, R8>,
178
- a9: Pipeable<In, O9, R9>,
179
- ): TypedAction<
180
- In,
181
- [O1, O2, O3, O4, O5, O6, O7, O8, O9],
182
- R1 | R2 | R3 | R4 | R5 | R6 | R7 | R8 | R9
183
- >;
184
- export function all<
185
- In,
186
- O1,
187
- O2,
188
- O3,
189
- O4,
190
- O5,
191
- O6,
192
- O7,
193
- O8,
194
- O9,
195
- O10,
196
- R1 extends string,
197
- R2 extends string,
198
- R3 extends string,
199
- R4 extends string,
200
- R5 extends string,
201
- R6 extends string,
202
- R7 extends string,
203
- R8 extends string,
204
- R9 extends string,
205
- R10 extends string,
206
- >(
207
- a1: Pipeable<In, O1, R1>,
208
- a2: Pipeable<In, O2, R2>,
209
- a3: Pipeable<In, O3, R3>,
210
- a4: Pipeable<In, O4, R4>,
211
- a5: Pipeable<In, O5, R5>,
212
- a6: Pipeable<In, O6, R6>,
213
- a7: Pipeable<In, O7, R7>,
214
- a8: Pipeable<In, O8, R8>,
215
- a9: Pipeable<In, O9, R9>,
216
- a10: Pipeable<In, O10, R10>,
217
- ): TypedAction<
218
- In,
219
- [O1, O2, O3, O4, O5, O6, O7, O8, O9, O10],
220
- R1 | R2 | R3 | R4 | R5 | R6 | R7 | R8 | R9 | R10
221
- >;
11
+ export function all<In, O1>(a1: Pipeable<In, O1>): TypedAction<In, [O1]>;
12
+ export function all<In, O1, O2>(
13
+ a1: Pipeable<In, O1>,
14
+ a2: Pipeable<In, O2>,
15
+ ): TypedAction<In, [O1, O2]>;
16
+ export function all<In, O1, O2, O3>(
17
+ a1: Pipeable<In, O1>,
18
+ a2: Pipeable<In, O2>,
19
+ a3: Pipeable<In, O3>,
20
+ ): TypedAction<In, [O1, O2, O3]>;
21
+ export function all<In, O1, O2, O3, O4>(
22
+ a1: Pipeable<In, O1>,
23
+ a2: Pipeable<In, O2>,
24
+ a3: Pipeable<In, O3>,
25
+ a4: Pipeable<In, O4>,
26
+ ): TypedAction<In, [O1, O2, O3, O4]>;
27
+ export function all<In, O1, O2, O3, O4, O5>(
28
+ a1: Pipeable<In, O1>,
29
+ a2: Pipeable<In, O2>,
30
+ a3: Pipeable<In, O3>,
31
+ a4: Pipeable<In, O4>,
32
+ a5: Pipeable<In, O5>,
33
+ ): TypedAction<In, [O1, O2, O3, O4, O5]>;
34
+ export function all<In, O1, O2, O3, O4, O5, O6>(
35
+ a1: Pipeable<In, O1>,
36
+ a2: Pipeable<In, O2>,
37
+ a3: Pipeable<In, O3>,
38
+ a4: Pipeable<In, O4>,
39
+ a5: Pipeable<In, O5>,
40
+ a6: Pipeable<In, O6>,
41
+ ): TypedAction<In, [O1, O2, O3, O4, O5, O6]>;
42
+ export function all<In, O1, O2, O3, O4, O5, O6, O7>(
43
+ a1: Pipeable<In, O1>,
44
+ a2: Pipeable<In, O2>,
45
+ a3: Pipeable<In, O3>,
46
+ a4: Pipeable<In, O4>,
47
+ a5: Pipeable<In, O5>,
48
+ a6: Pipeable<In, O6>,
49
+ a7: Pipeable<In, O7>,
50
+ ): TypedAction<In, [O1, O2, O3, O4, O5, O6, O7]>;
51
+ export function all<In, O1, O2, O3, O4, O5, O6, O7, O8>(
52
+ a1: Pipeable<In, O1>,
53
+ a2: Pipeable<In, O2>,
54
+ a3: Pipeable<In, O3>,
55
+ a4: Pipeable<In, O4>,
56
+ a5: Pipeable<In, O5>,
57
+ a6: Pipeable<In, O6>,
58
+ a7: Pipeable<In, O7>,
59
+ a8: Pipeable<In, O8>,
60
+ ): TypedAction<In, [O1, O2, O3, O4, O5, O6, O7, O8]>;
61
+ export function all<In, O1, O2, O3, O4, O5, O6, O7, O8, O9>(
62
+ a1: Pipeable<In, O1>,
63
+ a2: Pipeable<In, O2>,
64
+ a3: Pipeable<In, O3>,
65
+ a4: Pipeable<In, O4>,
66
+ a5: Pipeable<In, O5>,
67
+ a6: Pipeable<In, O6>,
68
+ a7: Pipeable<In, O7>,
69
+ a8: Pipeable<In, O8>,
70
+ a9: Pipeable<In, O9>,
71
+ ): TypedAction<In, [O1, O2, O3, O4, O5, O6, O7, O8, O9]>;
72
+ export function all<In, O1, O2, O3, O4, O5, O6, O7, O8, O9, O10>(
73
+ a1: Pipeable<In, O1>,
74
+ a2: Pipeable<In, O2>,
75
+ a3: Pipeable<In, O3>,
76
+ a4: Pipeable<In, O4>,
77
+ a5: Pipeable<In, O5>,
78
+ a6: Pipeable<In, O6>,
79
+ a7: Pipeable<In, O7>,
80
+ a8: Pipeable<In, O8>,
81
+ a9: Pipeable<In, O9>,
82
+ a10: Pipeable<In, O10>,
83
+ ): TypedAction<In, [O1, O2, O3, O4, O5, O6, O7, O8, O9, O10]>;
222
84
  export function all(...actions: Action[]): Action {
223
85
  if (actions.length === 0) {
224
86
  return constant([]);
package/src/ast.ts CHANGED
@@ -148,59 +148,41 @@ export type MergeTuple<TTuple> = TTuple extends unknown[]
148
148
  * so the covariant __in is needed for the entry point check).
149
149
  *
150
150
  */
151
- export type TypedAction<
152
- In = unknown,
153
- Out = unknown,
154
- Refs extends string = never,
155
- > = Action & {
151
+ export type TypedAction<In = unknown, Out = unknown> = Action & {
156
152
  __phantom_in?: (input: In) => void;
157
153
  __phantom_out?: () => Out;
158
154
  __phantom_out_check?: (output: Out) => void;
159
155
  __in?: In;
160
- __refs?: { _brand: Refs };
161
156
  /** Chain this action with another. `a.then(b)` ≡ `chain(a, b)`. */
162
- then<TNext, TRefs2 extends string = never>(
163
- next: Pipeable<Out, TNext, TRefs2>,
164
- ): TypedAction<In, TNext, Refs | TRefs2>;
157
+ then<TNext>(next: Pipeable<Out, TNext>): TypedAction<In, TNext>;
165
158
  /** Apply an action to each element of an array output. `a.forEach(b)` ≡ `a.then(forEach(b))`. */
166
- forEach<
167
- TIn,
168
- TElement,
169
- TNext,
170
- TRefs extends string,
171
- TRefs2 extends string = never,
172
- >(
173
- this: TypedAction<TIn, TElement[], TRefs>,
174
- action: Pipeable<TElement, TNext, TRefs2>,
175
- ): TypedAction<TIn, TNext[], TRefs | TRefs2>;
159
+ forEach<TIn, TElement, TNext>(
160
+ this: TypedAction<TIn, TElement[]>,
161
+ action: Pipeable<TElement, TNext>,
162
+ ): TypedAction<TIn, TNext[]>;
176
163
  /** Dispatch on a tagged union output. Auto-unwraps `value` before each case handler. */
177
164
  branch<
178
165
  TCases extends {
179
- [K in BranchKeys<Out>]: CaseHandler<
180
- BranchPayload<Out, K>,
181
- unknown,
182
- string
183
- >;
166
+ [K in BranchKeys<Out>]: CaseHandler<BranchPayload<Out, K>>;
184
167
  },
185
168
  >(
186
169
  cases: [BranchKeys<Out>] extends [never] ? never : TCases,
187
- ): TypedAction<In, ExtractOutput<TCases[keyof TCases & string]>, Refs>;
170
+ ): TypedAction<In, ExtractOutput<TCases[keyof TCases & string]>>;
188
171
  /** Flatten a nested array output. `a.flatten()` ≡ `pipe(a, flatten())`. */
189
172
  flatten(): TypedAction<
190
173
  In,
191
- Out extends (infer TElement)[][] ? TElement[] : Out,
192
- Refs
174
+ Out extends (infer TElement)[][] ? TElement[] : Out
193
175
  >;
194
176
  /** Discard output. `a.drop()` ≡ `pipe(a, drop)`. */
195
- drop(): TypedAction<In, never, Refs>;
177
+ drop(): TypedAction<In, never>;
196
178
  /** Wrap output as a tagged union member. Requires full variant map TDef so __def is carried. */
197
179
  tag<TDef extends Record<string, unknown>, TKind extends keyof TDef & string>(
198
180
  kind: TKind,
199
- ): TypedAction<In, TaggedUnion<TDef>, Refs>;
181
+ ): TypedAction<In, TaggedUnion<TDef>>;
200
182
  /** Extract a field from the output object. `a.get("name")` ≡ `pipe(a, extractField("name"))`. */
201
183
  get<TField extends keyof Out & string>(
202
184
  field: TField,
203
- ): TypedAction<In, Out[TField], Refs>;
185
+ ): TypedAction<In, Out[TField]>;
204
186
  /**
205
187
  * Run this sub-pipeline, then merge its output back into the original input.
206
188
  * `pipe(extractField("x"), transform).augment()` takes `In`, runs the
@@ -209,21 +191,21 @@ export type TypedAction<
209
191
  * Unlike the standalone `augment()` function, the postfix form has access
210
192
  * to `In` so the intersection types correctly.
211
193
  */
212
- augment(): TypedAction<In, In & Out, Refs>;
194
+ augment(): TypedAction<In, In & Out>;
213
195
  /** Merge a tuple of objects into a single object. `a.merge()` ≡ `pipe(a, merge())`. */
214
- merge(): TypedAction<In, MergeTuple<Out>, Refs>;
196
+ merge(): TypedAction<In, MergeTuple<Out>>;
215
197
  /** Select fields from the output. `a.pick("x", "y")` ≡ `pipe(a, pick("x", "y"))`. */
216
198
  pick<TKeys extends (keyof Out & string)[]>(
217
199
  ...keys: TKeys
218
- ): TypedAction<In, Pick<Out, TKeys[number]>, Refs>;
200
+ ): TypedAction<In, Pick<Out, TKeys[number]>>;
219
201
  /**
220
202
  * Transform the Some value inside an Option output. Only callable when
221
203
  * Out is Option<T>. Uses `this` parameter constraint to gate availability.
222
204
  */
223
- mapOption<TIn, T, U, TRefs extends string>(
224
- this: TypedAction<TIn, Option<T>, TRefs>,
205
+ mapOption<TIn, T, U>(
206
+ this: TypedAction<TIn, Option<T>>,
225
207
  action: Pipeable<T, U>,
226
- ): TypedAction<TIn, Option<U>, TRefs>;
208
+ ): TypedAction<TIn, Option<U>>;
227
209
  /**
228
210
  * Transform the Err value of a Result output.
229
211
  * `Result<TValue, TError> → Result<TValue, TErrorOut>`
@@ -231,9 +213,9 @@ export type TypedAction<
231
213
  * Only callable when Out is Result<TValue, TError>.
232
214
  */
233
215
  mapErr<TIn, TValue, TError, TErrorOut>(
234
- this: TypedAction<TIn, Result<TValue, TError>, any>,
216
+ this: TypedAction<TIn, Result<TValue, TError>>,
235
217
  action: Pipeable<TError, TErrorOut>,
236
- ): TypedAction<TIn, Result<TValue, TErrorOut>, Refs>;
218
+ ): TypedAction<TIn, Result<TValue, TErrorOut>>;
237
219
  /**
238
220
  * Unwrap a Result output. If Ok, pass through the value. If Err, apply
239
221
  * the default action. Only callable when Out is Result<TValue, TError>.
@@ -244,15 +226,11 @@ export type TypedAction<
244
226
  *
245
227
  * Uses CaseHandler for defaultAction (covariant output only) so that
246
228
  * `TypedAction<TError, never>` is assignable to `CaseHandler<TError, TValue>`.
247
- *
248
- * Refs position uses `any` in the `this` constraint to avoid TS
249
- * falling back to the constraint bound `string` when Refs = never.
250
- * The return type uses the enclosing TypedAction's `Refs` directly.
251
229
  */
252
230
  unwrapOr<TIn, TValue, TError>(
253
- this: TypedAction<TIn, Result<TValue, TError>, any>,
231
+ this: TypedAction<TIn, Result<TValue, TError>>,
254
232
  defaultAction: CaseHandler<TError, TValue>,
255
- ): TypedAction<TIn, TValue, Refs>;
233
+ ): TypedAction<TIn, TValue>;
256
234
  };
257
235
 
258
236
  /**
@@ -273,16 +251,11 @@ export type TypedAction<
273
251
  * TypedAction (with methods) is assignable to Pipeable because Pipeable
274
252
  * only requires a subset of properties.
275
253
  */
276
- export type Pipeable<
277
- In = unknown,
278
- Out = unknown,
279
- Refs extends string = never,
280
- > = Action & {
254
+ export type Pipeable<In = unknown, Out = unknown> = Action & {
281
255
  __phantom_in?: (input: In) => void;
282
256
  __phantom_out?: () => Out;
283
257
  __phantom_out_check?: (output: Out) => void;
284
258
  __in?: In;
285
- __refs?: { _brand: Refs };
286
259
  };
287
260
 
288
261
  /**
@@ -305,14 +278,9 @@ export type Pipeable<
305
278
  * TypedAction is assignable to CaseHandler because CaseHandler only
306
279
  * requires a subset of TypedAction's phantom fields.
307
280
  */
308
- type CaseHandler<
309
- TIn = unknown,
310
- TOut = unknown,
311
- TRefs extends string = never,
312
- > = Action & {
281
+ export type CaseHandler<TIn = unknown, TOut = unknown> = Action & {
313
282
  __phantom_in?: (input: TIn) => void;
314
283
  __phantom_out?: () => TOut;
315
- __refs?: { _brand: TRefs };
316
284
  };
317
285
 
318
286
  // ---------------------------------------------------------------------------
@@ -390,16 +358,10 @@ type BranchPayload<Out, K extends string> = [ExtractDef<Out>] extends [never]
390
358
  // ---------------------------------------------------------------------------
391
359
 
392
360
  // Shared implementations (one closure, not per-instance)
393
- function thenMethod<
394
- TIn,
395
- TOut,
396
- TRefs extends string,
397
- TNext,
398
- TRefs2 extends string,
399
- >(
400
- this: TypedAction<TIn, TOut, TRefs>,
401
- next: Pipeable<TOut, TNext, TRefs2>,
402
- ): TypedAction<TIn, TNext, TRefs | TRefs2> {
361
+ function thenMethod<TIn, TOut, TNext>(
362
+ this: TypedAction<TIn, TOut>,
363
+ next: Pipeable<TOut, TNext>,
364
+ ): TypedAction<TIn, TNext> {
403
365
  return typedAction({ kind: "Chain", first: this, rest: next as Action });
404
366
  }
405
367
 
@@ -595,11 +557,9 @@ function unwrapOrMethod(this: TypedAction, defaultAction: Action): TypedAction {
595
557
  * Attach `.then()` and `.forEach()` methods to a plain Action object.
596
558
  * Methods are non-enumerable: invisible to JSON.stringify and toEqual.
597
559
  */
598
- export function typedAction<
599
- In = unknown,
600
- Out = unknown,
601
- Refs extends string = never,
602
- >(action: Action): TypedAction<In, Out, Refs> {
560
+ export function typedAction<In = unknown, Out = unknown>(
561
+ action: Action,
562
+ ): TypedAction<In, Out> {
603
563
  if (!("then" in action)) {
604
564
  Object.defineProperties(action, {
605
565
  then: { value: thenMethod, configurable: true },
@@ -617,7 +577,7 @@ export function typedAction<
617
577
  unwrapOr: { value: unwrapOrMethod, configurable: true },
618
578
  });
619
579
  }
620
- return action as TypedAction<In, Out, Refs>;
580
+ return action as TypedAction<In, Out>;
621
581
  }
622
582
 
623
583
  // ---------------------------------------------------------------------------
@@ -663,9 +623,9 @@ import {
663
623
  export { tryCatch } from "./try-catch.js";
664
624
  export { race, sleep, withTimeout } from "./race.js";
665
625
 
666
- export function forEach<In, Out, R extends string = never>(
667
- action: Pipeable<In, Out, R>,
668
- ): TypedAction<In[], Out[], R> {
626
+ export function forEach<In, Out>(
627
+ action: Pipeable<In, Out>,
628
+ ): TypedAction<In[], Out[]> {
669
629
  return typedAction({ kind: "ForEach", action: action as Action });
670
630
  }
671
631
 
@@ -767,9 +727,9 @@ export const IDENTITY: Action = {
767
727
  *
768
728
  * Compiled form: `RestartHandle(id, ExtractIndex(0), body)`
769
729
  */
770
- export function recur<TIn = never, TOut = any, TRefs extends string = never>(
771
- bodyFn: (restart: TypedAction<TIn, never>) => Pipeable<TIn, TOut, TRefs>,
772
- ): TypedAction<PipeIn<TIn>, TOut, TRefs> {
730
+ export function recur<TIn = never, TOut = any>(
731
+ bodyFn: (restart: TypedAction<TIn, never>) => Pipeable<TIn, TOut>,
732
+ ): TypedAction<PipeIn<TIn>, TOut> {
773
733
  const restartHandlerId = allocateRestartHandlerId();
774
734
 
775
735
  const restartAction = typedAction<TIn, never>({
@@ -803,16 +763,11 @@ export function recur<TIn = never, TOut = any, TRefs extends string = never>(
803
763
  * a Branch. earlyReturn tags with Break and performs — the handler restarts
804
764
  * the body, Branch takes the Break path, and the value exits.
805
765
  */
806
- export function earlyReturn<
807
- TEarlyReturn = never,
808
- TIn = any,
809
- TOut = any,
810
- TRefs extends string = never,
811
- >(
766
+ export function earlyReturn<TEarlyReturn = never, TIn = any, TOut = any>(
812
767
  bodyFn: (
813
768
  earlyReturn: TypedAction<TEarlyReturn, never>,
814
- ) => Pipeable<TIn, TOut, TRefs>,
815
- ): TypedAction<TIn, TEarlyReturn | TOut, TRefs> {
769
+ ) => Pipeable<TIn, TOut>,
770
+ ): TypedAction<TIn, TEarlyReturn | TOut> {
816
771
  const restartHandlerId = allocateRestartHandlerId();
817
772
 
818
773
  const earlyReturnAction = typedAction<TEarlyReturn, never>({
@@ -873,12 +828,12 @@ export function buildRestartBranchAction(
873
828
  *
874
829
  * Compiles to `RestartHandle`/`RestartPerform`/Branch — same effect substrate as tryCatch and earlyReturn.
875
830
  */
876
- export function loop<TBreak = never, TIn = never, TRefs extends string = never>(
831
+ export function loop<TBreak = never, TIn = never>(
877
832
  bodyFn: (
878
833
  recur: TypedAction<TIn, never>,
879
834
  done: TypedAction<VoidToNull<TBreak>, never>,
880
- ) => Pipeable<TIn, never, TRefs>,
881
- ): TypedAction<PipeIn<TIn>, VoidToNull<TBreak>, TRefs> {
835
+ ) => Pipeable<TIn, never>,
836
+ ): TypedAction<PipeIn<TIn>, VoidToNull<TBreak>> {
882
837
  const restartHandlerId = allocateRestartHandlerId();
883
838
 
884
839
  const perform: Action = {
package/src/builtins.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  type Action,
3
+ type CaseHandler,
3
4
  type Option as OptionT,
4
5
  type Pipeable,
5
6
  type Result as ResultT,
@@ -148,9 +149,9 @@ export function pick<
148
149
  // DropResult — run an action for side effects, discard its output
149
150
  // ---------------------------------------------------------------------------
150
151
 
151
- export function dropResult<TInput, TOutput, TRefs extends string = never>(
152
- action: Pipeable<TInput, TOutput, TRefs>,
153
- ): TypedAction<TInput, never, TRefs> {
152
+ export function dropResult<TInput, TOutput>(
153
+ action: Pipeable<TInput, TOutput>,
154
+ ): TypedAction<TInput, never> {
154
155
  // Build AST directly — chain inference fails when drop's TValue
155
156
  // isn't constrained by context (resolves to unknown ≠ TOutput).
156
157
  return typedAction({
@@ -259,10 +260,7 @@ export function withResource<
259
260
  export function augment<
260
261
  TInput extends Record<string, unknown>,
261
262
  TOutput extends Record<string, unknown>,
262
- TRefs extends string = never,
263
- >(
264
- action: Pipeable<TInput, TOutput, TRefs>,
265
- ): TypedAction<TInput, TInput & TOutput, TRefs> {
263
+ >(action: Pipeable<TInput, TOutput>): TypedAction<TInput, TInput & TOutput> {
266
264
  // Build AST directly — chain inference fails because [TOutput, TInput]
267
265
  // doesn't match merge()'s Record<string, unknown>[] with invariance.
268
266
  return typedAction({
@@ -294,10 +292,9 @@ export function augment<
294
292
  * Example:
295
293
  * pipe(tap(pipe(pick("worktreePath", "description"), implement)), createPR)
296
294
  */
297
- export function tap<
298
- TInput extends Record<string, unknown>,
299
- TRefs extends string = never,
300
- >(action: Pipeable<TInput, any, TRefs>): TypedAction<TInput, TInput, TRefs> {
295
+ export function tap<TInput extends Record<string, unknown>>(
296
+ action: Pipeable<TInput, any>,
297
+ ): TypedAction<TInput, TInput> {
301
298
  // Build AST directly — internal plumbing (action → constant → augment)
302
299
  // can't go through typed chain/augment with invariant phantom fields.
303
300
  // tap: all(chain(action, constant({})), identity()) → merge
@@ -685,10 +682,7 @@ export const Result = {
685
682
  * Desugars to: `branch({ Ok: identity(), Err: defaultAction })`
686
683
  */
687
684
  unwrapOr<TValue, TError>(
688
- defaultAction: Action & {
689
- __phantom_in?: (input: TError) => void;
690
- __phantom_out?: () => TValue;
691
- },
685
+ defaultAction: CaseHandler<TError, TValue>,
692
686
  ): TypedAction<ResultT<TValue, TError>, TValue> {
693
687
  return typedAction(resultBranch(IDENTITY, defaultAction as Action));
694
688
  },
package/src/chain.ts CHANGED
@@ -5,10 +5,10 @@ import {
5
5
  typedAction,
6
6
  } from "./ast.js";
7
7
 
8
- export function chain<T1, T2, T3, R1 extends string, R2 extends string>(
9
- first: Pipeable<T1, T2, R1>,
10
- rest: Pipeable<T2, T3, R2>,
11
- ): TypedAction<T1, T3, R1 | R2> {
8
+ export function chain<T1, T2, T3>(
9
+ first: Pipeable<T1, T2>,
10
+ rest: Pipeable<T2, T3>,
11
+ ): TypedAction<T1, T3> {
12
12
  return typedAction({
13
13
  kind: "Chain",
14
14
  first: first as Action,
package/src/pipe.ts CHANGED
@@ -7,205 +7,79 @@ import {
7
7
  } from "./ast.js";
8
8
  import { identity } from "./builtins.js";
9
9
 
10
- export function pipe<T1, T2, R1 extends string>(
11
- a1: Pipeable<T1, T2, R1>,
12
- ): TypedAction<PipeIn<T1>, T2, R1>;
13
- export function pipe<T1, T2, T3, R1 extends string, R2 extends string>(
14
- a1: Pipeable<T1, T2, R1>,
15
- a2: Pipeable<T2, T3, R2>,
16
- ): TypedAction<PipeIn<T1>, T3, R1 | R2>;
17
- export function pipe<
18
- T1,
19
- T2,
20
- T3,
21
- T4,
22
- R1 extends string,
23
- R2 extends string,
24
- R3 extends string,
25
- >(
26
- a1: Pipeable<T1, T2, R1>,
27
- a2: Pipeable<T2, T3, R2>,
28
- a3: Pipeable<T3, T4, R3>,
29
- ): TypedAction<PipeIn<T1>, T4, R1 | R2 | R3>;
30
- export function pipe<
31
- T1,
32
- T2,
33
- T3,
34
- T4,
35
- T5,
36
- R1 extends string,
37
- R2 extends string,
38
- R3 extends string,
39
- R4 extends string,
40
- >(
41
- a1: Pipeable<T1, T2, R1>,
42
- a2: Pipeable<T2, T3, R2>,
43
- a3: Pipeable<T3, T4, R3>,
44
- a4: Pipeable<T4, T5, R4>,
45
- ): TypedAction<PipeIn<T1>, T5, R1 | R2 | R3 | R4>;
46
- export function pipe<
47
- T1,
48
- T2,
49
- T3,
50
- T4,
51
- T5,
52
- T6,
53
- R1 extends string,
54
- R2 extends string,
55
- R3 extends string,
56
- R4 extends string,
57
- R5 extends string,
58
- >(
59
- a1: Pipeable<T1, T2, R1>,
60
- a2: Pipeable<T2, T3, R2>,
61
- a3: Pipeable<T3, T4, R3>,
62
- a4: Pipeable<T4, T5, R4>,
63
- a5: Pipeable<T5, T6, R5>,
64
- ): TypedAction<PipeIn<T1>, T6, R1 | R2 | R3 | R4 | R5>;
65
- export function pipe<
66
- T1,
67
- T2,
68
- T3,
69
- T4,
70
- T5,
71
- T6,
72
- T7,
73
- R1 extends string,
74
- R2 extends string,
75
- R3 extends string,
76
- R4 extends string,
77
- R5 extends string,
78
- R6 extends string,
79
- >(
80
- a1: Pipeable<T1, T2, R1>,
81
- a2: Pipeable<T2, T3, R2>,
82
- a3: Pipeable<T3, T4, R3>,
83
- a4: Pipeable<T4, T5, R4>,
84
- a5: Pipeable<T5, T6, R5>,
85
- a6: Pipeable<T6, T7, R6>,
86
- ): TypedAction<PipeIn<T1>, T7, R1 | R2 | R3 | R4 | R5 | R6>;
87
- export function pipe<
88
- T1,
89
- T2,
90
- T3,
91
- T4,
92
- T5,
93
- T6,
94
- T7,
95
- T8,
96
- R1 extends string,
97
- R2 extends string,
98
- R3 extends string,
99
- R4 extends string,
100
- R5 extends string,
101
- R6 extends string,
102
- R7 extends string,
103
- >(
104
- a1: Pipeable<T1, T2, R1>,
105
- a2: Pipeable<T2, T3, R2>,
106
- a3: Pipeable<T3, T4, R3>,
107
- a4: Pipeable<T4, T5, R4>,
108
- a5: Pipeable<T5, T6, R5>,
109
- a6: Pipeable<T6, T7, R6>,
110
- a7: Pipeable<T7, T8, R7>,
111
- ): TypedAction<PipeIn<T1>, T8, R1 | R2 | R3 | R4 | R5 | R6 | R7>;
112
- export function pipe<
113
- T1,
114
- T2,
115
- T3,
116
- T4,
117
- T5,
118
- T6,
119
- T7,
120
- T8,
121
- T9,
122
- R1 extends string,
123
- R2 extends string,
124
- R3 extends string,
125
- R4 extends string,
126
- R5 extends string,
127
- R6 extends string,
128
- R7 extends string,
129
- R8 extends string,
130
- >(
131
- a1: Pipeable<T1, T2, R1>,
132
- a2: Pipeable<T2, T3, R2>,
133
- a3: Pipeable<T3, T4, R3>,
134
- a4: Pipeable<T4, T5, R4>,
135
- a5: Pipeable<T5, T6, R5>,
136
- a6: Pipeable<T6, T7, R6>,
137
- a7: Pipeable<T7, T8, R7>,
138
- a8: Pipeable<T8, T9, R8>,
139
- ): TypedAction<PipeIn<T1>, T9, R1 | R2 | R3 | R4 | R5 | R6 | R7 | R8>;
140
- export function pipe<
141
- T1,
142
- T2,
143
- T3,
144
- T4,
145
- T5,
146
- T6,
147
- T7,
148
- T8,
149
- T9,
150
- T10,
151
- R1 extends string,
152
- R2 extends string,
153
- R3 extends string,
154
- R4 extends string,
155
- R5 extends string,
156
- R6 extends string,
157
- R7 extends string,
158
- R8 extends string,
159
- R9 extends string,
160
- >(
161
- a1: Pipeable<T1, T2, R1>,
162
- a2: Pipeable<T2, T3, R2>,
163
- a3: Pipeable<T3, T4, R3>,
164
- a4: Pipeable<T4, T5, R4>,
165
- a5: Pipeable<T5, T6, R5>,
166
- a6: Pipeable<T6, T7, R6>,
167
- a7: Pipeable<T7, T8, R7>,
168
- a8: Pipeable<T8, T9, R8>,
169
- a9: Pipeable<T9, T10, R9>,
170
- ): TypedAction<PipeIn<T1>, T10, R1 | R2 | R3 | R4 | R5 | R6 | R7 | R8 | R9>;
171
- export function pipe<
172
- T1,
173
- T2,
174
- T3,
175
- T4,
176
- T5,
177
- T6,
178
- T7,
179
- T8,
180
- T9,
181
- T10,
182
- T11,
183
- R1 extends string,
184
- R2 extends string,
185
- R3 extends string,
186
- R4 extends string,
187
- R5 extends string,
188
- R6 extends string,
189
- R7 extends string,
190
- R8 extends string,
191
- R9 extends string,
192
- R10 extends string,
193
- >(
194
- a1: Pipeable<T1, T2, R1>,
195
- a2: Pipeable<T2, T3, R2>,
196
- a3: Pipeable<T3, T4, R3>,
197
- a4: Pipeable<T4, T5, R4>,
198
- a5: Pipeable<T5, T6, R5>,
199
- a6: Pipeable<T6, T7, R6>,
200
- a7: Pipeable<T7, T8, R7>,
201
- a8: Pipeable<T8, T9, R8>,
202
- a9: Pipeable<T9, T10, R9>,
203
- a10: Pipeable<T10, T11, R10>,
204
- ): TypedAction<
205
- PipeIn<T1>,
206
- T11,
207
- R1 | R2 | R3 | R4 | R5 | R6 | R7 | R8 | R9 | R10
208
- >;
10
+ export function pipe<T1, T2>(a1: Pipeable<T1, T2>): TypedAction<PipeIn<T1>, T2>;
11
+ export function pipe<T1, T2, T3>(
12
+ a1: Pipeable<T1, T2>,
13
+ a2: Pipeable<T2, T3>,
14
+ ): TypedAction<PipeIn<T1>, T3>;
15
+ export function pipe<T1, T2, T3, T4>(
16
+ a1: Pipeable<T1, T2>,
17
+ a2: Pipeable<T2, T3>,
18
+ a3: Pipeable<T3, T4>,
19
+ ): TypedAction<PipeIn<T1>, T4>;
20
+ export function pipe<T1, T2, T3, T4, T5>(
21
+ a1: Pipeable<T1, T2>,
22
+ a2: Pipeable<T2, T3>,
23
+ a3: Pipeable<T3, T4>,
24
+ a4: Pipeable<T4, T5>,
25
+ ): TypedAction<PipeIn<T1>, T5>;
26
+ export function pipe<T1, T2, T3, T4, T5, T6>(
27
+ a1: Pipeable<T1, T2>,
28
+ a2: Pipeable<T2, T3>,
29
+ a3: Pipeable<T3, T4>,
30
+ a4: Pipeable<T4, T5>,
31
+ a5: Pipeable<T5, T6>,
32
+ ): TypedAction<PipeIn<T1>, T6>;
33
+ export function pipe<T1, T2, T3, T4, T5, T6, T7>(
34
+ a1: Pipeable<T1, T2>,
35
+ a2: Pipeable<T2, T3>,
36
+ a3: Pipeable<T3, T4>,
37
+ a4: Pipeable<T4, T5>,
38
+ a5: Pipeable<T5, T6>,
39
+ a6: Pipeable<T6, T7>,
40
+ ): TypedAction<PipeIn<T1>, T7>;
41
+ export function pipe<T1, T2, T3, T4, T5, T6, T7, T8>(
42
+ a1: Pipeable<T1, T2>,
43
+ a2: Pipeable<T2, T3>,
44
+ a3: Pipeable<T3, T4>,
45
+ a4: Pipeable<T4, T5>,
46
+ a5: Pipeable<T5, T6>,
47
+ a6: Pipeable<T6, T7>,
48
+ a7: Pipeable<T7, T8>,
49
+ ): TypedAction<PipeIn<T1>, T8>;
50
+ export function pipe<T1, T2, T3, T4, T5, T6, T7, T8, T9>(
51
+ a1: Pipeable<T1, T2>,
52
+ a2: Pipeable<T2, T3>,
53
+ a3: Pipeable<T3, T4>,
54
+ a4: Pipeable<T4, T5>,
55
+ a5: Pipeable<T5, T6>,
56
+ a6: Pipeable<T6, T7>,
57
+ a7: Pipeable<T7, T8>,
58
+ a8: Pipeable<T8, T9>,
59
+ ): TypedAction<PipeIn<T1>, T9>;
60
+ export function pipe<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
61
+ a1: Pipeable<T1, T2>,
62
+ a2: Pipeable<T2, T3>,
63
+ a3: Pipeable<T3, T4>,
64
+ a4: Pipeable<T4, T5>,
65
+ a5: Pipeable<T5, T6>,
66
+ a6: Pipeable<T6, T7>,
67
+ a7: Pipeable<T7, T8>,
68
+ a8: Pipeable<T8, T9>,
69
+ a9: Pipeable<T9, T10>,
70
+ ): TypedAction<PipeIn<T1>, T10>;
71
+ export function pipe<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(
72
+ a1: Pipeable<T1, T2>,
73
+ a2: Pipeable<T2, T3>,
74
+ a3: Pipeable<T3, T4>,
75
+ a4: Pipeable<T4, T5>,
76
+ a5: Pipeable<T5, T6>,
77
+ a6: Pipeable<T6, T7>,
78
+ a7: Pipeable<T7, T8>,
79
+ a8: Pipeable<T8, T9>,
80
+ a9: Pipeable<T9, T10>,
81
+ a10: Pipeable<T10, T11>,
82
+ ): TypedAction<PipeIn<T1>, T11>;
209
83
  export function pipe(...actions: Action[]): Action {
210
84
  if (actions.length === 0) {
211
85
  return identity;