@fncts/typelevel 0.0.1

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.
Files changed (85) hide show
  1. package/Any.d.ts +48 -0
  2. package/Boolean.d.ts +39 -0
  3. package/BuiltIn.d.ts +3 -0
  4. package/Check.d.ts +70 -0
  5. package/Function.d.ts +11 -0
  6. package/HKT.d.ts +186 -0
  7. package/Intersection.d.ts +1 -0
  8. package/Iteration.d.ts +216 -0
  9. package/List.d.ts +15 -0
  10. package/Number.d.ts +56 -0
  11. package/Object.d.ts +118 -0
  12. package/String.d.ts +8 -0
  13. package/Union.d.ts +23 -0
  14. package/_cjs/Any.cjs +6 -0
  15. package/_cjs/Any.cjs.map +1 -0
  16. package/_cjs/Boolean.cjs +6 -0
  17. package/_cjs/Boolean.cjs.map +1 -0
  18. package/_cjs/BuiltIn.cjs +6 -0
  19. package/_cjs/BuiltIn.cjs.map +1 -0
  20. package/_cjs/Check.cjs +6 -0
  21. package/_cjs/Check.cjs.map +1 -0
  22. package/_cjs/Function.cjs +6 -0
  23. package/_cjs/Function.cjs.map +1 -0
  24. package/_cjs/HKT.cjs +26 -0
  25. package/_cjs/HKT.cjs.map +1 -0
  26. package/_cjs/Intersection.cjs +6 -0
  27. package/_cjs/Intersection.cjs.map +1 -0
  28. package/_cjs/Iteration.cjs +6 -0
  29. package/_cjs/Iteration.cjs.map +1 -0
  30. package/_cjs/List.cjs +6 -0
  31. package/_cjs/List.cjs.map +1 -0
  32. package/_cjs/Number.cjs +6 -0
  33. package/_cjs/Number.cjs.map +1 -0
  34. package/_cjs/Object.cjs +6 -0
  35. package/_cjs/Object.cjs.map +1 -0
  36. package/_cjs/String.cjs +6 -0
  37. package/_cjs/String.cjs.map +1 -0
  38. package/_cjs/Union.cjs +6 -0
  39. package/_cjs/Union.cjs.map +1 -0
  40. package/_cjs/index.cjs +51 -0
  41. package/_cjs/index.cjs.map +1 -0
  42. package/_mjs/Any.mjs +2 -0
  43. package/_mjs/Any.mjs.map +1 -0
  44. package/_mjs/Boolean.mjs +2 -0
  45. package/_mjs/Boolean.mjs.map +1 -0
  46. package/_mjs/BuiltIn.mjs +2 -0
  47. package/_mjs/BuiltIn.mjs.map +1 -0
  48. package/_mjs/Check.mjs +2 -0
  49. package/_mjs/Check.mjs.map +1 -0
  50. package/_mjs/Function.mjs +2 -0
  51. package/_mjs/Function.mjs.map +1 -0
  52. package/_mjs/HKT.mjs +19 -0
  53. package/_mjs/HKT.mjs.map +1 -0
  54. package/_mjs/Intersection.mjs +2 -0
  55. package/_mjs/Intersection.mjs.map +1 -0
  56. package/_mjs/Iteration.mjs +2 -0
  57. package/_mjs/Iteration.mjs.map +1 -0
  58. package/_mjs/List.mjs +2 -0
  59. package/_mjs/List.mjs.map +1 -0
  60. package/_mjs/Number.mjs +2 -0
  61. package/_mjs/Number.mjs.map +1 -0
  62. package/_mjs/Object.mjs +2 -0
  63. package/_mjs/Object.mjs.map +1 -0
  64. package/_mjs/String.mjs +2 -0
  65. package/_mjs/String.mjs.map +1 -0
  66. package/_mjs/Union.mjs +2 -0
  67. package/_mjs/Union.mjs.map +1 -0
  68. package/_mjs/index.mjs +21 -0
  69. package/_mjs/index.mjs.map +1 -0
  70. package/_src/Any.ts +100 -0
  71. package/_src/Boolean.ts +44 -0
  72. package/_src/BuiltIn.ts +7 -0
  73. package/_src/Check.ts +89 -0
  74. package/_src/Function.ts +24 -0
  75. package/_src/HKT.ts +349 -0
  76. package/_src/Intersection.ts +1 -0
  77. package/_src/Iteration.ts +224 -0
  78. package/_src/List.ts +47 -0
  79. package/_src/Number.ts +137 -0
  80. package/_src/Object.ts +332 -0
  81. package/_src/String.ts +28 -0
  82. package/_src/Union.ts +47 -0
  83. package/_src/index.ts +11 -0
  84. package/index.d.ts +11 -0
  85. package/package.json +13 -0
package/_src/Any.ts ADDED
@@ -0,0 +1,100 @@
1
+ import type { Boolean, False, True } from "./Boolean.js";
2
+ import type { BuiltIn } from "./BuiltIn.js";
3
+ import type { List } from "./List.js";
4
+ import type { Has } from "./Union.js";
5
+
6
+ export type Cast<A, B> = A extends B ? A : B;
7
+
8
+ export type Try<A1 , A2 , Catch = never> =
9
+ A1 extends A2
10
+ ? A1
11
+ : Catch;
12
+
13
+ export type Extends<A, B> = [A] extends [never] ? False : A extends B ? True : False;
14
+
15
+ export type Contains<A, B> = Extends<A, B> extends True ? True : False;
16
+
17
+ export type Equals<A, B> = (<X>() => X extends B ? True : False) extends <X>() => X extends A ? True : False
18
+ ? True
19
+ : False;
20
+
21
+ export type If<B extends Boolean, Then, Else = never> = B extends True ? Then : Else;
22
+
23
+ export type Match =
24
+ | "default"
25
+ // Extends<A, B>
26
+ | "extends->"
27
+ // Contains<A, B>
28
+ | "contains->"
29
+ // Equals<A, B>
30
+ | "equals"
31
+ // Extends<B, A>
32
+ | "<-extends"
33
+ // Contains<B, A>
34
+ | "<-contains";
35
+
36
+ export type Is<A, B, _ extends Match> = {
37
+ default: Extends<A, B>;
38
+ "extends->": Extends<A, B>;
39
+ "contains->": Contains<A, B>;
40
+ "<-extends": Extends<B, A>;
41
+ "<-contains": Contains<B, A>;
42
+ equals: Equals<A, B>;
43
+ }[_];
44
+
45
+ export type Key = string | number | symbol;
46
+
47
+ export type Literal = string | number | bigint | boolean;
48
+
49
+ export type Keys<A> = A extends List ? Exclude<keyof A, keyof any[]> | number : keyof A;
50
+
51
+ export type KnownKeys<A> = {
52
+ [K in keyof A]: string extends K ? never : number extends K ? never : K;
53
+ } extends {
54
+ [K in keyof A]: infer U;
55
+ }
56
+ ? U & Keys<A>
57
+ : never;
58
+
59
+ export type ComputeRaw<A> = A extends Function ? A : { [K in keyof A]: A[K] } & unknown;
60
+
61
+ export type ComputeFlat<A> = A extends BuiltIn
62
+ ? A
63
+ : A extends Array<any>
64
+ ? A extends Array<Record<Key, any>>
65
+ ? Array<{ [K in keyof A[number]]: A[number][K] } & unknown>
66
+ : A
67
+ : A extends ReadonlyArray<any>
68
+ ? A extends ReadonlyArray<Record<Key, any>>
69
+ ? ReadonlyArray<{ [K in keyof A[number]]: A[number][K] } & unknown>
70
+ : A
71
+ : { [K in keyof A]: A[K] } & unknown;
72
+
73
+ export type ComputeDeep<A, Seen = never> = A extends BuiltIn
74
+ ? A
75
+ : {
76
+ [False]: A extends Array<any>
77
+ ? A extends Array<Record<Key, any>>
78
+ ? Array<{ [K in keyof A[number]]: ComputeDeep<A[number][K], A | Seen> } & unknown>
79
+ : A
80
+ : A extends ReadonlyArray<any>
81
+ ? A extends ReadonlyArray<Record<Key, any>>
82
+ ? ReadonlyArray<{ [K in keyof A[number]]: ComputeDeep<A[number][K], A | Seen> } & unknown>
83
+ : A
84
+ : { [K in keyof A]: ComputeDeep<A[K], A | Seen> } & unknown;
85
+ [True]: A;
86
+ }[Has<Seen, A>];
87
+
88
+ export type At<A, K extends Key> = A extends List
89
+ ? number extends A["length"]
90
+ ? K extends number | `${number}`
91
+ ? A[never] | undefined
92
+ : undefined
93
+ : K extends keyof A
94
+ ? A[K]
95
+ : undefined
96
+ : unknown extends A
97
+ ? unknown
98
+ : K extends keyof A
99
+ ? A[K]
100
+ : undefined;
@@ -0,0 +1,44 @@
1
+ export declare const False: unique symbol;
2
+ export declare const True: unique symbol;
3
+
4
+ export type False = typeof False;
5
+ export type True = typeof True;
6
+ export type Boolean = True | False;
7
+
8
+ export type Or<B1 extends Boolean, B2 extends Boolean> = {
9
+ [False]: {
10
+ [False]: False;
11
+ [True]: True;
12
+ };
13
+ [True]: {
14
+ [False]: True;
15
+ [True]: True;
16
+ };
17
+ }[B1][B2];
18
+
19
+ export type And<B1 extends Boolean, B2 extends Boolean> = {
20
+ [False]: {
21
+ [False]: False,
22
+ [True]: False
23
+ },
24
+ [True]: {
25
+ [False]: False,
26
+ [True]: True
27
+ }
28
+ }[B1][B2];
29
+
30
+ export type Xor<B1 extends Boolean, B2 extends Boolean> = {
31
+ [False]: {
32
+ [False]: False,
33
+ [True]: True
34
+ },
35
+ [True]: {
36
+ [False]: True,
37
+ [True]: False
38
+ }
39
+ }[B1][B2];
40
+
41
+ export type Not<B extends Boolean> = {
42
+ [False]: True,
43
+ [True]: False
44
+ }[B];
@@ -0,0 +1,7 @@
1
+ export type BuiltIn =
2
+ | Function
3
+ | Error
4
+ | Date
5
+ | { readonly [Symbol.toStringTag]: string }
6
+ | RegExp
7
+ | Generator;
package/_src/Check.ts ADDED
@@ -0,0 +1,89 @@
1
+ import type { False, True } from "./Boolean.js";
2
+ import type * as Union from "./Union.js";
3
+
4
+ type EqualsWrapped<T> = T extends infer R & {}
5
+ ? {
6
+ [P in keyof R]: R[P];
7
+ }
8
+ : never;
9
+
10
+ /**
11
+ * @tsplus type fncts.Check
12
+ */
13
+ export type Check<Condition> = [Condition] extends [never] ? Check.False : Check.True;
14
+
15
+ export declare namespace Check {
16
+ /**
17
+ * @tsplus type fncts.Check.True
18
+ */
19
+ type True = typeof True;
20
+
21
+ /**
22
+ * @tsplus type fncts.Check.False
23
+ */
24
+ type False = typeof False;
25
+
26
+ /**
27
+ * @tsplus type fncts.Check.Result
28
+ */
29
+ type Result = True | False;
30
+
31
+ /**
32
+ * @tsplus type fncts.Check.Not
33
+ */
34
+ type Not<A> = [A] extends [never] ? unknown : never;
35
+
36
+ /**
37
+ * @tsplus type fncts.Check.Extends
38
+ */
39
+ type Extends<A, B> = [A] extends [never] ? never : [A] extends [B] ? unknown : never;
40
+
41
+ /**
42
+ * @tsplus type fncts.Check.IsUnion
43
+ */
44
+ type IsUnion<T> = [T] extends [Union.IntersectionOf<T>] ? never : unknown;
45
+
46
+ /**
47
+ * @tsplus type fncts.Check.IsEqual
48
+ */
49
+ type IsEqual<A, B> = (<T>() => T extends EqualsWrapped<A> ? 1 : 2) extends <
50
+ T,
51
+ >() => T extends EqualsWrapped<B> ? 1 : 2
52
+ ? unknown
53
+ : never;
54
+
55
+ /**
56
+ * @tsplus type fncts.Check.IsLiteral
57
+ */
58
+ type IsLiteral<A extends string | number> = Not<Extends<string, A> | Extends<number, A>>;
59
+
60
+ /**
61
+ * @tsplus type fncts.Check.IsStruct
62
+ */
63
+ type IsStruct<A> = Extends<keyof A, string> & Not<IsUnion<A>>;
64
+
65
+ /**
66
+ * @tsplus type fncts.Check.HaveSameLength
67
+ */
68
+ type HaveSameLength<A extends { length: number }, B extends { length: number }> = IsEqual<
69
+ A["length"],
70
+ B["length"]
71
+ >;
72
+
73
+ /**
74
+ * @tsplus type fncts.Check.IsTagged
75
+ */
76
+ type IsTagged<Tag extends PropertyKey, A extends { [k in Tag]: string }> = IsUnion<A[Tag]> &
77
+ IsUnion<A> &
78
+ HaveSameLength<Union.ListOf<A[Tag]>, Union.ListOf<A>>;
79
+
80
+ /**
81
+ * @tsplus type fncts.Check.If
82
+ */
83
+ type If<B, Then, Else = never> = B extends never ? Else : Then;
84
+
85
+ /**
86
+ * @tsplus type fncts.Check.Or
87
+ */
88
+ type Or<A, B> = A extends never ? B : A;
89
+ }
@@ -0,0 +1,24 @@
1
+ import type { Try } from "@fncts/typelevel/Any";
2
+
3
+ export type Narrowable = string | number | boolean | bigint;
4
+
5
+ export type Exact<A, B> = B extends unknown
6
+ ? A extends B
7
+ ? A extends Narrowable
8
+ ? A
9
+ : {
10
+ [K in keyof A]: K extends keyof B ? Exact<A[K], B[K]> : never;
11
+ }
12
+ : B
13
+ : never;
14
+
15
+ export type NoInfer<A> = [A][A extends any ? 0 : never];
16
+
17
+ type NarrowRaw<A> =
18
+ | (A extends [] ? [] : never)
19
+ | (A extends Narrowable ? A : never)
20
+ | {
21
+ [K in keyof A]: A[K] extends Function ? A[K] : NarrowRaw<A[K]>;
22
+ };
23
+
24
+ export type Narrow<A> = Try<A, [], NarrowRaw<A>>;
package/_src/HKT.ts ADDED
@@ -0,0 +1,349 @@
1
+ import type * as Union from "./Union.js";
2
+
3
+ export interface HKT {
4
+ readonly K?: unknown;
5
+ readonly Q?: unknown;
6
+ readonly W?: unknown;
7
+ readonly X?: unknown;
8
+ readonly I?: unknown;
9
+ readonly S?: unknown;
10
+ readonly R?: unknown;
11
+ readonly E?: unknown;
12
+ readonly A?: unknown;
13
+ readonly type?: unknown;
14
+
15
+ readonly index?: unknown;
16
+
17
+ readonly variance: {
18
+ readonly K?: HKT.Variance;
19
+ readonly Q?: HKT.Variance;
20
+ readonly W?: HKT.Variance;
21
+ readonly X?: HKT.Variance;
22
+ readonly I?: HKT.Variance;
23
+ readonly S?: HKT.Variance;
24
+ readonly R?: HKT.Variance;
25
+ readonly E?: HKT.Variance;
26
+ readonly A?: HKT.Variance;
27
+ };
28
+ }
29
+
30
+ // eslint-disable-next-line @typescript-eslint/no-namespace
31
+ export namespace HKT {
32
+ declare const URI: unique symbol;
33
+ declare const CURI: unique symbol;
34
+
35
+ export type Variance = "-" | "+" | "_";
36
+
37
+ export type VarianceOf<F extends HKT, N extends ParamName> = F["variance"][N];
38
+
39
+ export type CovariantE = HKT & {
40
+ readonly variance: {
41
+ E: "+";
42
+ };
43
+ };
44
+
45
+ export type ContravariantR = HKT & {
46
+ readonly variance: {
47
+ R: "-";
48
+ };
49
+ };
50
+
51
+ export interface Typeclass<F extends HKT, C = None> {
52
+ readonly [URI]: F;
53
+ readonly [CURI]: C;
54
+ }
55
+
56
+ export interface Typeclass2<F extends HKT, G extends HKT, C = None, D = None> {
57
+ readonly _F: F;
58
+ readonly _G: G;
59
+ readonly _CF: C;
60
+ readonly _CG: D;
61
+ }
62
+
63
+ export interface Compose2<F extends HKT, G extends HKT, C = None, D = None> extends HKT {
64
+ readonly type: Kind<
65
+ F,
66
+ C,
67
+ this["K"],
68
+ this["Q"],
69
+ this["W"],
70
+ this["X"],
71
+ this["I"],
72
+ this["S"],
73
+ this["R"],
74
+ this["E"],
75
+ Kind<
76
+ G,
77
+ D,
78
+ this["K"],
79
+ this["Q"],
80
+ this["W"],
81
+ this["X"],
82
+ this["I"],
83
+ this["S"],
84
+ this["R"],
85
+ this["E"],
86
+ this["A"]
87
+ >
88
+ >;
89
+ }
90
+
91
+ export interface FK<F, K, Q, W, X, I, S, R, E, A> {
92
+ readonly _F: F;
93
+ readonly _K: K;
94
+ readonly _Q: Q;
95
+ readonly _W: W;
96
+ readonly _X: X;
97
+ readonly _I: I;
98
+ readonly _S: S;
99
+ readonly _R: R;
100
+ readonly _E: E;
101
+ readonly _A: A;
102
+ }
103
+
104
+ export interface FK1<F, A> {
105
+ readonly _F: F;
106
+ readonly _K: unknown;
107
+ readonly _Q: unknown;
108
+ readonly _W: unknown;
109
+ readonly _X: unknown;
110
+ readonly _I: unknown;
111
+ readonly _S: unknown;
112
+ readonly _R: unknown;
113
+ readonly _E: unknown;
114
+ readonly _A: A;
115
+ }
116
+
117
+ export interface F<F> extends HKT {
118
+ readonly type: FK<
119
+ F,
120
+ this["K"],
121
+ this["Q"],
122
+ this["W"],
123
+ this["X"],
124
+ this["I"],
125
+ this["S"],
126
+ this["R"],
127
+ this["E"],
128
+ this["A"]
129
+ >;
130
+ readonly variance: {
131
+ readonly K: "_";
132
+ readonly Q: "_";
133
+ readonly W: "_";
134
+ readonly X: "_";
135
+ readonly I: "_";
136
+ readonly S: "_";
137
+ readonly R: "_";
138
+ readonly E: "_";
139
+ readonly A: "_";
140
+ };
141
+ }
142
+
143
+ export interface FCoE<F> extends HKT {
144
+ readonly type: FK<
145
+ F,
146
+ this["K"],
147
+ this["Q"],
148
+ this["W"],
149
+ this["X"],
150
+ this["I"],
151
+ this["S"],
152
+ this["R"],
153
+ this["E"],
154
+ this["A"]
155
+ >;
156
+ readonly variance: {
157
+ readonly K: "_";
158
+ readonly Q: "_";
159
+ readonly W: "_";
160
+ readonly X: "_";
161
+ readonly I: "_";
162
+ readonly S: "_";
163
+ readonly R: "_";
164
+ readonly E: "+";
165
+ readonly A: "_";
166
+ };
167
+ }
168
+
169
+ export interface FContraR<F> extends HKT {
170
+ readonly type: FK<
171
+ F,
172
+ this["K"],
173
+ this["Q"],
174
+ this["W"],
175
+ this["X"],
176
+ this["I"],
177
+ this["S"],
178
+ this["R"],
179
+ this["E"],
180
+ this["A"]
181
+ >;
182
+ readonly variance: {
183
+ readonly K: "_";
184
+ readonly Q: "_";
185
+ readonly W: "_";
186
+ readonly X: "_";
187
+ readonly I: "_";
188
+ readonly S: "_";
189
+ readonly R: "-";
190
+ readonly E: "_";
191
+ readonly A: "_";
192
+ };
193
+ }
194
+
195
+ export type ParamName = "K" | "Q" | "W" | "X" | "I" | "S" | "R" | "E" | "A";
196
+
197
+ export type Kind<F extends HKT, C, K, Q, W, X, I, S, R, E, A> = F extends {
198
+ readonly type: unknown;
199
+ }
200
+ ? (F & {
201
+ readonly K: OrFix<C, "K", K>;
202
+ readonly Q: OrFix<C, "Q", Q>;
203
+ readonly W: OrFix<C, "W", W>;
204
+ readonly X: OrFix<C, "X", X>;
205
+ readonly I: OrFix<C, "I", I>;
206
+ readonly S: OrFix<C, "S", S>;
207
+ readonly R: OrFix<C, "R", R>;
208
+ readonly E: OrFix<C, "E", E>;
209
+ readonly A: A;
210
+ })["type"]
211
+ : FK<F, K, Q, W, X, I, S, R, E, A>;
212
+
213
+ export type Infer<F extends HKT, C, N extends ParamName | "C", K> = [K] extends [
214
+ Kind<F, C, infer K, infer Q, infer W, infer X, infer I, infer S, infer R, infer E, infer A>,
215
+ ]
216
+ ? N extends "C"
217
+ ? C
218
+ : N extends "K"
219
+ ? K
220
+ : N extends "Q"
221
+ ? Q
222
+ : N extends "W"
223
+ ? W
224
+ : N extends "X"
225
+ ? X
226
+ : N extends "I"
227
+ ? I
228
+ : N extends "S"
229
+ ? S
230
+ : N extends "R"
231
+ ? R
232
+ : N extends "E"
233
+ ? E
234
+ : N extends "A"
235
+ ? A
236
+ : never
237
+ : never;
238
+
239
+ /*
240
+ * Lower bounds for variance
241
+ */
242
+
243
+ export interface Lows {
244
+ "-": unknown;
245
+ "+": never;
246
+ _: any;
247
+ }
248
+
249
+ export type Low<F extends HKT, N extends ParamName> = F["variance"][N] extends Variance
250
+ ? Lows[F["variance"][N]]
251
+ : never;
252
+
253
+ /*
254
+ * Type mixing for variance
255
+ */
256
+
257
+ export interface Mixes<P extends ReadonlyArray<unknown>> {
258
+ "-": P extends [any]
259
+ ? P[0]
260
+ : P extends [any, any]
261
+ ? P[0] & P[1]
262
+ : P extends [any, any, any]
263
+ ? P[0] & P[1] & P[2]
264
+ : P extends [any, any, any, any]
265
+ ? P[0] & P[1] & P[2] & P[3]
266
+ : P extends [any, any, any, any, any]
267
+ ? P[0] & P[1] & P[2] & P[3] & P[4]
268
+ : Union.IntersectionOf<P[number]>;
269
+ "+": P[number];
270
+ _: P[0];
271
+ }
272
+ export type Mix<
273
+ F extends HKT,
274
+ N extends ParamName,
275
+ P extends ReadonlyArray<unknown>,
276
+ > = F["variance"][N] extends Variance ? Mixes<P>[F["variance"][N]] : P[0];
277
+
278
+ export type OrNever<K> = unknown extends K ? never : K;
279
+
280
+ export type MixStruct<F extends HKT, N extends ParamName, X, Y> = F["variance"][N] extends "_"
281
+ ? X
282
+ : F["variance"][N] extends "+"
283
+ ? Y[keyof Y]
284
+ : F["variance"][N] extends "-"
285
+ ? Union.IntersectionOf<{ [k in keyof Y]: OrNever<Y[k]> }[keyof Y]>
286
+ : X;
287
+
288
+ export interface Intros<A, B> {
289
+ "-": B;
290
+ "+": B;
291
+ _: A;
292
+ }
293
+
294
+ /*
295
+ * Type introduction for variance
296
+ */
297
+
298
+ export type Intro<F extends HKT, N extends ParamName, A, B> = F["variance"][N] extends Variance
299
+ ? Intros<A, B>[F["variance"][N]]
300
+ : A;
301
+
302
+ /**
303
+ * Type parameter constraint
304
+ */
305
+
306
+ export type None = {};
307
+
308
+ declare const Fix: unique symbol;
309
+
310
+ export interface Fix<N extends ParamName, A> {
311
+ [Fix]: {
312
+ [K in N]: () => A;
313
+ };
314
+ }
315
+
316
+ declare const Extend: unique symbol;
317
+
318
+ export interface Extend<N extends ParamName, A> {
319
+ [Extend]: {
320
+ [K in N]: () => A;
321
+ };
322
+ }
323
+
324
+ export type OrFix<C, N extends ParamName, A> = C extends Fix<N, infer X> ? X : A;
325
+
326
+ export type OrExtend<C, N extends ParamName, A> = C extends Extend<N, infer X>
327
+ ? A extends X
328
+ ? A
329
+ : X
330
+ : A;
331
+
332
+ export type GetExtends<C, N extends ParamName, A> = C extends Extend<N, infer X> ? X : A;
333
+
334
+ export type IndexFor<F extends HKT, K> = F extends { readonly index: unknown } ? F["index"] : K;
335
+
336
+ /*
337
+ * Instance util
338
+ */
339
+
340
+ /**
341
+ * @tsplus macro identity
342
+ */
343
+ export function instance<F>(
344
+ _: Omit<F, typeof URI | typeof CURI | "_F" | "_G" | "_CF" | "_CG">,
345
+ ): F {
346
+ // @ts-expect-error: typelevel utility
347
+ return _;
348
+ }
349
+ }
@@ -0,0 +1 @@
1
+ export type Erase<A, B> = A & B extends B & infer C ? C : A;