effect 3.11.8 → 3.11.10

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 (124) hide show
  1. package/dist/cjs/Effect.js +1685 -293
  2. package/dist/cjs/Effect.js.map +1 -1
  3. package/dist/cjs/FiberHandle.js +1 -5
  4. package/dist/cjs/FiberHandle.js.map +1 -1
  5. package/dist/cjs/FiberMap.js +1 -5
  6. package/dist/cjs/FiberMap.js.map +1 -1
  7. package/dist/cjs/FiberSet.js +2 -2
  8. package/dist/cjs/FiberSet.js.map +1 -1
  9. package/dist/cjs/JSONSchema.js +3 -30
  10. package/dist/cjs/JSONSchema.js.map +1 -1
  11. package/dist/cjs/Micro.js +1 -1
  12. package/dist/cjs/Option.js +1 -1
  13. package/dist/cjs/ParseResult.js +15 -2
  14. package/dist/cjs/ParseResult.js.map +1 -1
  15. package/dist/cjs/Schema.js +333 -231
  16. package/dist/cjs/Schema.js.map +1 -1
  17. package/dist/cjs/SchemaAST.js +99 -59
  18. package/dist/cjs/SchemaAST.js.map +1 -1
  19. package/dist/cjs/Stream.js +6 -5
  20. package/dist/cjs/Stream.js.map +1 -1
  21. package/dist/cjs/internal/core-effect.js +4 -4
  22. package/dist/cjs/internal/core-effect.js.map +1 -1
  23. package/dist/cjs/internal/core.js +4 -5
  24. package/dist/cjs/internal/core.js.map +1 -1
  25. package/dist/cjs/internal/doNotation.js.map +1 -1
  26. package/dist/cjs/internal/fiberRuntime.js +5 -5
  27. package/dist/cjs/internal/fiberRuntime.js.map +1 -1
  28. package/dist/cjs/internal/mailbox.js.map +1 -1
  29. package/dist/cjs/internal/redacted.js +1 -1
  30. package/dist/cjs/internal/redacted.js.map +1 -1
  31. package/dist/cjs/internal/runtime.js +1 -1
  32. package/dist/cjs/internal/runtime.js.map +1 -1
  33. package/dist/cjs/internal/schema/errors.js +10 -10
  34. package/dist/cjs/internal/schema/errors.js.map +1 -1
  35. package/dist/cjs/internal/schema/util.js +2 -2
  36. package/dist/cjs/internal/schema/util.js.map +1 -1
  37. package/dist/cjs/internal/stm/core.js +2 -3
  38. package/dist/cjs/internal/stm/core.js.map +1 -1
  39. package/dist/cjs/internal/version.js +1 -1
  40. package/dist/cjs/internal/version.js.map +1 -1
  41. package/dist/dts/Effect.d.ts +12053 -8146
  42. package/dist/dts/Effect.d.ts.map +1 -1
  43. package/dist/dts/FiberHandle.d.ts +2 -2
  44. package/dist/dts/FiberHandle.d.ts.map +1 -1
  45. package/dist/dts/FiberMap.d.ts +2 -2
  46. package/dist/dts/FiberMap.d.ts.map +1 -1
  47. package/dist/dts/FiberSet.d.ts +3 -6
  48. package/dist/dts/FiberSet.d.ts.map +1 -1
  49. package/dist/dts/Option.d.ts +1 -1
  50. package/dist/dts/ParseResult.d.ts.map +1 -1
  51. package/dist/dts/Schema.d.ts +18 -8
  52. package/dist/dts/Schema.d.ts.map +1 -1
  53. package/dist/dts/SchemaAST.d.ts +9 -1
  54. package/dist/dts/SchemaAST.d.ts.map +1 -1
  55. package/dist/dts/Stream.d.ts +6 -5
  56. package/dist/dts/Stream.d.ts.map +1 -1
  57. package/dist/dts/internal/core-effect.d.ts.map +1 -1
  58. package/dist/dts/internal/core.d.ts.map +1 -1
  59. package/dist/dts/internal/fiberRuntime.d.ts.map +1 -1
  60. package/dist/esm/Effect.js +1734 -294
  61. package/dist/esm/Effect.js.map +1 -1
  62. package/dist/esm/FiberHandle.js +1 -4
  63. package/dist/esm/FiberHandle.js.map +1 -1
  64. package/dist/esm/FiberMap.js +1 -4
  65. package/dist/esm/FiberMap.js.map +1 -1
  66. package/dist/esm/FiberSet.js +2 -2
  67. package/dist/esm/FiberSet.js.map +1 -1
  68. package/dist/esm/JSONSchema.js +3 -30
  69. package/dist/esm/JSONSchema.js.map +1 -1
  70. package/dist/esm/Micro.js +1 -1
  71. package/dist/esm/Micro.js.map +1 -1
  72. package/dist/esm/Option.js +1 -1
  73. package/dist/esm/ParseResult.js +12 -1
  74. package/dist/esm/ParseResult.js.map +1 -1
  75. package/dist/esm/Schema.js +328 -226
  76. package/dist/esm/Schema.js.map +1 -1
  77. package/dist/esm/SchemaAST.js +96 -57
  78. package/dist/esm/SchemaAST.js.map +1 -1
  79. package/dist/esm/Stream.js +6 -5
  80. package/dist/esm/Stream.js.map +1 -1
  81. package/dist/esm/internal/core-effect.js +4 -4
  82. package/dist/esm/internal/core-effect.js.map +1 -1
  83. package/dist/esm/internal/core.js +1 -2
  84. package/dist/esm/internal/core.js.map +1 -1
  85. package/dist/esm/internal/doNotation.js.map +1 -1
  86. package/dist/esm/internal/fiberRuntime.js +5 -5
  87. package/dist/esm/internal/fiberRuntime.js.map +1 -1
  88. package/dist/esm/internal/mailbox.js.map +1 -1
  89. package/dist/esm/internal/redacted.js +1 -1
  90. package/dist/esm/internal/redacted.js.map +1 -1
  91. package/dist/esm/internal/runtime.js +1 -1
  92. package/dist/esm/internal/runtime.js.map +1 -1
  93. package/dist/esm/internal/schema/errors.js +5 -5
  94. package/dist/esm/internal/schema/errors.js.map +1 -1
  95. package/dist/esm/internal/schema/util.js +2 -2
  96. package/dist/esm/internal/schema/util.js.map +1 -1
  97. package/dist/esm/internal/stm/core.js +1 -2
  98. package/dist/esm/internal/stm/core.js.map +1 -1
  99. package/dist/esm/internal/version.js +1 -1
  100. package/dist/esm/internal/version.js.map +1 -1
  101. package/package.json +1 -1
  102. package/src/Effect.ts +7191 -3280
  103. package/src/FiberHandle.ts +2 -2
  104. package/src/FiberMap.ts +2 -2
  105. package/src/FiberSet.ts +3 -3
  106. package/src/JSONSchema.ts +3 -29
  107. package/src/Micro.ts +1 -1
  108. package/src/Option.ts +1 -1
  109. package/src/ParseResult.ts +19 -3
  110. package/src/Schema.ts +268 -184
  111. package/src/SchemaAST.ts +117 -62
  112. package/src/Stream.ts +6 -5
  113. package/src/internal/core-effect.ts +13 -10
  114. package/src/internal/core.ts +1 -2
  115. package/src/internal/doNotation.ts +1 -1
  116. package/src/internal/fiberRuntime.ts +15 -15
  117. package/src/internal/mailbox.ts +1 -1
  118. package/src/internal/pool.ts +1 -1
  119. package/src/internal/redacted.ts +1 -1
  120. package/src/internal/runtime.ts +1 -1
  121. package/src/internal/schema/errors.ts +6 -5
  122. package/src/internal/schema/util.ts +2 -2
  123. package/src/internal/stm/core.ts +1 -2
  124. package/src/internal/version.ts +1 -1
package/src/SchemaAST.ts CHANGED
@@ -1096,7 +1096,7 @@ export class Enums implements Annotated {
1096
1096
  */
1097
1097
  export const isEnums: (ast: AST) => ast is Enums = createASTGuard("Enums")
1098
1098
 
1099
- type TemplateLiteralSpanBaseType = StringKeyword | NumberKeyword | Literal
1099
+ type TemplateLiteralSpanBaseType = StringKeyword | NumberKeyword | Literal | TemplateLiteral
1100
1100
 
1101
1101
  type TemplateLiteralSpanType = TemplateLiteralSpanBaseType | Union<TemplateLiteralSpanType>
1102
1102
 
@@ -1105,6 +1105,7 @@ const isTemplateLiteralSpanType = (ast: AST): ast is TemplateLiteralSpanType =>
1105
1105
  case "Literal":
1106
1106
  case "NumberKeyword":
1107
1107
  case "StringKeyword":
1108
+ case "TemplateLiteral":
1108
1109
  return true
1109
1110
  case "Union":
1110
1111
  return ast.types.every(isTemplateLiteralSpanType)
@@ -1120,6 +1121,8 @@ const templateLiteralSpanUnionTypeToString = (type: TemplateLiteralSpanType): st
1120
1121
  return "string"
1121
1122
  case "NumberKeyword":
1122
1123
  return "number"
1124
+ case "TemplateLiteral":
1125
+ return String(type)
1123
1126
  case "Union":
1124
1127
  return type.types.map(templateLiteralSpanUnionTypeToString).join(" | ")
1125
1128
  }
@@ -1133,6 +1136,8 @@ const templateLiteralSpanTypeToString = (type: TemplateLiteralSpanType): string
1133
1136
  return "${string}"
1134
1137
  case "NumberKeyword":
1135
1138
  return "${number}"
1139
+ case "TemplateLiteral":
1140
+ return "${" + String(type) + "}"
1136
1141
  case "Union":
1137
1142
  return "${" + type.types.map(templateLiteralSpanUnionTypeToString).join(" | ") + "}"
1138
1143
  }
@@ -1792,7 +1797,12 @@ export class Refinement<From extends AST = AST> implements Annotated {
1792
1797
  * @since 3.10.0
1793
1798
  */
1794
1799
  toString() {
1795
- return Option.getOrElse(getExpected(this), () => `{ ${this.from} | filter }`)
1800
+ return getIdentifierAnnotation(this).pipe(Option.getOrElse(() =>
1801
+ Option.match(getOrElseExpected(this), {
1802
+ onNone: () => `{ ${this.from} | filter }`,
1803
+ onSome: (expected) => isRefinement(this.from) ? String(this.from) + " & " + expected : expected
1804
+ })
1805
+ ))
1796
1806
  }
1797
1807
  /**
1798
1808
  * @since 3.10.0
@@ -2093,72 +2103,75 @@ export const keyof = (ast: AST): AST => Union.unify(_keyof(ast))
2093
2103
  const STRING_KEYWORD_PATTERN = ".*"
2094
2104
  const NUMBER_KEYWORD_PATTERN = "[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?"
2095
2105
 
2096
- const getTemplateLiteralPattern = (type: TemplateLiteralSpanType): string => {
2106
+ const getTemplateLiteralSpanTypePattern = (type: TemplateLiteralSpanType, capture: boolean): string => {
2097
2107
  switch (type._tag) {
2108
+ case "Literal":
2109
+ return regexp.escape(String(type.literal))
2098
2110
  case "StringKeyword":
2099
2111
  return STRING_KEYWORD_PATTERN
2100
2112
  case "NumberKeyword":
2101
2113
  return NUMBER_KEYWORD_PATTERN
2102
- case "Literal":
2103
- return regexp.escape(String(type.literal))
2114
+ case "TemplateLiteral":
2115
+ return getTemplateLiteralPattern(type, capture, false)
2104
2116
  case "Union":
2105
- return type.types.map(getTemplateLiteralPattern).join("|")
2117
+ return type.types.map((type) => getTemplateLiteralSpanTypePattern(type, capture)).join("|")
2106
2118
  }
2107
2119
  }
2108
2120
 
2109
- /**
2110
- * @since 3.10.0
2111
- */
2112
- export const getTemplateLiteralRegExp = (ast: TemplateLiteral): RegExp => {
2113
- let pattern = `^`
2121
+ const handleTemplateLiteralSpanTypeParens = (
2122
+ type: TemplateLiteralSpanType,
2123
+ s: string,
2124
+ capture: boolean,
2125
+ top: boolean
2126
+ ) => {
2127
+ if (isUnion(type)) {
2128
+ if (capture && !top) {
2129
+ return `(?:${s})`
2130
+ }
2131
+ } else if (!capture || !top) {
2132
+ return s
2133
+ }
2134
+ return `(${s})`
2135
+ }
2136
+
2137
+ const getTemplateLiteralPattern = (ast: TemplateLiteral, capture: boolean, top: boolean): string => {
2138
+ let pattern = ``
2114
2139
  if (ast.head !== "") {
2115
- pattern += regexp.escape(ast.head)
2140
+ const head = regexp.escape(ast.head)
2141
+ pattern += capture && top ? `(${head})` : head
2116
2142
  }
2117
2143
 
2118
2144
  for (const span of ast.spans) {
2119
- const p = getTemplateLiteralPattern(span.type)
2120
- pattern += isUnion(span.type) ? `(${p})` : p
2145
+ const spanPattern = getTemplateLiteralSpanTypePattern(span.type, capture)
2146
+ pattern += handleTemplateLiteralSpanTypeParens(span.type, spanPattern, capture, top)
2121
2147
  if (span.literal !== "") {
2122
- pattern += regexp.escape(span.literal)
2148
+ const literal = regexp.escape(span.literal)
2149
+ pattern += capture && top ? `(${literal})` : literal
2123
2150
  }
2124
2151
  }
2125
2152
 
2126
- pattern += "$"
2127
- return new RegExp(pattern)
2128
- }
2129
-
2130
- const getTemplateLiteralCapturingPattern = (type: TemplateLiteralSpanType): string => {
2131
- switch (type._tag) {
2132
- case "StringKeyword":
2133
- return STRING_KEYWORD_PATTERN
2134
- case "NumberKeyword":
2135
- return NUMBER_KEYWORD_PATTERN
2136
- case "Literal":
2137
- return regexp.escape(String(type.literal))
2138
- case "Union":
2139
- return type.types.map(getTemplateLiteralCapturingPattern).join("|")
2140
- }
2153
+ return pattern
2141
2154
  }
2142
2155
 
2143
2156
  /**
2157
+ * Generates a regular expression from a `TemplateLiteral` AST node.
2158
+ *
2159
+ * @see {@link getTemplateLiteralCapturingRegExp} for a variant that captures the pattern.
2160
+ *
2144
2161
  * @since 3.10.0
2145
2162
  */
2146
- export const getTemplateLiteralCapturingRegExp = (ast: TemplateLiteral): RegExp => {
2147
- let pattern = `^`
2148
- if (ast.head !== "") {
2149
- pattern += `(${regexp.escape(ast.head)})`
2150
- }
2163
+ export const getTemplateLiteralRegExp = (ast: TemplateLiteral): RegExp =>
2164
+ new RegExp(`^${getTemplateLiteralPattern(ast, false, true)}$`)
2151
2165
 
2152
- for (const span of ast.spans) {
2153
- pattern += `(${getTemplateLiteralCapturingPattern(span.type)})`
2154
- if (span.literal !== "") {
2155
- pattern += `(${regexp.escape(span.literal)})`
2156
- }
2157
- }
2158
-
2159
- pattern += "$"
2160
- return new RegExp(pattern)
2161
- }
2166
+ /**
2167
+ * Generates a regular expression that captures the pattern defined by the given `TemplateLiteral` AST.
2168
+ *
2169
+ * @see {@link getTemplateLiteralRegExp} for a variant that does not capture the pattern.
2170
+ *
2171
+ * @since 3.10.0
2172
+ */
2173
+ export const getTemplateLiteralCapturingRegExp = (ast: TemplateLiteral): RegExp =>
2174
+ new RegExp(`^${getTemplateLiteralPattern(ast, true, true)}$`)
2162
2175
 
2163
2176
  /**
2164
2177
  * @since 3.10.0
@@ -2205,7 +2218,7 @@ export const getNumberIndexedAccess = (ast: AST): AST => {
2205
2218
  case "Suspend":
2206
2219
  return getNumberIndexedAccess(ast.f())
2207
2220
  }
2208
- throw new Error(errors_.getASTUnsupportedSchema(ast))
2221
+ throw new Error(errors_.getASTUnsupportedSchemaErrorMessage(ast))
2209
2222
  }
2210
2223
 
2211
2224
  const getTypeLiteralPropertySignature = (ast: TypeLiteral, name: PropertyKey): PropertySignature | undefined => {
@@ -2274,7 +2287,7 @@ export const getPropertyKeyIndexedAccess = (ast: AST, name: PropertyKey): Proper
2274
2287
  case "Refinement":
2275
2288
  return getPropertyKeyIndexedAccess(ast.from, name)
2276
2289
  }
2277
- throw new Error(errors_.getASTUnsupportedSchema(ast))
2290
+ throw new Error(errors_.getASTUnsupportedSchemaErrorMessage(ast))
2278
2291
  }
2279
2292
 
2280
2293
  const getPropertyKeys = (ast: AST): Array<PropertyKey> => {
@@ -2319,7 +2332,7 @@ export const record = (key: AST, value: AST): {
2319
2332
  if (Predicate.isString(key.literal) || Predicate.isNumber(key.literal)) {
2320
2333
  propertySignatures.push(new PropertySignature(key.literal, value, false, true))
2321
2334
  } else {
2322
- throw new Error(errors_.getASTUnsupportedLiteral(key.literal))
2335
+ throw new Error(errors_.getASTUnsupportedLiteralErrorMessage(key.literal))
2323
2336
  }
2324
2337
  break
2325
2338
  case "Enums": {
@@ -2335,7 +2348,7 @@ export const record = (key: AST, value: AST): {
2335
2348
  key.types.forEach(go)
2336
2349
  break
2337
2350
  default:
2338
- throw new Error(errors_.getASTUnsupportedKeySchema(key))
2351
+ throw new Error(errors_.getASTUnsupportedKeySchemaErrorMessage(key))
2339
2352
  }
2340
2353
  }
2341
2354
  go(key)
@@ -2409,7 +2422,7 @@ export const pick = (ast: AST, keys: ReadonlyArray<PropertyKey>): TypeLiteral |
2409
2422
  }
2410
2423
  }
2411
2424
  }
2412
- throw new Error(errors_.getASTUnsupportedSchema(ast))
2425
+ throw new Error(errors_.getASTUnsupportedSchemaErrorMessage(ast))
2413
2426
  }
2414
2427
 
2415
2428
  /**
@@ -2452,9 +2465,8 @@ export const partial = (ast: AST, options?: { readonly exact: true }): AST => {
2452
2465
  case "Suspend":
2453
2466
  return new Suspend(() => partial(ast.f(), options))
2454
2467
  case "Declaration":
2455
- throw new Error(errors_.getASTUnsupportedSchema(ast))
2456
2468
  case "Refinement":
2457
- throw new Error(errors_.getASTUnsupportedSchema(ast))
2469
+ throw new Error(errors_.getASTUnsupportedSchemaErrorMessage(ast))
2458
2470
  case "Transformation": {
2459
2471
  if (
2460
2472
  isTypeLiteralTransformation(ast.transformation) &&
@@ -2462,7 +2474,7 @@ export const partial = (ast: AST, options?: { readonly exact: true }): AST => {
2462
2474
  ) {
2463
2475
  return new Transformation(partial(ast.from, options), partial(ast.to, options), ast.transformation)
2464
2476
  }
2465
- throw new Error(errors_.getASTUnsupportedSchema(ast))
2477
+ throw new Error(errors_.getASTUnsupportedSchemaErrorMessage(ast))
2466
2478
  }
2467
2479
  }
2468
2480
  return ast
@@ -2491,9 +2503,8 @@ export const required = (ast: AST): AST => {
2491
2503
  case "Suspend":
2492
2504
  return new Suspend(() => required(ast.f()))
2493
2505
  case "Declaration":
2494
- throw new Error(errors_.getASTUnsupportedSchema(ast))
2495
2506
  case "Refinement":
2496
- throw new Error(errors_.getASTUnsupportedSchema(ast))
2507
+ throw new Error(errors_.getASTUnsupportedSchemaErrorMessage(ast))
2497
2508
  case "Transformation": {
2498
2509
  if (
2499
2510
  isTypeLiteralTransformation(ast.transformation) &&
@@ -2501,7 +2512,7 @@ export const required = (ast: AST): AST => {
2501
2512
  ) {
2502
2513
  return new Transformation(required(ast.from), required(ast.to), ast.transformation)
2503
2514
  }
2504
- throw new Error(errors_.getASTUnsupportedSchema(ast))
2515
+ throw new Error(errors_.getASTUnsupportedSchemaErrorMessage(ast))
2505
2516
  }
2506
2517
  }
2507
2518
  return ast
@@ -2868,7 +2879,7 @@ const _keyof = (ast: AST): Array<AST> => {
2868
2879
  case "Transformation":
2869
2880
  return _keyof(ast.to)
2870
2881
  }
2871
- throw new Error(errors_.getASTUnsupportedSchema(ast))
2882
+ throw new Error(errors_.getASTUnsupportedSchemaErrorMessage(ast))
2872
2883
  }
2873
2884
 
2874
2885
  /** @internal */
@@ -2920,15 +2931,59 @@ export const rename = (ast: AST, mapping: { readonly [K in PropertyKey]?: Proper
2920
2931
  case "Transformation":
2921
2932
  return compose(ast, rename(typeAST(ast), mapping))
2922
2933
  }
2923
- throw new Error(errors_.getASTUnsupportedRenameSchema(ast))
2934
+ throw new Error(errors_.getASTUnsupportedRenameSchemaErrorMessage(ast))
2924
2935
  }
2925
2936
 
2926
2937
  const formatKeyword = (ast: AST): string => Option.getOrElse(getExpected(ast), () => ast._tag)
2927
2938
 
2928
- const getExpected = (ast: Annotated): Option.Option<string> => {
2929
- return getIdentifierAnnotation(ast).pipe(
2930
- Option.orElse(() => getTitleAnnotation(ast)),
2939
+ function getBrands(ast: Annotated): string {
2940
+ return Option.match(getBrandAnnotation(ast), {
2941
+ onNone: () => "",
2942
+ onSome: (brands) => brands.map((brand) => ` & Brand<${util_.formatUnknown(brand)}>`).join("")
2943
+ })
2944
+ }
2945
+
2946
+ const getOrElseExpected = (ast: Annotated): Option.Option<string> =>
2947
+ getTitleAnnotation(ast).pipe(
2931
2948
  Option.orElse(() => getDescriptionAnnotation(ast)),
2932
- Option.orElse(() => getAutoTitleAnnotation(ast))
2949
+ Option.orElse(() => getAutoTitleAnnotation(ast)),
2950
+ Option.map((s) => s + getBrands(ast))
2933
2951
  )
2952
+
2953
+ const getExpected = (ast: Annotated): Option.Option<string> =>
2954
+ Option.orElse(getIdentifierAnnotation(ast), () => getOrElseExpected(ast))
2955
+
2956
+ /** @internal */
2957
+ export const pruneUndefined = (
2958
+ ast: AST,
2959
+ self: (ast: AST) => AST | undefined,
2960
+ onTransformation: (ast: Transformation) => AST | undefined
2961
+ ): AST | undefined => {
2962
+ switch (ast._tag) {
2963
+ case "UndefinedKeyword":
2964
+ return neverKeyword
2965
+ case "Union": {
2966
+ const types: Array<AST> = []
2967
+ let hasUndefined = false
2968
+ for (const type of ast.types) {
2969
+ const pruned = self(type)
2970
+ if (pruned) {
2971
+ hasUndefined = true
2972
+ if (!isNeverKeyword(pruned)) {
2973
+ types.push(pruned)
2974
+ }
2975
+ } else {
2976
+ types.push(type)
2977
+ }
2978
+ }
2979
+ if (hasUndefined) {
2980
+ return Union.make(types)
2981
+ }
2982
+ break
2983
+ }
2984
+ case "Suspend":
2985
+ return self(ast.f())
2986
+ case "Transformation":
2987
+ return onTransformation(ast)
2988
+ }
2934
2989
  }
package/src/Stream.ts CHANGED
@@ -8380,11 +8380,12 @@ export const scheduleWith: {
8380
8380
  *
8381
8381
  * // Creating a single-valued stream from a scoped resource
8382
8382
  * const stream = Stream.scoped(
8383
- * Effect.acquireUseRelease(
8384
- * Console.log("acquire"),
8385
- * () => Console.log("use"),
8386
- * () => Console.log("release")
8387
- * )
8383
+ * Effect.acquireRelease(
8384
+ * Console.log("acquire"),
8385
+ * () => Console.log("release")
8386
+ * )
8387
+ * ).pipe(
8388
+ * Stream.flatMap(() => Console.log("use"))
8388
8389
  * )
8389
8390
  *
8390
8391
  * // Effect.runPromise(Stream.runCollect(stream)).then(console.log)
@@ -1,5 +1,3 @@
1
- import type { Exit } from "effect/Exit"
2
- import { internalCall } from "effect/Utils"
3
1
  import * as Arr from "../Array.js"
4
2
  import type * as Cause from "../Cause.js"
5
3
  import * as Chunk from "../Chunk.js"
@@ -7,6 +5,7 @@ import * as Clock from "../Clock.js"
7
5
  import * as Context from "../Context.js"
8
6
  import * as Duration from "../Duration.js"
9
7
  import type * as Effect from "../Effect.js"
8
+ import type { Exit } from "../Exit.js"
10
9
  import type * as Fiber from "../Fiber.js"
11
10
  import type * as FiberId from "../FiberId.js"
12
11
  import type * as FiberRef from "../FiberRef.js"
@@ -29,6 +28,7 @@ import type * as runtimeFlagsPatch from "../RuntimeFlagsPatch.js"
29
28
  import * as Tracer from "../Tracer.js"
30
29
  import type { NoInfer } from "../Types.js"
31
30
  import type { Unify } from "../Unify.js"
31
+ import { internalCall } from "../Utils.js"
32
32
  import * as internalCause from "./cause.js"
33
33
  import { clockTag } from "./clock.js"
34
34
  import * as core from "./core.js"
@@ -664,23 +664,23 @@ export const filterOrFail: {
664
664
  /* @internal */
665
665
  export const findFirst: {
666
666
  <A, E, R>(
667
- f: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>
667
+ predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>
668
668
  ): (elements: Iterable<A>) => Effect.Effect<Option.Option<A>, E, R>
669
669
  <A, E, R>(
670
670
  elements: Iterable<A>,
671
- f: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>
671
+ predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>
672
672
  ): Effect.Effect<Option.Option<A>, E, R>
673
673
  } = dual(
674
674
  2,
675
675
  <A, E, R>(
676
676
  elements: Iterable<A>,
677
- f: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>
677
+ predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>
678
678
  ): Effect.Effect<Option.Option<A>, E, R> =>
679
679
  core.suspend(() => {
680
680
  const iterator = elements[Symbol.iterator]()
681
681
  const next = iterator.next()
682
682
  if (!next.done) {
683
- return findLoop(iterator, 0, f, next.value)
683
+ return findLoop(iterator, 0, predicate, next.value)
684
684
  }
685
685
  return core.succeed(Option.none())
686
686
  })
@@ -762,15 +762,18 @@ export const match: {
762
762
  /* @internal */
763
763
  export const every: {
764
764
  <A, E, R>(
765
- f: (a: A, i: number) => Effect.Effect<boolean, E, R>
765
+ predicate: (a: A, i: number) => Effect.Effect<boolean, E, R>
766
766
  ): (elements: Iterable<A>) => Effect.Effect<boolean, E, R>
767
- <A, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect.Effect<boolean, E, R>): Effect.Effect<boolean, E, R>
767
+ <A, E, R>(
768
+ elements: Iterable<A>,
769
+ predicate: (a: A, i: number) => Effect.Effect<boolean, E, R>
770
+ ): Effect.Effect<boolean, E, R>
768
771
  } = dual(
769
772
  2,
770
773
  <A, E, R>(
771
774
  elements: Iterable<A>,
772
- f: (a: A, i: number) => Effect.Effect<boolean, E, R>
773
- ): Effect.Effect<boolean, E, R> => core.suspend(() => forAllLoop(elements[Symbol.iterator](), 0, f))
775
+ predicate: (a: A, i: number) => Effect.Effect<boolean, E, R>
776
+ ): Effect.Effect<boolean, E, R> => core.suspend(() => forAllLoop(elements[Symbol.iterator](), 0, predicate))
774
777
  )
775
778
 
776
779
  const forAllLoop = <A, E, R>(
@@ -1,4 +1,3 @@
1
- import { internalCall } from "effect/Utils"
2
1
  import * as Arr from "../Array.js"
3
2
  import type * as Cause from "../Cause.js"
4
3
  import * as Chunk from "../Chunk.js"
@@ -38,7 +37,7 @@ import * as RuntimeFlagsPatch from "../RuntimeFlagsPatch.js"
38
37
  import type * as Scope from "../Scope.js"
39
38
  import type * as Tracer from "../Tracer.js"
40
39
  import type { NoInfer, NotFunction } from "../Types.js"
41
- import { YieldWrap } from "../Utils.js"
40
+ import { internalCall, YieldWrap } from "../Utils.js"
42
41
  import * as _blockedRequests from "./blockedRequests.js"
43
42
  import * as internalCause from "./cause.js"
44
43
  import * as deferred from "./deferred.js"
@@ -1,6 +1,6 @@
1
- import type { NoInfer } from "effect/Types"
2
1
  import { dual } from "../Function.js"
3
2
  import type { Kind, TypeLambda } from "../HKT.js"
3
+ import type { NoInfer } from "../Types.js"
4
4
 
5
5
  type Map<F extends TypeLambda> = {
6
6
  <A, B>(f: (a: A) => B): <R, O, E>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, B>
@@ -1,4 +1,3 @@
1
- import { internalCall, yieldWrapGet } from "effect/Utils"
2
1
  import * as RA from "../Array.js"
3
2
  import * as Boolean from "../Boolean.js"
4
3
  import type * as Cause from "../Cause.js"
@@ -45,6 +44,7 @@ import type * as Scope from "../Scope.js"
45
44
  import type * as Supervisor from "../Supervisor.js"
46
45
  import type * as Tracer from "../Tracer.js"
47
46
  import type { Concurrency, NoInfer } from "../Types.js"
47
+ import { internalCall, yieldWrapGet } from "../Utils.js"
48
48
  import * as _RequestBlock from "./blockedRequests.js"
49
49
  import * as internalCause from "./cause.js"
50
50
  import * as clock from "./clock.js"
@@ -1705,30 +1705,30 @@ const _existsParFound = Symbol.for("effect/Effect/existsPar/found")
1705
1705
 
1706
1706
  /* @internal */
1707
1707
  export const exists: {
1708
- <A, E, R>(f: (a: A, i: number) => Effect.Effect<boolean, E, R>, options?: {
1708
+ <A, E, R>(predicate: (a: A, i: number) => Effect.Effect<boolean, E, R>, options?: {
1709
1709
  readonly concurrency?: Concurrency | undefined
1710
1710
  readonly batching?: boolean | "inherit" | undefined
1711
1711
  readonly concurrentFinalizers?: boolean | undefined
1712
1712
  }): (elements: Iterable<A>) => Effect.Effect<boolean, E, R>
1713
- <A, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect.Effect<boolean, E, R>, options?: {
1713
+ <A, E, R>(elements: Iterable<A>, predicate: (a: A, i: number) => Effect.Effect<boolean, E, R>, options?: {
1714
1714
  readonly concurrency?: Concurrency | undefined
1715
1715
  readonly batching?: boolean | "inherit" | undefined
1716
1716
  readonly concurrentFinalizers?: boolean | undefined
1717
1717
  }): Effect.Effect<boolean, E, R>
1718
1718
  } = dual(
1719
1719
  (args) => Predicate.isIterable(args[0]) && !core.isEffect(args[0]),
1720
- <A, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect.Effect<boolean, E, R>, options?: {
1720
+ <A, E, R>(elements: Iterable<A>, predicate: (a: A, i: number) => Effect.Effect<boolean, E, R>, options?: {
1721
1721
  readonly concurrency?: Concurrency | undefined
1722
1722
  readonly batching?: boolean | "inherit" | undefined
1723
1723
  }) =>
1724
1724
  concurrency.matchSimple(
1725
1725
  options?.concurrency,
1726
- () => core.suspend(() => existsLoop(elements[Symbol.iterator](), 0, f)),
1726
+ () => core.suspend(() => existsLoop(elements[Symbol.iterator](), 0, predicate)),
1727
1727
  () =>
1728
1728
  core.matchEffect(
1729
1729
  forEach(
1730
1730
  elements,
1731
- (a, i) => core.if_(f(a, i), { onTrue: () => core.fail(_existsParFound), onFalse: () => core.void }),
1731
+ (a, i) => core.if_(predicate(a, i), { onTrue: () => core.fail(_existsParFound), onFalse: () => core.void }),
1732
1732
  options
1733
1733
  ),
1734
1734
  {
@@ -1757,7 +1757,7 @@ const existsLoop = <A, E, R>(
1757
1757
  /* @internal */
1758
1758
  export const filter = dual<
1759
1759
  <A, E, R>(
1760
- f: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>,
1760
+ predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>,
1761
1761
  options?: {
1762
1762
  readonly concurrency?: Concurrency | undefined
1763
1763
  readonly batching?: boolean | "inherit" | undefined
@@ -1765,7 +1765,7 @@ export const filter = dual<
1765
1765
  readonly concurrentFinalizers?: boolean | undefined
1766
1766
  }
1767
1767
  ) => (elements: Iterable<A>) => Effect.Effect<Array<A>, E, R>,
1768
- <A, E, R>(elements: Iterable<A>, f: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>, options?: {
1768
+ <A, E, R>(elements: Iterable<A>, predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>, options?: {
1769
1769
  readonly concurrency?: Concurrency | undefined
1770
1770
  readonly batching?: boolean | "inherit" | undefined
1771
1771
  readonly negate?: boolean | undefined
@@ -1773,13 +1773,13 @@ export const filter = dual<
1773
1773
  }) => Effect.Effect<Array<A>, E, R>
1774
1774
  >(
1775
1775
  (args) => Predicate.isIterable(args[0]) && !core.isEffect(args[0]),
1776
- <A, E, R>(elements: Iterable<A>, f: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>, options?: {
1776
+ <A, E, R>(elements: Iterable<A>, predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, E, R>, options?: {
1777
1777
  readonly concurrency?: Concurrency | undefined
1778
1778
  readonly batching?: boolean | "inherit" | undefined
1779
1779
  readonly negate?: boolean | undefined
1780
1780
  readonly concurrentFinalizers?: boolean | undefined
1781
1781
  }) => {
1782
- const predicate = options?.negate ? (a: A, i: number) => core.map(f(a, i), Boolean.not) : f
1782
+ const predicate_ = options?.negate ? (a: A, i: number) => core.map(predicate(a, i), Boolean.not) : predicate
1783
1783
  return concurrency.matchSimple(
1784
1784
  options?.concurrency,
1785
1785
  () =>
@@ -1788,7 +1788,7 @@ export const filter = dual<
1788
1788
  (effect, a, i) =>
1789
1789
  core.zipWith(
1790
1790
  effect,
1791
- core.suspend(() => predicate(a, i)),
1791
+ core.suspend(() => predicate_(a, i)),
1792
1792
  (list, b) => b ? [a, ...list] : list
1793
1793
  ),
1794
1794
  core.sync(() => new Array<A>()) as Effect.Effect<Array<A>, E, R>
@@ -1798,7 +1798,7 @@ export const filter = dual<
1798
1798
  core.map(
1799
1799
  forEach(
1800
1800
  elements,
1801
- (a, i) => core.map(predicate(a, i), (b) => (b ? Option.some(a) : Option.none())),
1801
+ (a, i) => core.map(predicate_(a, i), (b) => (b ? Option.some(a) : Option.none())),
1802
1802
  options
1803
1803
  ),
1804
1804
  RA.getSomes
@@ -2706,7 +2706,7 @@ const raceAllArbiter = <E, E1, A, A1>(
2706
2706
  export const reduceEffect = dual<
2707
2707
  <Z, E, R, Eff extends Effect.Effect<any, any, any>>(
2708
2708
  zero: Effect.Effect<Z, E, R>,
2709
- f: (acc: NoInfer<Z>, a: Effect.Effect.Success<Eff>, i: number) => Z,
2709
+ f: (z: NoInfer<Z>, a: Effect.Effect.Success<Eff>, i: number) => Z,
2710
2710
  options?: {
2711
2711
  readonly concurrency?: Concurrency | undefined
2712
2712
  readonly batching?: boolean | "inherit" | undefined
@@ -2716,7 +2716,7 @@ export const reduceEffect = dual<
2716
2716
  <Eff extends Effect.Effect<any, any, any>, Z, E, R>(
2717
2717
  elements: Iterable<Eff>,
2718
2718
  zero: Effect.Effect<Z, E, R>,
2719
- f: (acc: NoInfer<Z>, a: Effect.Effect.Success<Eff>, i: number) => Z,
2719
+ f: (z: NoInfer<Z>, a: Effect.Effect.Success<Eff>, i: number) => Z,
2720
2720
  options?: {
2721
2721
  readonly concurrency?: Concurrency | undefined
2722
2722
  readonly batching?: boolean | "inherit" | undefined
@@ -2726,7 +2726,7 @@ export const reduceEffect = dual<
2726
2726
  >((args) => Predicate.isIterable(args[0]) && !core.isEffect(args[0]), <A, E, R, Z>(
2727
2727
  elements: Iterable<Effect.Effect<A, E, R>>,
2728
2728
  zero: Effect.Effect<Z, E, R>,
2729
- f: (acc: NoInfer<Z>, a: NoInfer<A>, i: number) => Z,
2729
+ f: (z: NoInfer<Z>, a: NoInfer<A>, i: number) => Z,
2730
2730
  options?: {
2731
2731
  readonly concurrency?: Concurrency | undefined
2732
2732
  readonly batching?: boolean | "inherit" | undefined
@@ -1,4 +1,3 @@
1
- import type { Scope } from "effect/Scope"
2
1
  import * as Arr from "../Array.js"
3
2
  import type { Cause } from "../Cause.js"
4
3
  import { NoSuchElementException } from "../Cause.js"
@@ -15,6 +14,7 @@ import * as Option from "../Option.js"
15
14
  import { pipeArguments } from "../Pipeable.js"
16
15
  import { hasProperty } from "../Predicate.js"
17
16
  import type { Scheduler } from "../Scheduler.js"
17
+ import type { Scope } from "../Scope.js"
18
18
  import type { Stream } from "../Stream.js"
19
19
  import * as channel from "./channel.js"
20
20
  import * as channelExecutor from "./channel/channelExecutor.js"
@@ -1,4 +1,4 @@
1
- import type { Cause } from "effect/Cause"
1
+ import type { Cause } from "../Cause.js"
2
2
  import * as Context from "../Context.js"
3
3
  import * as Duration from "../Duration.js"
4
4
  import type { Effect, Semaphore } from "../Effect.js"
@@ -1,8 +1,8 @@
1
- import { NodeInspectSymbol } from "effect/Inspectable"
2
1
  import * as Equal from "../Equal.js"
3
2
  import { pipe } from "../Function.js"
4
3
  import { globalValue } from "../GlobalValue.js"
5
4
  import * as Hash from "../Hash.js"
5
+ import { NodeInspectSymbol } from "../Inspectable.js"
6
6
  import { pipeArguments } from "../Pipeable.js"
7
7
  import { hasProperty } from "../Predicate.js"
8
8
  import type * as Redacted from "../Redacted.js"
@@ -1,8 +1,8 @@
1
- import { equals } from "effect/Equal"
2
1
  import type * as ReadonlyArray from "../Array.js"
3
2
  import type * as Cause from "../Cause.js"
4
3
  import * as Context from "../Context.js"
5
4
  import type * as Effect from "../Effect.js"
5
+ import { equals } from "../Equal.js"
6
6
  import * as Exit from "../Exit.js"
7
7
  import * as Fiber from "../Fiber.js"
8
8
  import * as FiberId from "../FiberId.js"
@@ -1,4 +1,4 @@
1
- import * as array_ from "effect/Array"
1
+ import * as array_ from "../../Array.js"
2
2
  import type * as AST from "../../SchemaAST.js"
3
3
  import * as util_ from "./util.js"
4
4
 
@@ -150,14 +150,15 @@ export const getSchemaUnsupportedLiteralSpanErrorMessage = (ast: AST.AST) =>
150
150
  // ---------------------------------------------
151
151
 
152
152
  /** @internal */
153
- export const getASTUnsupportedSchema = (ast: AST.AST) => getUnsupportedSchemaErrorMessage(undefined, undefined, ast)
153
+ export const getASTUnsupportedSchemaErrorMessage = (ast: AST.AST) =>
154
+ getUnsupportedSchemaErrorMessage(undefined, undefined, ast)
154
155
 
155
156
  /** @internal */
156
- export const getASTUnsupportedKeySchema = (ast: AST.AST) =>
157
+ export const getASTUnsupportedKeySchemaErrorMessage = (ast: AST.AST) =>
157
158
  getErrorMessage("Unsupported key schema", undefined, undefined, ast)
158
159
 
159
160
  /** @internal */
160
- export const getASTUnsupportedLiteral = (literal: AST.LiteralValue) =>
161
+ export const getASTUnsupportedLiteralErrorMessage = (literal: AST.LiteralValue) =>
161
162
  getErrorMessage("Unsupported literal", `literal value: ${util_.formatUnknown(literal)}`)
162
163
 
163
164
  /** @internal */
@@ -181,7 +182,7 @@ export const getASTDuplicatePropertySignatureTransformationErrorMessage = (key:
181
182
  getErrorMessage("Duplicate property signature transformation", `Duplicate key ${util_.formatUnknown(key)}`)
182
183
 
183
184
  /** @internal */
184
- export const getASTUnsupportedRenameSchema = (ast: AST.AST): string =>
185
+ export const getASTUnsupportedRenameSchemaErrorMessage = (ast: AST.AST): string =>
185
186
  getUnsupportedSchemaErrorMessage(undefined, undefined, ast)
186
187
 
187
188
  /** @internal */
@@ -1,6 +1,6 @@
1
- import * as array_ from "effect/Array"
2
- import * as Predicate from "effect/Predicate"
1
+ import * as array_ from "../../Array.js"
3
2
  import type * as ParseResult from "../../ParseResult.js"
3
+ import * as Predicate from "../../Predicate.js"
4
4
  import type * as AST from "../../SchemaAST.js"
5
5
 
6
6
  /** @internal */
@@ -1,4 +1,3 @@
1
- import { internalCall } from "effect/Utils"
2
1
  import * as Cause from "../../Cause.js"
3
2
  import * as Context from "../../Context.js"
4
3
  import * as Effect from "../../Effect.js"
@@ -15,7 +14,7 @@ import { pipeArguments } from "../../Pipeable.js"
15
14
  import { hasProperty } from "../../Predicate.js"
16
15
  import type * as Scheduler from "../../Scheduler.js"
17
16
  import type * as STM from "../../STM.js"
18
- import { YieldWrap } from "../../Utils.js"
17
+ import { internalCall, YieldWrap } from "../../Utils.js"
19
18
  import { ChannelTypeId } from "../core-stream.js"
20
19
  import { withFiberRuntime } from "../core.js"
21
20
  import { effectVariance, StreamTypeId } from "../effectable.js"