effect 4.0.0-beta.82 → 4.0.0-beta.84

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 (199) hide show
  1. package/dist/Array.d.ts +64 -64
  2. package/dist/Array.js +26 -26
  3. package/dist/Cache.d.ts +1 -1
  4. package/dist/Cache.js +1 -1
  5. package/dist/Cause.d.ts +68 -68
  6. package/dist/Cause.js +47 -47
  7. package/dist/Channel.d.ts +5 -5
  8. package/dist/Channel.js +3 -3
  9. package/dist/Clock.d.ts +1 -1
  10. package/dist/Clock.js +1 -1
  11. package/dist/Combiner.d.ts +9 -9
  12. package/dist/Combiner.js +8 -8
  13. package/dist/Config.d.ts +15 -94
  14. package/dist/Config.d.ts.map +1 -1
  15. package/dist/Config.js +22 -70
  16. package/dist/Config.js.map +1 -1
  17. package/dist/ConfigProvider.d.ts +58 -74
  18. package/dist/ConfigProvider.d.ts.map +1 -1
  19. package/dist/ConfigProvider.js +66 -41
  20. package/dist/ConfigProvider.js.map +1 -1
  21. package/dist/Console.d.ts +1 -1
  22. package/dist/Console.js +1 -1
  23. package/dist/Data.d.ts +15 -15
  24. package/dist/Data.js +3 -3
  25. package/dist/DateTime.d.ts +6 -6
  26. package/dist/DateTime.js +2 -2
  27. package/dist/Duration.d.ts +3 -3
  28. package/dist/Duration.js +3 -3
  29. package/dist/Effect.d.ts +84 -45
  30. package/dist/Effect.d.ts.map +1 -1
  31. package/dist/Effect.js +72 -33
  32. package/dist/Effect.js.map +1 -1
  33. package/dist/Equal.d.ts +7 -7
  34. package/dist/Equal.js +5 -5
  35. package/dist/Equivalence.d.ts +17 -17
  36. package/dist/Equivalence.js +13 -13
  37. package/dist/Exit.d.ts +3 -3
  38. package/dist/Exit.js +3 -3
  39. package/dist/Formatter.d.ts +5 -5
  40. package/dist/Formatter.js +4 -4
  41. package/dist/Function.d.ts +10 -10
  42. package/dist/Function.js +3 -3
  43. package/dist/HashMap.d.ts +3 -3
  44. package/dist/HashMap.js +1 -1
  45. package/dist/Iterable.d.ts +6 -6
  46. package/dist/Iterable.js +2 -2
  47. package/dist/JsonPatch.d.ts +2 -2
  48. package/dist/Layer.d.ts +1 -1
  49. package/dist/Layer.js +1 -1
  50. package/dist/Logger.d.ts +1 -1
  51. package/dist/Logger.js +1 -1
  52. package/dist/Match.d.ts +8 -8
  53. package/dist/Match.js +8 -8
  54. package/dist/Metric.d.ts +3 -3
  55. package/dist/Metric.js +3 -3
  56. package/dist/Optic.d.ts +30 -30
  57. package/dist/Optic.js +12 -12
  58. package/dist/Option.d.ts +7 -7
  59. package/dist/Option.js +7 -7
  60. package/dist/Order.d.ts +23 -23
  61. package/dist/Order.js +20 -20
  62. package/dist/Pool.d.ts +1 -1
  63. package/dist/Pool.js +1 -1
  64. package/dist/Predicate.d.ts +88 -88
  65. package/dist/Predicate.js +47 -47
  66. package/dist/PubSub.d.ts +3 -3
  67. package/dist/PubSub.js +3 -3
  68. package/dist/Reducer.d.ts +1 -1
  69. package/dist/Reducer.js +1 -1
  70. package/dist/Result.d.ts +18 -18
  71. package/dist/Result.js +8 -8
  72. package/dist/Runtime.d.ts +1 -1
  73. package/dist/Runtime.js +1 -1
  74. package/dist/Schema.d.ts +265 -120
  75. package/dist/Schema.d.ts.map +1 -1
  76. package/dist/Schema.js +285 -116
  77. package/dist/Schema.js.map +1 -1
  78. package/dist/SchemaAST.d.ts +1 -1
  79. package/dist/SchemaAST.d.ts.map +1 -1
  80. package/dist/SchemaAST.js +13 -9
  81. package/dist/SchemaAST.js.map +1 -1
  82. package/dist/SchemaGetter.d.ts +48 -48
  83. package/dist/SchemaGetter.js +44 -44
  84. package/dist/SchemaIssue.d.ts +3 -3
  85. package/dist/SchemaIssue.js +3 -3
  86. package/dist/SchemaParser.d.ts +122 -22
  87. package/dist/SchemaParser.d.ts.map +1 -1
  88. package/dist/SchemaParser.js +186 -50
  89. package/dist/SchemaParser.js.map +1 -1
  90. package/dist/SchemaRepresentation.d.ts +1 -1
  91. package/dist/SchemaRepresentation.d.ts.map +1 -1
  92. package/dist/SchemaRepresentation.js +96 -2
  93. package/dist/SchemaRepresentation.js.map +1 -1
  94. package/dist/SchemaTransformation.d.ts +20 -20
  95. package/dist/SchemaTransformation.js +18 -18
  96. package/dist/Stream.d.ts +3 -3
  97. package/dist/Stream.js +2 -2
  98. package/dist/Stream.js.map +1 -1
  99. package/dist/String.d.ts +1 -1
  100. package/dist/String.js +1 -1
  101. package/dist/Struct.d.ts +1 -1
  102. package/dist/Struct.js +1 -1
  103. package/dist/Types.d.ts +13 -13
  104. package/dist/internal/effect.js +23 -10
  105. package/dist/internal/effect.js.map +1 -1
  106. package/dist/internal/schema/cause.d.ts +2 -0
  107. package/dist/internal/schema/cause.d.ts.map +1 -0
  108. package/dist/internal/schema/cause.js +24 -0
  109. package/dist/internal/schema/cause.js.map +1 -0
  110. package/dist/internal/schema/schema.d.ts +8 -4
  111. package/dist/internal/schema/schema.d.ts.map +1 -1
  112. package/dist/internal/schema/schema.js +21 -8
  113. package/dist/internal/schema/schema.js.map +1 -1
  114. package/dist/testing/TestSchema.d.ts +3 -3
  115. package/dist/testing/TestSchema.js +1 -1
  116. package/dist/unstable/ai/AiError.d.ts +1 -1
  117. package/dist/unstable/ai/AiError.js +1 -1
  118. package/dist/unstable/ai/Chat.d.ts +1 -1
  119. package/dist/unstable/ai/Chat.js +1 -1
  120. package/dist/unstable/cli/Prompt.js +2 -2
  121. package/dist/unstable/cli/Prompt.js.map +1 -1
  122. package/dist/unstable/httpapi/HttpApiScalar.d.ts +2 -2
  123. package/dist/unstable/httpapi/HttpApiSchema.d.ts +39 -0
  124. package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
  125. package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
  126. package/dist/unstable/rpc/Rpc.d.ts +1 -1
  127. package/dist/unstable/rpc/Rpc.js +1 -1
  128. package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
  129. package/dist/unstable/rpc/RpcGroup.js +3 -4
  130. package/dist/unstable/rpc/RpcGroup.js.map +1 -1
  131. package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
  132. package/dist/unstable/sql/SqlResolver.js +15 -2
  133. package/dist/unstable/sql/SqlResolver.js.map +1 -1
  134. package/dist/unstable/workflow/Activity.d.ts +1 -0
  135. package/dist/unstable/workflow/Activity.d.ts.map +1 -1
  136. package/dist/unstable/workflow/Activity.js +1 -0
  137. package/dist/unstable/workflow/Activity.js.map +1 -1
  138. package/dist/unstable/workflow/WorkflowEngine.js +1 -1
  139. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  140. package/package.json +1 -1
  141. package/src/Array.ts +65 -65
  142. package/src/Cache.ts +1 -1
  143. package/src/Cause.ts +68 -68
  144. package/src/Channel.ts +5 -5
  145. package/src/Clock.ts +1 -1
  146. package/src/Combiner.ts +9 -9
  147. package/src/Config.ts +40 -108
  148. package/src/ConfigProvider.ts +139 -100
  149. package/src/Console.ts +1 -1
  150. package/src/Data.ts +15 -15
  151. package/src/DateTime.ts +6 -6
  152. package/src/Duration.ts +3 -3
  153. package/src/Effect.ts +89 -45
  154. package/src/Equal.ts +7 -7
  155. package/src/Equivalence.ts +17 -17
  156. package/src/Exit.ts +3 -3
  157. package/src/Formatter.ts +5 -5
  158. package/src/Function.ts +10 -10
  159. package/src/HashMap.ts +3 -3
  160. package/src/Iterable.ts +6 -6
  161. package/src/JsonPatch.ts +2 -2
  162. package/src/Layer.ts +1 -1
  163. package/src/Logger.ts +1 -1
  164. package/src/Match.ts +8 -8
  165. package/src/Metric.ts +3 -3
  166. package/src/Optic.ts +30 -30
  167. package/src/Option.ts +7 -7
  168. package/src/Order.ts +23 -23
  169. package/src/Pool.ts +1 -1
  170. package/src/Predicate.ts +88 -88
  171. package/src/PubSub.ts +3 -3
  172. package/src/Reducer.ts +1 -1
  173. package/src/Result.ts +20 -20
  174. package/src/Runtime.ts +1 -1
  175. package/src/Schema.ts +314 -131
  176. package/src/SchemaAST.ts +20 -11
  177. package/src/SchemaGetter.ts +48 -48
  178. package/src/SchemaIssue.ts +3 -3
  179. package/src/SchemaParser.ts +197 -58
  180. package/src/SchemaRepresentation.ts +73 -3
  181. package/src/SchemaTransformation.ts +20 -20
  182. package/src/Stream.ts +4 -4
  183. package/src/String.ts +1 -1
  184. package/src/Struct.ts +1 -1
  185. package/src/Types.ts +13 -13
  186. package/src/internal/effect.ts +29 -10
  187. package/src/internal/schema/cause.ts +26 -0
  188. package/src/internal/schema/schema.ts +36 -10
  189. package/src/testing/TestSchema.ts +3 -3
  190. package/src/unstable/ai/AiError.ts +1 -1
  191. package/src/unstable/ai/Chat.ts +1 -1
  192. package/src/unstable/cli/Prompt.ts +1 -1
  193. package/src/unstable/httpapi/HttpApiScalar.ts +2 -2
  194. package/src/unstable/httpapi/HttpApiSchema.ts +18 -6
  195. package/src/unstable/rpc/Rpc.ts +1 -1
  196. package/src/unstable/rpc/RpcGroup.ts +3 -4
  197. package/src/unstable/sql/SqlResolver.ts +15 -2
  198. package/src/unstable/workflow/Activity.ts +2 -0
  199. package/src/unstable/workflow/WorkflowEngine.ts +1 -1
@@ -447,7 +447,7 @@ export function trim(): Transformation<string, string> {
447
447
  * Encoding converts values such as `"myFieldName"` back to `"my_field_name"`.
448
448
  * The transformation is round-trippable for standard snake_case and camelCase.
449
449
  *
450
- * **Example** (Snake to camel conversion)
450
+ * **Example** (Converting snake case to camel case)
451
451
  *
452
452
  * ```ts
453
453
  * import { Schema, SchemaTransformation } from "effect"
@@ -722,7 +722,7 @@ export function passthrough<T>(): Transformation<T, T> {
722
722
  * Both decode and encode are no-ops and return a shared singleton
723
723
  * transformation.
724
724
  *
725
- * **Example** (Supertype passthrough)
725
+ * **Example** (Passing through supertypes)
726
726
  *
727
727
  * ```ts
728
728
  * import { SchemaTransformation } from "effect"
@@ -755,7 +755,7 @@ export function passthroughSupertype<T>(): Transformation<T, T> {
755
755
  * - Both decode and encode are no-ops (same as {@link passthrough}).
756
756
  * - Returns a shared singleton instance.
757
757
  *
758
- * **Example** (Subtype passthrough)
758
+ * **Example** (Passing through subtypes)
759
759
  *
760
760
  * ```ts
761
761
  * import { SchemaTransformation } from "effect"
@@ -790,7 +790,7 @@ export function passthroughSubtype<T>(): Transformation<T, T> {
790
790
  * result is finite; combine with `Schema.Finite` or `Schema.Int` for stricter
791
791
  * checks.
792
792
  *
793
- * **Example** (Number from string)
793
+ * **Example** (Converting a string to a number)
794
794
  *
795
795
  * ```ts
796
796
  * import { Schema, SchemaTransformation } from "effect"
@@ -826,7 +826,7 @@ export const numberFromString = new Transformation(
826
826
  * the bigint to a string like `String(n)`. Decoding fails if the string is not
827
827
  * a valid bigint representation.
828
828
  *
829
- * **Example** (BigInt from string)
829
+ * **Example** (Converting a string to a BigInt)
830
830
  *
831
831
  * ```ts
832
832
  * import { Schema, SchemaTransformation } from "effect"
@@ -861,7 +861,7 @@ export const bigintFromString = new Transformation(
861
861
  * converts the `Date` to an ISO string like `date.toISOString()`, returning
862
862
  * `"Invalid Date"` for invalid dates.
863
863
  *
864
- * **Example** (Date from string)
864
+ * **Example** (Converting a string to a Date)
865
865
  *
866
866
  * ```ts
867
867
  * import { Schema, SchemaTransformation } from "effect"
@@ -898,7 +898,7 @@ export const dateFromString: Transformation<globalThis.Date, string> = new Trans
898
898
  * producing strings such as `"2000 millis"` or `"10 nanos"` that round-trip
899
899
  * through the parser.
900
900
  *
901
- * **Example** (Duration from string)
901
+ * **Example** (Converting a string to a Duration)
902
902
  *
903
903
  * ```ts
904
904
  * import { Schema, SchemaTransformation } from "effect"
@@ -942,7 +942,7 @@ export const durationFromString: Transformation<Duration.Duration, string> = tra
942
942
  * fails with `InvalidValue` if the `Duration` cannot be represented as a
943
943
  * `bigint`, such as `Duration.infinity`.
944
944
  *
945
- * **Example** (Duration from nanoseconds)
945
+ * **Example** (Converting nanoseconds to a Duration)
946
946
  *
947
947
  * ```ts
948
948
  * import { Schema, SchemaTransformation } from "effect"
@@ -983,7 +983,7 @@ export const durationFromNanos: Transformation<Duration.Duration, bigint> = tran
983
983
  * Decode creates a duration from the number, and encode returns the duration
984
984
  * length in milliseconds.
985
985
  *
986
- * **Example** (Duration from milliseconds)
986
+ * **Example** (Converting milliseconds to a Duration)
987
987
  *
988
988
  * ```ts
989
989
  * import { Schema, SchemaTransformation } from "effect"
@@ -1098,7 +1098,7 @@ export const defectFromJson = (options?: ErrorOptions) =>
1098
1098
  * `Option.some(value)`. Encoding maps `Option.none()` to `null` and
1099
1099
  * `Option.some(value)` to `value`. The transformation is pure and synchronous.
1100
1100
  *
1101
- * **Example** (Option from nullable)
1101
+ * **Example** (Converting nullable values to an Option)
1102
1102
  *
1103
1103
  * ```ts
1104
1104
  * import { Schema, SchemaTransformation } from "effect"
@@ -1138,7 +1138,7 @@ export function optionFromNullOr<T>(): Transformation<Option.Option<T>, T | null
1138
1138
  * `Option.some(value)`. Encoding maps `Option.none()` to `undefined` and
1139
1139
  * `Option.some(value)` to `value`. The transformation is pure and synchronous.
1140
1140
  *
1141
- * **Example** (Option from undefined-or)
1141
+ * **Example** (Converting undefined-or values to an Option)
1142
1142
  *
1143
1143
  * ```ts
1144
1144
  * import { Schema, SchemaTransformation } from "effect"
@@ -1181,7 +1181,7 @@ export function optionFromUndefinedOr<T>(): Transformation<Option.Option<T>, T |
1181
1181
  * `undefined` according to `options.onNoneEncoding`, and maps
1182
1182
  * `Option.some(value)` to `value`. The transformation is pure and synchronous.
1183
1183
  *
1184
- * **Example** (Option from nullish, encoding None as null)
1184
+ * **Example** (Converting nullish values to an Option and encoding None as null)
1185
1185
  *
1186
1186
  * ```ts
1187
1187
  * import { Schema, SchemaTransformation } from "effect"
@@ -1227,7 +1227,7 @@ export function optionFromNullishOr<T>(
1227
1227
  * the key, and maps `Some(Some(v))` to `Some(v)`. This uses
1228
1228
  * `transformOptional` under the hood.
1229
1229
  *
1230
- * **Example** (Optional key to Option)
1230
+ * **Example** (Converting an optional key to an Option)
1231
1231
  *
1232
1232
  * ```ts
1233
1233
  * import { Schema, SchemaTransformation } from "effect"
@@ -1272,7 +1272,7 @@ export function optionFromOptionalKey<T>(): Transformation<Option.Option<T>, T>
1272
1272
  * value, and maps `Some(Some(v))` to `Some(v)`. This uses
1273
1273
  * `transformOptional` under the hood and filters out `undefined` on decode.
1274
1274
  *
1275
- * **Example** (Optional value to Option)
1275
+ * **Example** (Converting an optional value to an Option)
1276
1276
  *
1277
1277
  * ```ts
1278
1278
  * import { Schema, SchemaTransformation } from "effect"
@@ -1315,7 +1315,7 @@ export function optionFromOptional<T>(): Transformation<Option.Option<T>, T | un
1315
1315
  * Decoding calls `new URL(s)` and fails with `InvalidValue` if the string is
1316
1316
  * not a valid URL. Encoding returns `url.href`.
1317
1317
  *
1318
- * **Example** (URL from string)
1318
+ * **Example** (Converting a string to a URL)
1319
1319
  *
1320
1320
  * ```ts
1321
1321
  * import { Schema, SchemaTransformation } from "effect"
@@ -1385,7 +1385,7 @@ export const bigDecimalFromString: Transformation<BigDecimal.BigDecimal, string>
1385
1385
  * Decoding parses the Base64 string into bytes. Encoding writes the byte array
1386
1386
  * as a Base64 string.
1387
1387
  *
1388
- * **Example** (Uint8Array from Base64)
1388
+ * **Example** (Converting Base64 to a Uint8Array)
1389
1389
  *
1390
1390
  * ```ts
1391
1391
  * import { Schema, SchemaTransformation } from "effect"
@@ -1420,7 +1420,7 @@ export const uint8ArrayFromBase64String: Transformation<Uint8Array<ArrayBufferLi
1420
1420
  * Decoding parses the Base64 string into a UTF-8 string. Encoding writes the
1421
1421
  * string as a Base64 string.
1422
1422
  *
1423
- * **Example** (String from Base64)
1423
+ * **Example** (Converting Base64 to a string)
1424
1424
  *
1425
1425
  * ```ts
1426
1426
  * import { Schema, SchemaTransformation } from "effect"
@@ -1454,7 +1454,7 @@ export const stringFromBase64String: Transformation<string, string> = new Transf
1454
1454
  * Decoding parses the Base64 URL string into a UTF-8 string. Encoding writes
1455
1455
  * the string as a Base64 URL string.
1456
1456
  *
1457
- * **Example** (String from Base64Url)
1457
+ * **Example** (Converting Base64Url to a string)
1458
1458
  *
1459
1459
  * ```ts
1460
1460
  * import { Schema, SchemaTransformation } from "effect"
@@ -1488,7 +1488,7 @@ export const stringFromBase64UrlString: Transformation<string, string> = new Tra
1488
1488
  * Decoding parses the hex string into a UTF-8 string. Encoding writes the
1489
1489
  * string as a hex string.
1490
1490
  *
1491
- * **Example** (String from Hex)
1491
+ * **Example** (Converting hex to a string)
1492
1492
  *
1493
1493
  * ```ts
1494
1494
  * import { Schema, SchemaTransformation } from "effect"
@@ -1524,7 +1524,7 @@ export const stringFromHexString: Transformation<string, string> = new Transform
1524
1524
  * Decoding calls `decodeURIComponent` and fails if the input contains malformed
1525
1525
  * percent-encoding sequences. Encoding calls `encodeURIComponent`.
1526
1526
  *
1527
- * **Example** (URI component schema)
1527
+ * **Example** (Defining a URI component schema)
1528
1528
  *
1529
1529
  * ```ts
1530
1530
  * import { Schema, SchemaTransformation } from "effect"
package/src/Stream.ts CHANGED
@@ -2905,7 +2905,7 @@ export const tapSink: {
2905
2905
  * multiple inner streams may run at the same time and their outputs are merged
2906
2906
  * as they arrive.
2907
2907
  *
2908
- * **Example** (FlatMapping stream values)
2908
+ * **Example** (Flat mapping stream values)
2909
2909
  *
2910
2910
  * ```ts
2911
2911
  * import { Console, Effect, Stream } from "effect"
@@ -2936,7 +2936,7 @@ export const flatMap: {
2936
2936
  * multiple inner streams may run at the same time and their outputs are merged
2937
2937
  * as they arrive.
2938
2938
  *
2939
- * **Example** (FlatMapping stream values)
2939
+ * **Example** (Flat mapping stream values)
2940
2940
  *
2941
2941
  * ```ts
2942
2942
  * import { Console, Effect, Stream } from "effect"
@@ -2973,7 +2973,7 @@ export const flatMap: {
2973
2973
  * multiple inner streams may run at the same time and their outputs are merged
2974
2974
  * as they arrive.
2975
2975
  *
2976
- * **Example** (FlatMapping stream values)
2976
+ * **Example** (Flat mapping stream values)
2977
2977
  *
2978
2978
  * ```ts
2979
2979
  * import { Console, Effect, Stream } from "effect"
@@ -19522,7 +19522,7 @@ export const runForEachWhile: {
19522
19522
  if (!b) done = true
19523
19523
  }
19524
19524
  }),
19525
- () => done
19525
+ () => !done
19526
19526
  )
19527
19527
  }))
19528
19528
 
package/src/String.ts CHANGED
@@ -102,7 +102,7 @@ export const Equivalence: Equ.Equivalence<string> = Equ.String
102
102
  *
103
103
  * Use when you need the canonical empty string value from the `String` module.
104
104
  *
105
- * **Example** (Using the empty string)
105
+ * **Example** (Referencing the empty string)
106
106
  *
107
107
  * ```ts
108
108
  * import { String } from "effect"
package/src/Struct.ts CHANGED
@@ -199,7 +199,7 @@ export const get: {
199
199
  *
200
200
  * Symbol keys are excluded; only string keys are returned.
201
201
  *
202
- * **Example** (Typed keys)
202
+ * **Example** (Reading typed keys)
203
203
  *
204
204
  * ```ts
205
205
  * import { Struct } from "effect"
package/src/Types.ts CHANGED
@@ -31,7 +31,7 @@ type TupleOf_<T, N extends number, R extends Array<unknown>> = `${N}` extends `-
31
31
  * - If `N` is the general `number` type (non-literal), degrades to `Array<T>`.
32
32
  * - Negative numbers produce `never`.
33
33
  *
34
- * **Example** (Fixed-length tuple)
34
+ * **Example** (Checking fixed-length tuples)
35
35
  *
36
36
  * ```ts
37
37
  * import type { Types } from "effect"
@@ -66,7 +66,7 @@ export type TupleOf<N extends number, T> = N extends N ? number extends N ? Arra
66
66
  *
67
67
  * Produces a tuple with `N` fixed positions followed by `...Array<T>`.
68
68
  *
69
- * **Example** (Minimum-length tuple)
69
+ * **Example** (Checking minimum-length tuples)
70
70
  *
71
71
  * ```ts
72
72
  * import type { Types } from "effect"
@@ -201,7 +201,7 @@ export type ExtractTag<E, K extends string> = E extends { readonly _tag: infer T
201
201
  * - If the union members are incompatible (e.g. `string | number`), the
202
202
  * result is `never`.
203
203
  *
204
- * **Example** (Union to intersection)
204
+ * **Example** (Converting a union to an intersection)
205
205
  *
206
206
  * ```ts
207
207
  * import type { Types } from "effect"
@@ -264,7 +264,7 @@ export type Simplify<A> = {
264
264
  * distinguishing between `any`, `unknown`, `never`, and other types.
265
265
  * - Resolves to `true` if `X` and `Y` are identical, `false` otherwise.
266
266
  *
267
- * **Example** (Type equality check)
267
+ * **Example** (Checking type equality)
268
268
  *
269
269
  * ```ts
270
270
  * import type { Types } from "effect"
@@ -295,7 +295,7 @@ export type Equals<X, Y> = (<T>() => T extends X ? 1 : 2) extends <
295
295
  *
296
296
  * Returns `Y` when `A` and `B` are equal, `N` otherwise.
297
297
  *
298
- * **Example** (Conditional type based on equality)
298
+ * **Example** (Choosing a conditional type based on equality)
299
299
  *
300
300
  * ```ts
301
301
  * import type { Types } from "effect"
@@ -324,7 +324,7 @@ export type EqualsWith<A, B, Y, N> = (<T>() => T extends A ? 1 : 2) extends (<T>
324
324
  * Returns `true` if at least one key from `Key` exists in `A`, `false`
325
325
  * otherwise.
326
326
  *
327
- * **Example** (Key presence check)
327
+ * **Example** (Checking key presence)
328
328
  *
329
329
  * ```ts
330
330
  * import type { Types } from "effect"
@@ -352,7 +352,7 @@ export type Has<A, Key extends string> = (Key extends infer K ? K extends keyof
352
352
  *
353
353
  * Implemented as `MergeRight<Target, Source>`.
354
354
  *
355
- * **Example** (Left-biased merge)
355
+ * **Example** (Merging with left bias)
356
356
  *
357
357
  * ```ts
358
358
  * import type { Types } from "effect"
@@ -423,7 +423,7 @@ export type MergeRight<Target, Source> = Simplify<
423
423
  * - `"unbounded"` — run all effects concurrently with no limit.
424
424
  * - `"inherit"` — inherit the concurrency from the surrounding context.
425
425
  *
426
- * **Example** (Concurrency values)
426
+ * **Example** (Setting concurrency values)
427
427
  *
428
428
  * ```ts
429
429
  * import type { Types } from "effect"
@@ -451,7 +451,7 @@ export type Concurrency = number | "unbounded" | "inherit"
451
451
  *
452
452
  * Only affects the top level; nested properties remain readonly.
453
453
  *
454
- * **Example** (Shallow mutable conversion)
454
+ * **Example** (Converting shallowly to mutable types)
455
455
  *
456
456
  * ```ts
457
457
  * import type { Types } from "effect"
@@ -492,7 +492,7 @@ export type Mutable<T> = {
492
492
  * Recursion stops at primitives (`string`, `number`, `boolean`, `bigint`,
493
493
  * `symbol`) and functions.
494
494
  *
495
- * **Example** (Deep mutable conversion)
495
+ * **Example** (Converting deeply to mutable types)
496
496
  *
497
497
  * ```ts
498
498
  * import type { Types } from "effect"
@@ -557,7 +557,7 @@ export type NoInfer<A> = [A][A extends any ? 0 : never]
557
557
  * A value of type `Invariant<A>` cannot be assigned to `Invariant<B>` unless
558
558
  * `A` and `B` are the same type.
559
559
  *
560
- * **Example** (Invariant phantom type)
560
+ * **Example** (Defining an invariant phantom type)
561
561
  *
562
562
  * ```ts
563
563
  * import type { Types } from "effect"
@@ -625,7 +625,7 @@ export declare namespace Invariant {
625
625
  * `Covariant<A>` is assignable to `Covariant<B>` when `A extends B`, following
626
626
  * the subtype direction.
627
627
  *
628
- * **Example** (Covariant phantom type)
628
+ * **Example** (Defining a covariant phantom type)
629
629
  *
630
630
  * ```ts
631
631
  * import type { Types } from "effect"
@@ -693,7 +693,7 @@ export declare namespace Covariant {
693
693
  * `Contravariant<A>` is assignable to `Contravariant<B>` when `B extends A`,
694
694
  * following the supertype direction.
695
695
  *
696
- * **Example** (Contravariant phantom type)
696
+ * **Example** (Defining a contravariant phantom type)
697
697
  *
698
698
  * ```ts
699
699
  * import type { Types } from "effect"
@@ -933,6 +933,11 @@ export const succeedNone: Effect.Effect<Option.Option<never>> = succeed(
933
933
  Option.none()
934
934
  )
935
935
 
936
+ /** @internal */
937
+ export const transposeOption = <A = never, E = never, R = never>(
938
+ self: Option.Option<Effect.Effect<A, E, R>>
939
+ ): Effect.Effect<Option.Option<A>, E, R> => Option.isNone(self) ? succeedNone : map(self.value, Option.some)
940
+
936
941
  /** @internal */
937
942
  export const failCauseSync = <E>(
938
943
  evaluate: LazyArg<Cause.Cause<E>>
@@ -950,17 +955,24 @@ const void_: Effect.Effect<void> = succeed(void 0)
950
955
  export { void_ as void }
951
956
 
952
957
  /** @internal */
953
- const try_ = <A, E>(options: {
954
- try: LazyArg<A>
955
- catch: (error: unknown) => E
956
- }): Effect.Effect<A, E> =>
957
- suspend(() => {
958
+ const try_ = <A, E = Cause.UnknownError>(
959
+ options: {
960
+ readonly try: LazyArg<A>
961
+ readonly catch: (error: unknown) => E
962
+ } | LazyArg<A>
963
+ ): Effect.Effect<A, E> => {
964
+ const evaluate = typeof options === "function" ? options : options.try
965
+ const catcher = typeof options === "function"
966
+ ? ((cause: unknown) => new UnknownError(cause, "An error occurred in Effect.try"))
967
+ : options.catch
968
+ return suspend(() => {
958
969
  try {
959
- return succeed(internalCall(options.try))
970
+ return succeed(internalCall(evaluate))
960
971
  } catch (err) {
961
- return fail(internalCall(() => options.catch(err)))
972
+ return fail(internalCall(() => catcher(err)) as E)
962
973
  }
963
974
  })
975
+ }
964
976
  /** @internal */
965
977
  export { try_ as try }
966
978
 
@@ -987,15 +999,22 @@ export const tryPromise = <A, E = Cause.UnknownError>(
987
999
  ? ((cause: unknown) => new UnknownError(cause, "An error occurred in Effect.tryPromise"))
988
1000
  : options.catch
989
1001
  return callbackOptions<A, E>(function(resume, signal) {
1002
+ const failWithCatch = (cause: unknown) => {
1003
+ try {
1004
+ resume(fail(internalCall(() => catcher(cause)) as E))
1005
+ } catch (err) {
1006
+ resume(die(err))
1007
+ }
1008
+ }
990
1009
  try {
991
1010
  internalCall(() => f(signal!)).then(
992
1011
  (a) => resume(succeed(a)),
993
- (e) => resume(fail(internalCall(() => catcher(e)) as E))
1012
+ failWithCatch
994
1013
  )
995
1014
  } catch (err) {
996
- resume(fail(internalCall(() => catcher(err)) as E))
1015
+ failWithCatch(err)
997
1016
  }
998
- }, eval.length !== 0)
1017
+ }, f.length !== 0)
999
1018
  }
1000
1019
 
1001
1020
  /** @internal */
@@ -0,0 +1,26 @@
1
+ import * as Cause from "../../Cause.ts"
2
+ import * as SchemaIssue from "../../SchemaIssue.ts"
3
+
4
+ /** @internal */
5
+ export function getSchemaIssue(cause: Cause.Cause<SchemaIssue.Issue>): SchemaIssue.Issue | undefined {
6
+ let issue: SchemaIssue.Issue | undefined
7
+ for (const reason of cause.reasons) {
8
+ if (!Cause.isFailReason(reason) || !SchemaIssue.isIssue(reason.error)) {
9
+ return undefined
10
+ }
11
+ issue ??= reason.error
12
+ }
13
+ return issue
14
+ }
15
+
16
+ /** @internal */
17
+ export function getSchemaIssueOrThrow(
18
+ cause: Cause.Cause<SchemaIssue.Issue>,
19
+ message: string
20
+ ): SchemaIssue.Issue {
21
+ const issue = getSchemaIssue(cause)
22
+ if (issue === undefined) {
23
+ throw new Error(message, { cause })
24
+ }
25
+ return issue
26
+ }
@@ -1,5 +1,7 @@
1
+ import * as Cause from "../../Cause.ts"
2
+ import * as Data from "../../Data.ts"
1
3
  import * as Effect from "../../Effect.ts"
2
- import { flow } from "../../Function.ts"
4
+ import * as Exit from "../../Exit.ts"
3
5
  import * as Pipeable from "../../Pipeable.ts"
4
6
  import type * as Schema from "../../Schema.ts"
5
7
  import * as SchemaAST from "../../SchemaAST.ts"
@@ -33,7 +35,8 @@ export function make<S extends Schema.Top>(ast: S["ast"], options?: object): S {
33
35
  }
34
36
  self.ast = ast
35
37
  self.rebuild = (ast: SchemaAST.AST) => make(ast, options)
36
- self.makeEffect = flow(SchemaParser.makeEffect(self), Effect.mapErrorEager((issue) => new SchemaError(issue)))
38
+ self.makeEffect = (input: S["~type.make.in"], options?: Schema.MakeOptions) =>
39
+ mapSchemaIssueEffect(SchemaParser.makeEffect(self)(input, options))
37
40
  self.make = SchemaParser.make(self)
38
41
  self.makeOption = SchemaParser.makeOption(self)
39
42
  return self
@@ -42,23 +45,46 @@ export function make<S extends Schema.Top>(ast: S["ast"], options?: object): S {
42
45
  /** @internal */
43
46
  export const SchemaErrorTypeId = "~effect/Schema/SchemaError"
44
47
 
45
- // not internal
46
- export class SchemaError {
47
- readonly [SchemaErrorTypeId] = SchemaErrorTypeId
48
- readonly _tag = "SchemaError"
49
- readonly name: string = "SchemaError"
48
+ // purposefully not internal
49
+ export class SchemaError extends Data.TaggedError("SchemaError")<{
50
50
  readonly issue: Issue
51
+ }> {
52
+ readonly [SchemaErrorTypeId]: typeof SchemaErrorTypeId = SchemaErrorTypeId
51
53
  constructor(issue: Issue) {
52
- this.issue = issue
54
+ super({ issue })
53
55
  }
54
- get message() {
56
+ override get message() {
55
57
  return this.issue.toString()
56
58
  }
57
- toString() {
59
+ override toString() {
58
60
  return `SchemaError(${this.message})`
59
61
  }
60
62
  }
61
63
 
64
+ /** @internal */
65
+ export function mapSchemaIssueEffect<A, R>(
66
+ self: Effect.Effect<A, Issue, R>
67
+ ): Effect.Effect<A, SchemaError, R> {
68
+ return Effect.catchCause(
69
+ self,
70
+ (cause) => Effect.failCauseSync(() => Cause.map(cause, (issue) => new SchemaError(issue)))
71
+ )
72
+ }
73
+
74
+ /** @internal */
75
+ export function mapSchemaErrorEffect<A, R>(
76
+ self: Effect.Effect<A, SchemaError, R>
77
+ ): Effect.Effect<A, Issue, R> {
78
+ return Effect.catchCause(self, (cause) => Effect.failCauseSync(() => Cause.map(cause, (error) => error.issue)))
79
+ }
80
+
81
+ /** @internal */
82
+ export function mapSchemaIssueExit<A>(exit: Exit.Exit<A, Issue>): Exit.Exit<A, SchemaError> {
83
+ return Exit.isSuccess(exit)
84
+ ? Exit.succeed(exit.value)
85
+ : Exit.failCause(Cause.map(exit.cause, (issue) => new SchemaError(issue)))
86
+ }
87
+
62
88
  /** @internal */
63
89
  export const jsonReorder = makeReorder(getJsonPriority)
64
90
 
@@ -154,7 +154,7 @@ export class Asserts<S extends Schema.Top> {
154
154
  *
155
155
  * FastCheck generates arbitrary values matching the schema's `Type`. The assertion fails if any generated value does not round-trip. Pass `options.params` to control FastCheck parameters such as `numRuns`.
156
156
  *
157
- * **Example** (Round-trip verification)
157
+ * **Example** (Verifying round trips)
158
158
  *
159
159
  * ```ts
160
160
  * import { Schema } from "effect"
@@ -338,7 +338,7 @@ export class Decoding<S extends Schema.Top> {
338
338
  *
339
339
  * Use to verify successful decoding for one input case.
340
340
  *
341
- * **Example** (Identity and transformed decoding)
341
+ * **Example** (Testing identity and transformed decoding)
342
342
  *
343
343
  * ```ts
344
344
  * import { Schema } from "effect"
@@ -478,7 +478,7 @@ export class Encoding<S extends Schema.Top> {
478
478
  *
479
479
  * Use to verify successful encoding for one input case.
480
480
  *
481
- * **Example** (Identity and transformed encoding)
481
+ * **Example** (Testing identity and transformed encoding)
482
482
  *
483
483
  * ```ts
484
484
  * import { Schema } from "effect"
@@ -181,7 +181,7 @@ export class NetworkError extends Schema.ErrorClass<NetworkError>(
181
181
  * Provider-specific metadata is namespaced by provider name. Each provider
182
182
  * value can contain arbitrary mutable JSON metadata or `null`.
183
183
  *
184
- * **Example** (Metadata shape)
184
+ * **Example** (Inspecting metadata shape)
185
185
  *
186
186
  * ```ts
187
187
  * const metadata = {
@@ -46,7 +46,7 @@ import type * as Tool from "./Tool.ts"
46
46
  * enabling persistent conversational AI interactions with full context
47
47
  * management.
48
48
  *
49
- * **Example** (Using the Chat service)
49
+ * **Example** (Accessing the Chat service)
50
50
  *
51
51
  * ```ts
52
52
  * import { Effect } from "effect"
@@ -1422,7 +1422,7 @@ const runLoop = Effect.fnUntraced(
1422
1422
  yield* Effect.orDie(terminal.display(msg))
1423
1423
  if (loop.events) {
1424
1424
  const takeInput = Queue.take(input).pipe(
1425
- Effect.map((event) => ({ _tag: "Input" as const, event }))
1425
+ Effect.map((input) => ({ _tag: "Input" as const, input }))
1426
1426
  )
1427
1427
  const result = yield* Effect.raceFirst(
1428
1428
  takeInput,
@@ -87,7 +87,7 @@ export type ScalarConfig = {
87
87
  /**
88
88
  * Path to a favicon image.
89
89
  *
90
- * **Example** (Relative favicon)
90
+ * **Example** (Setting a relative favicon)
91
91
  *
92
92
  * ```ts
93
93
  * const favicon = "/favicon.svg"
@@ -107,7 +107,7 @@ export type ScalarConfig = {
107
107
  * Browsers can derive the origin from `window.location.origin`; server
108
108
  * rendering needs this value supplied explicitly.
109
109
  *
110
- * **Example** (Local server URL)
110
+ * **Example** (Setting a local server URL)
111
111
  *
112
112
  * ```ts
113
113
  * const baseServerURL = "http://localhost:3000"
@@ -34,13 +34,18 @@ declare module "../../Schema.ts" {
34
34
  }
35
35
 
36
36
  /**
37
- * @internal
37
+ * HTTP API body encoding metadata used by payloads and responses.
38
+ *
39
+ * @category models
40
+ * @since 4.0.0
38
41
  */
39
42
  export type Encoding = PayloadEncoding | ResponseEncoding
40
43
 
41
44
  /**
42
- * Encodings for payloads
43
- * @internal
45
+ * HTTP API request payload encoding metadata.
46
+ *
47
+ * @category models
48
+ * @since 4.0.0
44
49
  */
45
50
  export type PayloadEncoding =
46
51
  | {
@@ -55,8 +60,10 @@ export type PayloadEncoding =
55
60
  }
56
61
 
57
62
  /**
58
- * Encodings for responses
59
- * @internal
63
+ * HTTP API response body encoding metadata.
64
+ *
65
+ * @category models
66
+ * @since 4.0.0
60
67
  */
61
68
  export type ResponseEncoding = {
62
69
  readonly _tag: "Json" | "FormUrlEncoded" | "Uint8Array" | "Text"
@@ -360,7 +367,12 @@ export interface StreamUint8Array extends
360
367
  readonly contentType: string
361
368
  }
362
369
 
363
- /** @internal */
370
+ /**
371
+ * Schema for a streaming HTTP API success response.
372
+ *
373
+ * @category models
374
+ * @since 4.0.0
375
+ */
364
376
  export type StreamSchema = StreamSse<Sse.EventCodec, Schema.Top, unknown> | StreamUint8Array
365
377
 
366
378
  /** @internal */
@@ -955,7 +955,7 @@ export const make = <
955
955
  /**
956
956
  * Creates a custom `Rpc` constructor that can transform the output schemas.
957
957
  *
958
- * **Example** (Paginated RPC constructor)
958
+ * **Example** (Defining a paginated RPC constructor)
959
959
  *
960
960
  * ```ts
961
961
  * import { Schema } from "effect"
@@ -303,14 +303,13 @@ const RpcGroupProto = {
303
303
  const services = yield* Effect.context<never>()
304
304
  const handlers = Effect.isEffect(build) ? yield* build : build
305
305
  const contextMap = new Map<string, unknown>()
306
- for (const [tag, handler] of Object.entries(handlers)) {
307
- const rpc = self.requests.get(tag)!
306
+ self.requests.forEach((rpc, tag) => {
308
307
  contextMap.set(rpc.key, {
309
308
  tag: rpc._tag,
310
- handler,
309
+ handler: handlers[tag],
311
310
  context: services
312
311
  })
313
- }
312
+ })
314
313
  return Context.makeUnsafe(contextMap)
315
314
  })
316
315
  },