effect 4.0.0-beta.30 → 4.0.0-beta.32

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 (514) hide show
  1. package/dist/Array.d.ts +87 -86
  2. package/dist/Array.d.ts.map +1 -1
  3. package/dist/Array.js +47 -40
  4. package/dist/Array.js.map +1 -1
  5. package/dist/BigDecimal.d.ts +46 -45
  6. package/dist/BigDecimal.d.ts.map +1 -1
  7. package/dist/BigDecimal.js +35 -38
  8. package/dist/BigDecimal.js.map +1 -1
  9. package/dist/BigInt.d.ts +39 -32
  10. package/dist/BigInt.d.ts.map +1 -1
  11. package/dist/BigInt.js +32 -29
  12. package/dist/BigInt.js.map +1 -1
  13. package/dist/Channel.d.ts +2 -2
  14. package/dist/Channel.d.ts.map +1 -1
  15. package/dist/Channel.js.map +1 -1
  16. package/dist/Chunk.d.ts +58 -57
  17. package/dist/Chunk.d.ts.map +1 -1
  18. package/dist/Chunk.js +20 -21
  19. package/dist/Chunk.js.map +1 -1
  20. package/dist/Config.d.ts.map +1 -1
  21. package/dist/Config.js +4 -1
  22. package/dist/Config.js.map +1 -1
  23. package/dist/Cron.d.ts +3 -6
  24. package/dist/Cron.d.ts.map +1 -1
  25. package/dist/Cron.js +11 -18
  26. package/dist/Cron.js.map +1 -1
  27. package/dist/DateTime.d.ts +49 -92
  28. package/dist/DateTime.d.ts.map +1 -1
  29. package/dist/DateTime.js +9 -9
  30. package/dist/DateTime.js.map +1 -1
  31. package/dist/Deferred.d.ts +7 -5
  32. package/dist/Deferred.d.ts.map +1 -1
  33. package/dist/Deferred.js +7 -5
  34. package/dist/Deferred.js.map +1 -1
  35. package/dist/Duration.d.ts +55 -25
  36. package/dist/Duration.d.ts.map +1 -1
  37. package/dist/Duration.js +100 -70
  38. package/dist/Duration.js.map +1 -1
  39. package/dist/Effect.d.ts.map +1 -1
  40. package/dist/Effect.js +3 -4
  41. package/dist/Effect.js.map +1 -1
  42. package/dist/Fiber.d.ts +2 -1
  43. package/dist/Fiber.d.ts.map +1 -1
  44. package/dist/Fiber.js.map +1 -1
  45. package/dist/FiberHandle.d.ts +9 -8
  46. package/dist/FiberHandle.d.ts.map +1 -1
  47. package/dist/FiberHandle.js +8 -7
  48. package/dist/FiberHandle.js.map +1 -1
  49. package/dist/FiberMap.d.ts +20 -19
  50. package/dist/FiberMap.d.ts.map +1 -1
  51. package/dist/FiberMap.js +6 -6
  52. package/dist/FiberMap.js.map +1 -1
  53. package/dist/FileSystem.d.ts +17 -16
  54. package/dist/FileSystem.d.ts.map +1 -1
  55. package/dist/FileSystem.js +10 -7
  56. package/dist/FileSystem.js.map +1 -1
  57. package/dist/Graph.d.ts +64 -64
  58. package/dist/Graph.d.ts.map +1 -1
  59. package/dist/Graph.js +53 -53
  60. package/dist/Graph.js.map +1 -1
  61. package/dist/HashMap.d.ts +11 -5
  62. package/dist/HashMap.d.ts.map +1 -1
  63. package/dist/HashMap.js +3 -1
  64. package/dist/HashMap.js.map +1 -1
  65. package/dist/Iterable.d.ts +11 -11
  66. package/dist/Iterable.d.ts.map +1 -1
  67. package/dist/Iterable.js +12 -12
  68. package/dist/Iterable.js.map +1 -1
  69. package/dist/Latch.d.ts +69 -3
  70. package/dist/Latch.d.ts.map +1 -1
  71. package/dist/Latch.js +58 -0
  72. package/dist/Latch.js.map +1 -1
  73. package/dist/Layer.d.ts +181 -2
  74. package/dist/Layer.d.ts.map +1 -1
  75. package/dist/Layer.js +35 -2
  76. package/dist/Layer.js.map +1 -1
  77. package/dist/Number.d.ts +74 -18
  78. package/dist/Number.d.ts.map +1 -1
  79. package/dist/Number.js +34 -15
  80. package/dist/Number.js.map +1 -1
  81. package/dist/Option.d.ts +2 -0
  82. package/dist/Option.d.ts.map +1 -1
  83. package/dist/Option.js.map +1 -1
  84. package/dist/PartitionedSemaphore.d.ts +183 -0
  85. package/dist/PartitionedSemaphore.d.ts.map +1 -0
  86. package/dist/PartitionedSemaphore.js +231 -0
  87. package/dist/PartitionedSemaphore.js.map +1 -0
  88. package/dist/PubSub.d.ts +5 -4
  89. package/dist/PubSub.d.ts.map +1 -1
  90. package/dist/PubSub.js +6 -5
  91. package/dist/PubSub.js.map +1 -1
  92. package/dist/Queue.d.ts +3 -3
  93. package/dist/Queue.d.ts.map +1 -1
  94. package/dist/Queue.js +2 -2
  95. package/dist/Queue.js.map +1 -1
  96. package/dist/Record.d.ts +40 -40
  97. package/dist/Record.d.ts.map +1 -1
  98. package/dist/Record.js +16 -15
  99. package/dist/Record.js.map +1 -1
  100. package/dist/Scheduler.d.ts +25 -123
  101. package/dist/Scheduler.d.ts.map +1 -1
  102. package/dist/Scheduler.js +20 -123
  103. package/dist/Scheduler.js.map +1 -1
  104. package/dist/Schema.d.ts +2346 -114
  105. package/dist/Schema.d.ts.map +1 -1
  106. package/dist/Schema.js +1359 -68
  107. package/dist/Schema.js.map +1 -1
  108. package/dist/SchemaAST.d.ts +2 -2
  109. package/dist/SchemaAST.js +2 -2
  110. package/dist/SchemaGetter.js +6 -4
  111. package/dist/SchemaGetter.js.map +1 -1
  112. package/dist/SchemaRepresentation.d.ts +2 -2
  113. package/dist/SchemaRepresentation.d.ts.map +1 -1
  114. package/dist/SchemaRepresentation.js.map +1 -1
  115. package/dist/SchemaTransformation.d.ts.map +1 -1
  116. package/dist/SchemaTransformation.js +32 -27
  117. package/dist/SchemaTransformation.js.map +1 -1
  118. package/dist/Semaphore.d.ts +149 -53
  119. package/dist/Semaphore.d.ts.map +1 -1
  120. package/dist/Semaphore.js +137 -117
  121. package/dist/Semaphore.js.map +1 -1
  122. package/dist/ServiceMap.d.ts +26 -0
  123. package/dist/ServiceMap.d.ts.map +1 -1
  124. package/dist/ServiceMap.js +36 -21
  125. package/dist/ServiceMap.js.map +1 -1
  126. package/dist/Stream.js +1 -1
  127. package/dist/Stream.js.map +1 -1
  128. package/dist/String.d.ts +114 -47
  129. package/dist/String.d.ts.map +1 -1
  130. package/dist/String.js +29 -47
  131. package/dist/String.js.map +1 -1
  132. package/dist/SubscriptionRef.d.ts +1 -2
  133. package/dist/SubscriptionRef.d.ts.map +1 -1
  134. package/dist/SubscriptionRef.js +81 -115
  135. package/dist/SubscriptionRef.js.map +1 -1
  136. package/dist/Terminal.d.ts +2 -1
  137. package/dist/Terminal.d.ts.map +1 -1
  138. package/dist/Terminal.js.map +1 -1
  139. package/dist/Tracer.d.ts +5 -4
  140. package/dist/Tracer.d.ts.map +1 -1
  141. package/dist/Tracer.js +2 -1
  142. package/dist/Tracer.js.map +1 -1
  143. package/dist/Trie.d.ts +26 -14
  144. package/dist/Trie.d.ts.map +1 -1
  145. package/dist/Trie.js +8 -4
  146. package/dist/Trie.js.map +1 -1
  147. package/dist/TxHashMap.d.ts +77 -59
  148. package/dist/TxHashMap.d.ts.map +1 -1
  149. package/dist/TxHashMap.js +25 -19
  150. package/dist/TxHashMap.js.map +1 -1
  151. package/dist/TxSemaphore.d.ts +162 -2
  152. package/dist/TxSemaphore.d.ts.map +1 -1
  153. package/dist/TxSemaphore.js +16 -2
  154. package/dist/TxSemaphore.js.map +1 -1
  155. package/dist/index.d.ts +88 -32
  156. package/dist/index.d.ts.map +1 -1
  157. package/dist/index.js +88 -32
  158. package/dist/index.js.map +1 -1
  159. package/dist/internal/dateTime.js +66 -59
  160. package/dist/internal/dateTime.js.map +1 -1
  161. package/dist/internal/effect.js +21 -90
  162. package/dist/internal/effect.js.map +1 -1
  163. package/dist/internal/hashMap.js +2 -1
  164. package/dist/internal/hashMap.js.map +1 -1
  165. package/dist/internal/option.js +6 -0
  166. package/dist/internal/option.js.map +1 -1
  167. package/dist/internal/trie.js +3 -3
  168. package/dist/internal/trie.js.map +1 -1
  169. package/dist/unstable/ai/AiError.js +1 -1
  170. package/dist/unstable/ai/AiError.js.map +1 -1
  171. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
  172. package/dist/unstable/ai/AnthropicStructuredOutput.js +4 -0
  173. package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
  174. package/dist/unstable/ai/Chat.d.ts +3 -4
  175. package/dist/unstable/ai/Chat.d.ts.map +1 -1
  176. package/dist/unstable/ai/Chat.js +2 -2
  177. package/dist/unstable/ai/Chat.js.map +1 -1
  178. package/dist/unstable/ai/LanguageModel.d.ts +30 -16
  179. package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
  180. package/dist/unstable/ai/LanguageModel.js +10 -87
  181. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  182. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
  183. package/dist/unstable/ai/OpenAiStructuredOutput.js +4 -0
  184. package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
  185. package/dist/unstable/ai/Tool.d.ts +14 -0
  186. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  187. package/dist/unstable/ai/Tool.js +13 -0
  188. package/dist/unstable/ai/Tool.js.map +1 -1
  189. package/dist/unstable/cli/Argument.d.ts +2 -4
  190. package/dist/unstable/cli/Argument.d.ts.map +1 -1
  191. package/dist/unstable/cli/Argument.js +1 -3
  192. package/dist/unstable/cli/Argument.js.map +1 -1
  193. package/dist/unstable/cli/CliOutput.d.ts +3 -2
  194. package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
  195. package/dist/unstable/cli/CliOutput.js +4 -3
  196. package/dist/unstable/cli/CliOutput.js.map +1 -1
  197. package/dist/unstable/cli/Command.d.ts +3 -2
  198. package/dist/unstable/cli/Command.d.ts.map +1 -1
  199. package/dist/unstable/cli/Command.js +3 -3
  200. package/dist/unstable/cli/Command.js.map +1 -1
  201. package/dist/unstable/cli/Completions.d.ts +16 -0
  202. package/dist/unstable/cli/Completions.d.ts.map +1 -0
  203. package/dist/unstable/cli/Completions.js +23 -0
  204. package/dist/unstable/cli/Completions.js.map +1 -0
  205. package/dist/unstable/cli/Flag.d.ts +2 -2
  206. package/dist/unstable/cli/Flag.d.ts.map +1 -1
  207. package/dist/unstable/cli/Flag.js +1 -1
  208. package/dist/unstable/cli/Flag.js.map +1 -1
  209. package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -1
  210. package/dist/unstable/cli/GlobalFlag.js +4 -4
  211. package/dist/unstable/cli/GlobalFlag.js.map +1 -1
  212. package/dist/unstable/cli/HelpDoc.d.ts +14 -12
  213. package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
  214. package/dist/unstable/cli/Param.d.ts +4 -4
  215. package/dist/unstable/cli/Param.d.ts.map +1 -1
  216. package/dist/unstable/cli/Param.js +7 -7
  217. package/dist/unstable/cli/Param.js.map +1 -1
  218. package/dist/unstable/cli/Primitive.d.ts +1 -1
  219. package/dist/unstable/cli/Primitive.d.ts.map +1 -1
  220. package/dist/unstable/cli/Primitive.js.map +1 -1
  221. package/dist/unstable/cli/Prompt.js +71 -67
  222. package/dist/unstable/cli/Prompt.js.map +1 -1
  223. package/dist/unstable/cli/index.d.ts +4 -0
  224. package/dist/unstable/cli/index.d.ts.map +1 -1
  225. package/dist/unstable/cli/index.js +4 -0
  226. package/dist/unstable/cli/index.js.map +1 -1
  227. package/dist/unstable/cli/internal/completions/CommandDescriptor.js +9 -2
  228. package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
  229. package/dist/unstable/cli/internal/parser.js +8 -3
  230. package/dist/unstable/cli/internal/parser.js.map +1 -1
  231. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -2
  232. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  233. package/dist/unstable/cluster/ClusterWorkflowEngine.js +25 -23
  234. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  235. package/dist/unstable/cluster/DeliverAt.js +1 -1
  236. package/dist/unstable/cluster/DeliverAt.js.map +1 -1
  237. package/dist/unstable/cluster/Entity.d.ts +3 -2
  238. package/dist/unstable/cluster/Entity.d.ts.map +1 -1
  239. package/dist/unstable/cluster/Entity.js +7 -7
  240. package/dist/unstable/cluster/Entity.js.map +1 -1
  241. package/dist/unstable/cluster/Message.d.ts +4 -3
  242. package/dist/unstable/cluster/Message.d.ts.map +1 -1
  243. package/dist/unstable/cluster/Message.js +3 -2
  244. package/dist/unstable/cluster/Message.js.map +1 -1
  245. package/dist/unstable/cluster/MessageStorage.d.ts +10 -10
  246. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  247. package/dist/unstable/cluster/MessageStorage.js +12 -12
  248. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  249. package/dist/unstable/cluster/Reply.d.ts +2 -1
  250. package/dist/unstable/cluster/Reply.d.ts.map +1 -1
  251. package/dist/unstable/cluster/Reply.js +4 -3
  252. package/dist/unstable/cluster/Reply.js.map +1 -1
  253. package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
  254. package/dist/unstable/cluster/RunnerServer.js +9 -8
  255. package/dist/unstable/cluster/RunnerServer.js.map +1 -1
  256. package/dist/unstable/cluster/Runners.d.ts +2 -1
  257. package/dist/unstable/cluster/Runners.d.ts.map +1 -1
  258. package/dist/unstable/cluster/Runners.js +7 -6
  259. package/dist/unstable/cluster/Runners.js.map +1 -1
  260. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  261. package/dist/unstable/cluster/Sharding.js +19 -13
  262. package/dist/unstable/cluster/Sharding.js.map +1 -1
  263. package/dist/unstable/cluster/ShardingConfig.d.ts +5 -4
  264. package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
  265. package/dist/unstable/cluster/ShardingConfig.js +4 -4
  266. package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
  267. package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
  268. package/dist/unstable/cluster/SqlMessageStorage.js +19 -18
  269. package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
  270. package/dist/unstable/cluster/internal/entityManager.js +9 -10
  271. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  272. package/dist/unstable/devtools/DevToolsSchema.d.ts +2 -1
  273. package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
  274. package/dist/unstable/devtools/DevToolsSchema.js +1 -4
  275. package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
  276. package/dist/unstable/encoding/Ndjson.d.ts +8 -8
  277. package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
  278. package/dist/unstable/encoding/Ndjson.js.map +1 -1
  279. package/dist/unstable/http/Cookies.d.ts +5 -4
  280. package/dist/unstable/http/Cookies.d.ts.map +1 -1
  281. package/dist/unstable/http/Cookies.js +3 -4
  282. package/dist/unstable/http/Cookies.js.map +1 -1
  283. package/dist/unstable/http/Etag.d.ts.map +1 -1
  284. package/dist/unstable/http/Etag.js +5 -1
  285. package/dist/unstable/http/Etag.js.map +1 -1
  286. package/dist/unstable/http/Headers.d.ts +3 -2
  287. package/dist/unstable/http/Headers.d.ts.map +1 -1
  288. package/dist/unstable/http/Headers.js +2 -1
  289. package/dist/unstable/http/Headers.js.map +1 -1
  290. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  291. package/dist/unstable/http/HttpClient.js +2 -1
  292. package/dist/unstable/http/HttpClient.js.map +1 -1
  293. package/dist/unstable/http/HttpClientRequest.d.ts +4 -3
  294. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  295. package/dist/unstable/http/HttpClientRequest.js +8 -6
  296. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  297. package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
  298. package/dist/unstable/http/HttpClientResponse.js +2 -1
  299. package/dist/unstable/http/HttpClientResponse.js.map +1 -1
  300. package/dist/unstable/http/HttpIncomingMessage.d.ts +3 -2
  301. package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
  302. package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
  303. package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
  304. package/dist/unstable/http/HttpMiddleware.js +16 -15
  305. package/dist/unstable/http/HttpMiddleware.js.map +1 -1
  306. package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
  307. package/dist/unstable/http/HttpPlatform.js +3 -2
  308. package/dist/unstable/http/HttpPlatform.js.map +1 -1
  309. package/dist/unstable/http/HttpRouter.d.ts +2 -1
  310. package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
  311. package/dist/unstable/http/HttpRouter.js +7 -7
  312. package/dist/unstable/http/HttpRouter.js.map +1 -1
  313. package/dist/unstable/http/HttpServer.d.ts.map +1 -1
  314. package/dist/unstable/http/HttpServer.js +2 -2
  315. package/dist/unstable/http/HttpServer.js.map +1 -1
  316. package/dist/unstable/http/HttpServerError.d.ts +2 -1
  317. package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
  318. package/dist/unstable/http/HttpServerError.js +2 -1
  319. package/dist/unstable/http/HttpServerError.js.map +1 -1
  320. package/dist/unstable/http/HttpServerRequest.d.ts +3 -2
  321. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  322. package/dist/unstable/http/HttpServerRequest.js +14 -10
  323. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  324. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  325. package/dist/unstable/http/HttpServerResponse.js +4 -3
  326. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  327. package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
  328. package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
  329. package/dist/unstable/http/HttpTraceContext.js +27 -15
  330. package/dist/unstable/http/HttpTraceContext.js.map +1 -1
  331. package/dist/unstable/http/UrlParams.d.ts +5 -4
  332. package/dist/unstable/http/UrlParams.d.ts.map +1 -1
  333. package/dist/unstable/http/UrlParams.js +5 -6
  334. package/dist/unstable/http/UrlParams.js.map +1 -1
  335. package/dist/unstable/httpapi/HttpApiBuilder.d.ts +2 -2
  336. package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
  337. package/dist/unstable/httpapi/HttpApiBuilder.js +4 -2
  338. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  339. package/dist/unstable/httpapi/HttpApiError.d.ts +15 -0
  340. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  341. package/dist/unstable/httpapi/HttpApiError.js +81 -3
  342. package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
  343. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  344. package/dist/unstable/observability/OtlpExporter.js +2 -2
  345. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  346. package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
  347. package/dist/unstable/observability/OtlpTracer.js +7 -3
  348. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  349. package/dist/unstable/persistence/Persistable.js +1 -1
  350. package/dist/unstable/persistence/Persistable.js.map +1 -1
  351. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  352. package/dist/unstable/reactivity/Atom.js +1 -5
  353. package/dist/unstable/reactivity/Atom.js.map +1 -1
  354. package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
  355. package/dist/unstable/reactivity/AtomRegistry.js +4 -2
  356. package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
  357. package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
  358. package/dist/unstable/rpc/Rpc.js +4 -3
  359. package/dist/unstable/rpc/Rpc.js.map +1 -1
  360. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  361. package/dist/unstable/rpc/RpcClient.js +4 -4
  362. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  363. package/dist/unstable/rpc/RpcGroup.d.ts +1 -3
  364. package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
  365. package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
  366. package/dist/unstable/rpc/RpcSchema.js +3 -2
  367. package/dist/unstable/rpc/RpcSchema.js.map +1 -1
  368. package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
  369. package/dist/unstable/rpc/RpcSerialization.js +4 -1
  370. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  371. package/dist/unstable/rpc/RpcServer.d.ts +1 -1
  372. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  373. package/dist/unstable/rpc/RpcServer.js +3 -2
  374. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  375. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  376. package/dist/unstable/socket/Socket.js +2 -1
  377. package/dist/unstable/socket/Socket.js.map +1 -1
  378. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  379. package/dist/unstable/sql/SqlClient.js +1 -1
  380. package/dist/unstable/sql/SqlClient.js.map +1 -1
  381. package/dist/unstable/workflow/DurableDeferred.js +6 -6
  382. package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
  383. package/dist/unstable/workflow/Workflow.d.ts +2 -1
  384. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  385. package/dist/unstable/workflow/WorkflowEngine.d.ts +5 -4
  386. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  387. package/dist/unstable/workflow/WorkflowEngine.js +19 -14
  388. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  389. package/package.json +1 -1
  390. package/src/Array.ts +112 -105
  391. package/src/BigDecimal.ts +63 -66
  392. package/src/BigInt.ts +49 -41
  393. package/src/Channel.ts +3 -3
  394. package/src/Chunk.ts +68 -63
  395. package/src/Config.ts +4 -1
  396. package/src/Cron.ts +13 -18
  397. package/src/DateTime.ts +51 -92
  398. package/src/Deferred.ts +8 -6
  399. package/src/Duration.ts +112 -56
  400. package/src/Effect.ts +3 -4
  401. package/src/Fiber.ts +2 -1
  402. package/src/FiberHandle.ts +10 -9
  403. package/src/FiberMap.ts +22 -22
  404. package/src/FileSystem.ts +25 -22
  405. package/src/Graph.ts +105 -105
  406. package/src/HashMap.ts +11 -5
  407. package/src/Iterable.ts +13 -13
  408. package/src/Latch.ts +85 -3
  409. package/src/Layer.ts +244 -19
  410. package/src/Number.ts +85 -26
  411. package/src/Option.ts +2 -0
  412. package/src/PartitionedSemaphore.ts +414 -0
  413. package/src/PubSub.ts +7 -6
  414. package/src/Queue.ts +5 -5
  415. package/src/Record.ts +52 -47
  416. package/src/Scheduler.ts +37 -126
  417. package/src/Schema.ts +2366 -116
  418. package/src/SchemaAST.ts +2 -2
  419. package/src/SchemaGetter.ts +4 -4
  420. package/src/SchemaRepresentation.ts +2 -2
  421. package/src/SchemaTransformation.ts +27 -27
  422. package/src/Semaphore.ts +271 -183
  423. package/src/ServiceMap.ts +83 -31
  424. package/src/Stream.ts +1 -1
  425. package/src/String.ts +122 -69
  426. package/src/SubscriptionRef.ts +96 -117
  427. package/src/Terminal.ts +2 -1
  428. package/src/Tracer.ts +6 -5
  429. package/src/Trie.ts +26 -14
  430. package/src/TxHashMap.ts +78 -60
  431. package/src/TxSemaphore.ts +186 -11
  432. package/src/index.ts +89 -33
  433. package/src/internal/dateTime.ts +74 -65
  434. package/src/internal/effect.ts +30 -122
  435. package/src/internal/hashMap.ts +4 -3
  436. package/src/internal/option.ts +7 -0
  437. package/src/internal/trie.ts +6 -6
  438. package/src/unstable/ai/AiError.ts +1 -1
  439. package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -0
  440. package/src/unstable/ai/Chat.ts +17 -15
  441. package/src/unstable/ai/LanguageModel.ts +148 -97
  442. package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -0
  443. package/src/unstable/ai/Tool.ts +20 -0
  444. package/src/unstable/cli/Argument.ts +2 -4
  445. package/src/unstable/cli/CliOutput.ts +7 -5
  446. package/src/unstable/cli/Command.ts +5 -5
  447. package/src/unstable/cli/Completions.ts +36 -0
  448. package/src/unstable/cli/Flag.ts +2 -2
  449. package/src/unstable/cli/GlobalFlag.ts +4 -5
  450. package/src/unstable/cli/HelpDoc.ts +14 -12
  451. package/src/unstable/cli/Param.ts +15 -11
  452. package/src/unstable/cli/Primitive.ts +1 -1
  453. package/src/unstable/cli/Prompt.ts +81 -83
  454. package/src/unstable/cli/index.ts +5 -0
  455. package/src/unstable/cli/internal/completions/CommandDescriptor.ts +3 -2
  456. package/src/unstable/cli/internal/parser.ts +7 -4
  457. package/src/unstable/cluster/ClusterWorkflowEngine.ts +35 -30
  458. package/src/unstable/cluster/DeliverAt.ts +1 -1
  459. package/src/unstable/cluster/Entity.ts +13 -12
  460. package/src/unstable/cluster/Message.ts +6 -5
  461. package/src/unstable/cluster/MessageStorage.ts +26 -25
  462. package/src/unstable/cluster/Reply.ts +7 -4
  463. package/src/unstable/cluster/RunnerServer.ts +10 -13
  464. package/src/unstable/cluster/Runners.ts +8 -7
  465. package/src/unstable/cluster/Sharding.ts +24 -17
  466. package/src/unstable/cluster/ShardingConfig.ts +6 -6
  467. package/src/unstable/cluster/SqlMessageStorage.ts +21 -18
  468. package/src/unstable/cluster/internal/entityManager.ts +27 -21
  469. package/src/unstable/devtools/DevToolsSchema.ts +3 -2
  470. package/src/unstable/encoding/Ndjson.ts +17 -17
  471. package/src/unstable/http/Cookies.ts +7 -8
  472. package/src/unstable/http/Etag.ts +5 -3
  473. package/src/unstable/http/Headers.ts +6 -5
  474. package/src/unstable/http/HttpClient.ts +2 -1
  475. package/src/unstable/http/HttpClientRequest.ts +11 -9
  476. package/src/unstable/http/HttpClientResponse.ts +5 -4
  477. package/src/unstable/http/HttpIncomingMessage.ts +3 -2
  478. package/src/unstable/http/HttpMiddleware.ts +16 -15
  479. package/src/unstable/http/HttpPlatform.ts +3 -2
  480. package/src/unstable/http/HttpRouter.ts +9 -9
  481. package/src/unstable/http/HttpServer.ts +3 -9
  482. package/src/unstable/http/HttpServerError.ts +3 -2
  483. package/src/unstable/http/HttpServerRequest.ts +29 -25
  484. package/src/unstable/http/HttpServerResponse.ts +7 -6
  485. package/src/unstable/http/HttpTraceContext.ts +31 -17
  486. package/src/unstable/http/UrlParams.ts +11 -14
  487. package/src/unstable/httpapi/HttpApiBuilder.ts +13 -7
  488. package/src/unstable/httpapi/HttpApiError.ts +67 -12
  489. package/src/unstable/observability/OtlpExporter.ts +5 -2
  490. package/src/unstable/observability/OtlpTracer.ts +8 -4
  491. package/src/unstable/persistence/Persistable.ts +1 -1
  492. package/src/unstable/reactivity/Atom.ts +1 -4
  493. package/src/unstable/reactivity/AtomRegistry.ts +5 -3
  494. package/src/unstable/rpc/Rpc.ts +4 -3
  495. package/src/unstable/rpc/RpcClient.ts +10 -9
  496. package/src/unstable/rpc/RpcGroup.ts +3 -3
  497. package/src/unstable/rpc/RpcSchema.ts +6 -5
  498. package/src/unstable/rpc/RpcSerialization.ts +4 -1
  499. package/src/unstable/rpc/RpcServer.ts +3 -3
  500. package/src/unstable/socket/Socket.ts +2 -1
  501. package/src/unstable/sql/SqlClient.ts +5 -3
  502. package/src/unstable/workflow/DurableDeferred.ts +6 -6
  503. package/src/unstable/workflow/Workflow.ts +1 -1
  504. package/src/unstable/workflow/WorkflowEngine.ts +29 -20
  505. package/dist/NullOr.d.ts +0 -149
  506. package/dist/NullOr.d.ts.map +0 -1
  507. package/dist/NullOr.js +0 -152
  508. package/dist/NullOr.js.map +0 -1
  509. package/dist/unstable/cli/internal/completions/Completions.d.ts +0 -2
  510. package/dist/unstable/cli/internal/completions/Completions.d.ts.map +0 -1
  511. package/dist/unstable/cli/internal/completions/Completions.js +0 -23
  512. package/dist/unstable/cli/internal/completions/Completions.js.map +0 -1
  513. package/src/NullOr.ts +0 -204
  514. package/src/unstable/cli/internal/completions/Completions.ts +0 -31
package/src/Schema.ts CHANGED
@@ -1,4 +1,86 @@
1
1
  /**
2
+ * Define data shapes, validate unknown input, and transform values between formats.
3
+ *
4
+ * ## Mental model
5
+ *
6
+ * - **Schema** — a description of a data shape. Every schema carries a decoded
7
+ * *Type* (the value you work with) and an *Encoded* representation (the
8
+ * serialized form, e.g. JSON).
9
+ * - **Decoding** — turning unknown external data (API responses, form
10
+ * submissions, config files) into typed, validated values.
11
+ * - **Encoding** — turning typed values back into a serializable format.
12
+ * - **Codec** — a schema that tracks both Type and Encoded, so it can decode
13
+ * *and* encode. Most concrete schemas are Codecs.
14
+ * - **Check / Filter** — a constraint attached to a schema (e.g. `isMinLength`,
15
+ * `isGreaterThan`). Attach them with `.check(...)`.
16
+ * - **Transformation** — a pair of functions (decode + encode) that convert
17
+ * values between two schemas. Created with {@link decodeTo} / {@link encodeTo}.
18
+ * - **Annotation** — metadata attached to a schema (title, description, custom
19
+ * keys). Attach with `.annotate(...)`.
20
+ *
21
+ * ## Common tasks
22
+ *
23
+ * - Define a struct: {@link Struct}
24
+ * - Define a union: {@link Union}, {@link TaggedUnion}, {@link Literals}
25
+ * - Define an array: {@link Array}, {@link NonEmptyArray}
26
+ * - Define a record: {@link Record}
27
+ * - Define a tuple: {@link Tuple}, {@link TupleWithRest}
28
+ * - Validate unknown data synchronously: {@link decodeUnknownSync}
29
+ * - Validate unknown data (Effect): {@link decodeUnknownEffect}
30
+ * - Encode a value: {@link encodeUnknownSync}, {@link encodeUnknownEffect}
31
+ * - Type guard: {@link is}
32
+ * - Assertion: {@link asserts}
33
+ * - Add constraints: `.check(...)` with filters like {@link isMinLength},
34
+ * {@link isGreaterThan}, {@link isPattern}, {@link isUUID}
35
+ * - Transform between schemas: {@link decodeTo}, {@link encodeTo}
36
+ * - Add a default for missing keys: {@link withDecodingDefault}, {@link withDecodingDefaultKey}
37
+ * - Create branded types: {@link brand}
38
+ * - Define classes with validation: {@link Class}, {@link TaggedClass}
39
+ * - Define error classes: {@link ErrorClass}, {@link TaggedErrorClass}
40
+ * - Generate JSON Schema: {@link toJsonSchemaDocument}
41
+ * - Generate test data: {@link toArbitrary}
42
+ * - Derive equivalence: {@link toEquivalence}
43
+ *
44
+ * ## Gotchas
45
+ *
46
+ * - `Schema.optional` creates `T | undefined` (key can be missing *or*
47
+ * `undefined`). Use `Schema.optionalKey` for exact optional properties.
48
+ * - `decodeTo` is curried: use `from.pipe(Schema.decodeTo(to, ...))`.
49
+ * - `decodeUnknownSync` throws on failure. Use `decodeUnknownExit` or
50
+ * `decodeUnknownOption` for non-throwing alternatives.
51
+ * - Filters do not change the TypeScript type. Use {@link refine} or
52
+ * {@link brand} to narrow the type.
53
+ * - Recursive schemas require {@link suspend} to avoid infinite loops.
54
+ *
55
+ * ## Quickstart
56
+ *
57
+ * **Example** (Validate a user object)
58
+ *
59
+ * ```ts
60
+ * import { Schema } from "effect"
61
+ *
62
+ * const User = Schema.Struct({
63
+ * name: Schema.String.check(Schema.isMinLength(1)),
64
+ * age: Schema.Number.check(Schema.isGreaterThanOrEqualTo(0)),
65
+ * email: Schema.optionalKey(Schema.String)
66
+ * })
67
+ *
68
+ * // Decode unknown input — throws on failure
69
+ * const user = Schema.decodeUnknownSync(User)({
70
+ * name: "Alice",
71
+ * age: 30
72
+ * })
73
+ *
74
+ * console.log(user)
75
+ * // { name: "Alice", age: 30 }
76
+ * ```
77
+ *
78
+ * @see {@link Schema} — type-level view tracking only the decoded Type
79
+ * @see {@link Codec} — type-level view tracking both Type and Encoded
80
+ * @see {@link Struct} — define object shapes
81
+ * @see {@link decodeUnknownSync} — synchronous validation
82
+ * @see {@link decodeTo} — schema transformations
83
+ *
2
84
  * @since 4.0.0
3
85
  */
4
86
 
@@ -58,29 +140,42 @@ import type { Unify } from "./Unify.ts"
58
140
  const TypeId = InternalSchema.TypeId
59
141
 
60
142
  /**
61
- * Is this schema required or optional?
143
+ * Whether a schema field is required or optional within a struct.
144
+ *
145
+ * @see {@link optionalKey} — mark a struct field as optional
146
+ * @see {@link optional} — mark a struct field as optional with `| undefined`
62
147
  *
63
148
  * @since 4.0.0
64
149
  */
65
150
  export type Optionality = "required" | "optional"
66
151
 
67
152
  /**
68
- * Is this schema read-only or mutable?
153
+ * Whether a schema field is readonly or mutable within a struct.
154
+ *
155
+ * @see {@link mutableKey} — mark a struct field as mutable
69
156
  *
70
157
  * @since 4.0.0
71
158
  */
72
159
  export type Mutability = "readonly" | "mutable"
73
160
 
74
161
  /**
75
- * Does the constructor of this schema supply a default value?
162
+ * Whether a schema field has a constructor default value.
163
+ *
164
+ * @see {@link withConstructorDefault} — add a default to a schema field
165
+ * @see {@link tag} — creates a literal field with a constructor default
76
166
  *
77
167
  * @since 4.0.0
78
168
  */
79
169
  export type ConstructorDefault = "no-default" | "with-default"
80
170
 
81
171
  /**
82
- * Configuration options for the `makeUnsafe` method, providing control over
83
- * parsing behavior and validation.
172
+ * Options for `makeUnsafe` and Class constructors.
173
+ *
174
+ * When to use:
175
+ * - Pass `disableValidation: true` to skip validation when you trust the data.
176
+ * - Pass `parseOptions` to control error reporting behavior.
177
+ *
178
+ * @see {@link Bottom.makeUnsafe}
84
179
  *
85
180
  * @since 4.0.0
86
181
  */
@@ -96,15 +191,19 @@ export interface MakeOptions {
96
191
  }
97
192
 
98
193
  /**
99
- * The base interface for all schemas in the Effect Schema library, exposing all
100
- * 14 type parameters that control schema behavior and type inference. Bottom
101
- * sits at the root of the schema type hierarchy and provides access to the
102
- * complete internal type information of schemas.
194
+ * The fully-parameterized base interface for all schemas. Exposes all 14 type
195
+ * parameters controlling type inference, mutability, optionality, services,
196
+ * and transformation behavior.
103
197
  *
104
- * Bottom is primarily used for advanced type-level operations, schema
105
- * introspection, and when you need precise control over all aspects of schema
106
- * behavior including mutability, optionality, service dependencies, and
107
- * transformation characteristics.
198
+ * When to use:
199
+ * - You are writing advanced generic schema utilities or performing schema
200
+ * introspection.
201
+ * - In user code, prefer {@link Schema}, {@link Codec}, {@link Decoder}, or
202
+ * {@link Encoder} instead.
203
+ *
204
+ * @see {@link Top} — the existential "any schema" type (erased type params)
205
+ * @see {@link Schema} — tracks only the decoded Type
206
+ * @see {@link Codec} — tracks Type + Encoded
108
207
  *
109
208
  * @since 4.0.0
110
209
  */
@@ -159,6 +258,11 @@ export interface Bottom<
159
258
  }
160
259
 
161
260
  /**
261
+ * The schema type returned by {@link declareConstructor}, tracking the decoded
262
+ * type `T`, the encoded type `E`, and the list of type-parameter schemas
263
+ * `TypeParameters`.
264
+ *
265
+ * @category Constructors
162
266
  * @since 4.0.0
163
267
  */
164
268
  export interface declareConstructor<T, E, TypeParameters extends ReadonlyArray<Top>, Iso = T> extends
@@ -178,9 +282,51 @@ export interface declareConstructor<T, E, TypeParameters extends ReadonlyArray<T
178
282
  }
179
283
 
180
284
  /**
181
- * An API for creating schemas for parametric types.
285
+ * Creates a schema for a **parametric** type (a generic container such as
286
+ * `Array<A>`, `Option<A>`, etc.) by accepting a list of type-parameter schemas
287
+ * and a decoder factory.
182
288
  *
183
- * @see {@link declare} for creating schemas for non parametric types.
289
+ * The outer call `declareConstructor<T, E, Iso>()` fixes the decoded type `T`,
290
+ * the encoded type `E`, and the optional iso type. The inner call receives:
291
+ * - `typeParameters` — the concrete schemas for each type variable
292
+ * - `run` — a factory that, given resolved codecs for each type parameter,
293
+ * returns a parsing function `(u, ast, options) => Effect<T, Issue>`
294
+ * - `annotations` — optional metadata
295
+ *
296
+ * @see {@link declare} for creating schemas for non-parametric types.
297
+ *
298
+ * **Example** (Schema for a parametric `Box<A>` type)
299
+ *
300
+ * ```ts
301
+ * import { Effect, Schema } from "effect"
302
+ * import * as SchemaParser from "effect/SchemaParser"
303
+ * import * as Issue from "effect/SchemaIssue"
304
+ * import * as Option from "effect/Option"
305
+ *
306
+ * interface Box<A> {
307
+ * readonly value: A
308
+ * }
309
+ *
310
+ * const isBox = (u: unknown): u is Box<unknown> =>
311
+ * typeof u === "object" && u !== null && "value" in u
312
+ *
313
+ * const Box = <A extends Schema.Top>(item: A) =>
314
+ * Schema.declareConstructor<Box<A["Type"]>, Box<A["Encoded"]>>()(
315
+ * [item],
316
+ * ([itemCodec]) =>
317
+ * (u, ast, options) => {
318
+ * if (!isBox(u)) {
319
+ * return Effect.fail(new Issue.InvalidType(ast, Option.some(u)))
320
+ * }
321
+ * return Effect.map(
322
+ * SchemaParser.decodeUnknownEffect(itemCodec)(u.value, options),
323
+ * (value) => ({ value })
324
+ * )
325
+ * }
326
+ * )
327
+ *
328
+ * const schema = Box(Schema.Number)
329
+ * ```
184
330
  *
185
331
  * @category Constructors
186
332
  * @since 4.0.0
@@ -206,16 +352,41 @@ export function declareConstructor<T, E = T, Iso = T>() {
206
352
  }
207
353
 
208
354
  /**
355
+ * The schema type returned by {@link declare}, representing a non-parametric
356
+ * opaque type `T` with no type parameters.
357
+ *
209
358
  * @category Constructors
210
359
  * @since 4.0.0
211
360
  */
212
361
  export interface declare<T, Iso = T> extends declareConstructor<T, T, readonly [], Iso> {}
213
362
 
214
363
  /**
215
- * An API for creating schemas for non parametric types.
364
+ * Creates a schema for a **non-parametric** opaque type using a type-guard
365
+ * function. The schema accepts any unknown value and succeeds when `is` returns
366
+ * `true`, failing with an `InvalidType` issue otherwise.
367
+ *
368
+ * Use this when the type has no type parameters. For parametric types such as
369
+ * `Option<A>` or `Array<A>`, use {@link declareConstructor} instead.
370
+ *
371
+ * **Example** (Schema for a custom `UserId` branded type)
372
+ *
373
+ * ```ts
374
+ * import { Schema } from "effect"
375
+ *
376
+ * type UserId = string & { readonly _tag: "UserId" }
377
+ *
378
+ * const isUserId = (u: unknown): u is UserId =>
379
+ * typeof u === "string" && u.startsWith("user_")
380
+ *
381
+ * const UserId = Schema.declare<UserId>(isUserId, {
382
+ * title: "UserId",
383
+ * description: "A user identifier starting with 'user_'"
384
+ * })
385
+ * ```
216
386
  *
217
387
  * @see {@link declareConstructor} for creating schemas for parametric types.
218
388
  *
389
+ * @category Constructors
219
390
  * @since 4.0.0
220
391
  */
221
392
  export function declare<T, Iso = T>(
@@ -233,8 +404,28 @@ export function declare<T, Iso = T>(
233
404
  }
234
405
 
235
406
  /**
236
- * Reveals the complete Bottom interface type of a schema, exposing all 14 type
237
- * parameters.
407
+ * Widens a schema's type to the fully-parameterized {@link Bottom} interface,
408
+ * making all 14 type parameters visible to TypeScript.
409
+ *
410
+ * Normally, concrete schema interfaces (e.g. `Schema<string>`) hide most type
411
+ * parameters. `revealBottom` is useful when writing generic utilities that need
412
+ * to inspect or propagate the complete set of type parameters.
413
+ *
414
+ * **Example** (Inspecting all type parameters of a schema)
415
+ *
416
+ * ```ts
417
+ * import { Schema } from "effect"
418
+ *
419
+ * const schema = Schema.String
420
+ *
421
+ * // Widen to Bottom to access all 14 type parameters
422
+ * const bottom = Schema.revealBottom(schema)
423
+ *
424
+ * // `bottom` now exposes Type, Encoded, DecodingServices, EncodingServices,
425
+ * // ast, ~rebuild.out, ~type.make.in, Iso, ~type.parameters, etc.
426
+ * type T = typeof bottom["Type"] // string
427
+ * type E = typeof bottom["Encoded"] // string
428
+ * ```
238
429
  *
239
430
  * @since 4.0.0
240
431
  */
@@ -262,8 +453,24 @@ export function revealBottom<S extends Top>(
262
453
 
263
454
  /**
264
455
  * Adds metadata annotations to a schema without changing its runtime behavior.
265
- * Annotations are used to provide additional context for documentation,
266
- * JSON schema generation, error formatting, and other tooling.
456
+ * This is the pipeable (curried) counterpart of the `.annotate` method.
457
+ *
458
+ * Annotations provide extra context used by documentation generators, JSON
459
+ * Schema converters, error formatters, and other tooling. Common keys include
460
+ * `title`, `description`, `examples`, `message`, and `identifier`.
461
+ *
462
+ * **Example** (Adding a title and description)
463
+ *
464
+ * ```ts
465
+ * import { Schema } from "effect"
466
+ *
467
+ * const Age = Schema.Number.pipe(
468
+ * Schema.annotate({
469
+ * title: "Age",
470
+ * description: "A non-negative integer representing age in years"
471
+ * })
472
+ * )
473
+ * ```
267
474
  *
268
475
  * @category Annotations
269
476
  * @since 4.0.0
@@ -275,9 +482,29 @@ export function annotate<S extends Top>(annotations: S["~annotate.in"]) {
275
482
  }
276
483
 
277
484
  /**
278
- * Adds key-specific annotations to a schema field. This is useful for providing
279
- * custom error messages and documentation for individual fields within
280
- * structures.
485
+ * Adds key-level annotations to a schema field. This is the pipeable
486
+ * (curried) counterpart of the `.annotateKey` method.
487
+ *
488
+ * Key annotations apply to a field's position inside a `Struct` or `Tuple`
489
+ * rather than to the field's value type. They can carry a
490
+ * `messageMissingKey` to customise the error shown when the field is absent,
491
+ * as well as standard documentation fields such as `title`, `description`,
492
+ * and `examples`.
493
+ *
494
+ * **Example** (Custom missing-key message for a required field)
495
+ *
496
+ * ```ts
497
+ * import { Schema } from "effect"
498
+ *
499
+ * const schema = Schema.Struct({
500
+ * username: Schema.String.pipe(
501
+ * Schema.annotateKey({
502
+ * description: "The username used to log in",
503
+ * messageMissingKey: "Username is required"
504
+ * })
505
+ * )
506
+ * })
507
+ * ```
281
508
  *
282
509
  * @category Annotations
283
510
  * @since 4.0.0
@@ -289,15 +516,17 @@ export function annotateKey<S extends Top>(annotations: Annotations.Key<S["Type"
289
516
  }
290
517
 
291
518
  /**
292
- * The top (most general) type for all schema-like values in this module.
519
+ * The existential "any schema" type all type parameters are erased to `unknown`.
293
520
  *
294
- * When to use:
295
- * - You are writing generic helpers and only need "some schema", without caring about its `Type` / `Encoded`.
296
- * - You need a common constraint for type-level utilities (for example in `Schema.Type` or `Codec.Encoded`).
521
+ * Use `Top` as a constraint when writing generic utilities that must accept *any*
522
+ * schema regardless of its `Type`, `Encoded`, or service requirements. It is the
523
+ * widest possible schema type and therefore gives you the least static information.
297
524
  *
298
- * Behavior:
299
- * - This is a *type-level* supertype; it does not represent a specific concrete schema.
300
- * - In user code, you usually want {@link Schema}, {@link Codec}, {@link Decoder}, or {@link Encoder} instead.
525
+ * In user code prefer the narrower interfaces:
526
+ * - {@link Schema}`<T>` when you only care about the decoded type
527
+ * - {@link Codec}`<T, E, RD, RE>` when you need the encoded type and service requirements
528
+ * - {@link Decoder}`<T, RD>` — for decode-only APIs
529
+ * - {@link Encoder}`<E, RE>` — for encode-only APIs
301
530
  *
302
531
  * @since 4.0.0
303
532
  */
@@ -322,25 +551,53 @@ export interface Top extends
322
551
  {}
323
552
 
324
553
  /**
554
+ * Namespace of type-level helpers for {@link Schema}.
555
+ *
325
556
  * @since 4.0.0
326
557
  */
327
558
  export declare namespace Schema {
328
559
  /**
560
+ * Extracts the decoded `Type` from a schema.
561
+ *
562
+ * **Example** (Extracting the decoded type)
563
+ *
564
+ * ```ts
565
+ * import { Schema } from "effect"
566
+ *
567
+ * const Person = Schema.Struct({ name: Schema.String, age: Schema.Number })
568
+ * type Person = Schema.Schema.Type<typeof Person>
569
+ * // { readonly name: string; readonly age: number }
570
+ * ```
571
+ *
329
572
  * @since 4.0.0
330
573
  */
331
574
  export type Type<S> = S extends Top ? S["Type"] : never
332
575
  }
333
576
 
334
577
  /**
335
- * A typed view of a schema that tracks the decoded (output) type `T`.
578
+ * A typed view of a schema that tracks only the decoded (output) type `T`.
336
579
  *
337
- * When to use:
338
- * - You want to accept "any schema that decodes to `T`" in a function signature.
339
- * - You only care about the decoded type and do not need to talk about the encoded representation.
580
+ * Use `Schema<T>` as a constraint when you want to accept "any schema that
581
+ * decodes to `T`" and do not need to know or constrain the encoded
582
+ * representation, required services, or any other type parameters.
583
+ *
584
+ * This is a structural interface — concrete schema values are produced by the
585
+ * constructors in this module (e.g. {@link Struct}, {@link String}, {@link Number}).
586
+ * When you also need the encoded type or service requirements, use {@link Codec}.
587
+ *
588
+ * **Example** (Function that accepts any schema decoding to `string`)
589
+ *
590
+ * ```ts
591
+ * import { Schema } from "effect"
340
592
  *
341
- * Behavior:
342
- * - This is a structural interface used for typing; it does not by itself construct or run validation.
343
- * - If you also need the encoded type (or decoding/encoding services), use {@link Codec}.
593
+ * declare function print(schema: Schema.Schema<string>): void
594
+ *
595
+ * print(Schema.String) // ok
596
+ * print(Schema.NonEmptyString) // ok
597
+ * ```
598
+ *
599
+ * @see {@link Codec} — also tracks Encoded, DecodingServices, EncodingServices
600
+ * @see {@link Schema.Type} — extract the decoded type at the type level
344
601
  *
345
602
  * @since 4.0.0
346
603
  */
@@ -350,22 +607,66 @@ export interface Schema<out T> extends Top {
350
607
  }
351
608
 
352
609
  /**
610
+ * Namespace of type-level helpers for {@link Codec}.
611
+ *
353
612
  * @since 4.0.0
354
613
  */
355
614
  export declare namespace Codec {
356
615
  /**
616
+ * Extracts the encoded (`Encoded`) type from a schema.
617
+ *
618
+ * **Example** (Extracting the encoded type)
619
+ *
620
+ * ```ts
621
+ * import { Schema } from "effect"
622
+ *
623
+ * const schema = Schema.NumberFromString
624
+ * type Enc = Schema.Codec.Encoded<typeof schema>
625
+ * // string
626
+ * ```
627
+ *
357
628
  * @since 4.0.0
358
629
  */
359
630
  export type Encoded<S> = S extends Top ? S["Encoded"] : never
360
631
  /**
632
+ * Extracts the Effect services required during *decoding* from a schema.
633
+ *
634
+ * **Example** (Checking decoding service requirements)
635
+ *
636
+ * ```ts
637
+ * import { Schema } from "effect"
638
+ *
639
+ * const schema = Schema.String
640
+ * type RD = Schema.Codec.DecodingServices<typeof schema>
641
+ * // never
642
+ * ```
643
+ *
361
644
  * @since 4.0.0
362
645
  */
363
646
  export type DecodingServices<S> = S extends Top ? S["DecodingServices"] : never
364
647
  /**
648
+ * Extracts the Effect services required during *encoding* from a schema.
649
+ *
650
+ * **Example** (Checking encoding service requirements)
651
+ *
652
+ * ```ts
653
+ * import { Schema } from "effect"
654
+ *
655
+ * const schema = Schema.String
656
+ * type RE = Schema.Codec.EncodingServices<typeof schema>
657
+ * // never
658
+ * ```
659
+ *
365
660
  * @since 4.0.0
366
661
  */
367
662
  export type EncodingServices<S> = S extends Top ? S["EncodingServices"] : never
368
663
  /**
664
+ * Converts a schema type into an assertion function signature. The resulting
665
+ * function narrows its argument to `I & S["Type"]`. Only schemas with
666
+ * `DecodingServices: never` (i.e. no required services) can be used here.
667
+ *
668
+ * Produced by {@link asserts}.
669
+ *
369
670
  * @since 4.0.0
370
671
  */
371
672
  export type ToAsserts<S extends Top & { readonly DecodingServices: never }> = <I>(
@@ -374,6 +675,18 @@ export declare namespace Codec {
374
675
  }
375
676
 
376
677
  /**
678
+ * A schema that additionally supports optic (lens/prism) operations.
679
+ *
680
+ * `Optic<T, Iso>` extends {@link Schema}`<T>` with an `Iso` type that
681
+ * describes the isomorphic counterpart used by the optic layer. Crucially,
682
+ * decoding and encoding require *no* Effect services (`DecodingServices` and
683
+ * `EncodingServices` are both `never`), which means the optic can operate
684
+ * purely without an Effect runtime.
685
+ *
686
+ * Most primitive schemas (e.g. `Schema.String`, `Schema.Number`) implement
687
+ * `Optic` automatically. You normally interact with this interface through
688
+ * {@link Optic_} utilities rather than constructing it directly.
689
+ *
377
690
  * @since 4.0.0
378
691
  */
379
692
  export interface Optic<out T, out Iso> extends Schema<T> {
@@ -384,16 +697,32 @@ export interface Optic<out T, out Iso> extends Schema<T> {
384
697
  }
385
698
 
386
699
  /**
387
- * A schema that tracks both the decoded type `T` and the encoded representation `E`.
700
+ * A schema that tracks the decoded type `T`, the encoded type `E`, and the
701
+ * Effect services required during decoding (`RD`) and encoding (`RE`).
388
702
  *
389
- * When to use:
390
- * - You want a schema in APIs that may both decode and encode.
391
- * - You need to preserve/describe the encoded representation (`Encoded`) in types.
392
- * - You need to model required services for decoding (`RD`) and encoding (`RE`).
703
+ * Use `Codec<T, E, RD, RE>` when you need to preserve full type information
704
+ * about a schema both what it decodes to and what it serializes from/to.
705
+ * Most concrete schemas produced by this module implement `Codec`.
706
+ *
707
+ * For APIs that only need one direction, prefer the narrower views:
708
+ * - {@link Decoder}`<T, RD>` — decode-only
709
+ * - {@link Encoder}`<E, RE>` — encode-only
710
+ * - {@link Schema}`<T>` — type-only (no encoded representation)
711
+ *
712
+ * **Example** (Accepting a codec that decodes to `number` from `string`)
393
713
  *
394
- * Behavior:
395
- * - This is a typing surface; concrete schema values are created by the various constructors in this module.
396
- * - For decode-only or encode-only APIs, prefer {@link Decoder} or {@link Encoder}.
714
+ * ```ts
715
+ * import { Schema } from "effect"
716
+ *
717
+ * declare function serialize<T>(codec: Schema.Codec<T, string>): string
718
+ *
719
+ * serialize(Schema.NumberFromString) // ok — decodes number, encoded as string
720
+ * ```
721
+ *
722
+ * @see {@link Codec.Encoded} — extract the encoded type
723
+ * @see {@link Codec.DecodingServices} — extract required decoding services
724
+ * @see {@link Codec.EncodingServices} — extract required encoding services
725
+ * @see {@link revealCodec} — helper to make TypeScript infer the full Codec type
397
726
  *
398
727
  * @since 4.0.0
399
728
  */
@@ -405,11 +734,22 @@ export interface Codec<out T, out E = T, out RD = never, out RE = never> extends
405
734
  }
406
735
 
407
736
  /**
408
- * A `Codec` view intended for APIs that only *decode* (parse/validate) values.
737
+ * A {@link Codec} view for APIs that only *decode* (parse/validate) values.
409
738
  *
410
- * When to use:
411
- * - You want to accept "anything that can decode to `T`", without requiring encoding support.
412
- * - You are writing helpers that should not depend on the schema’s `Encoded` representation.
739
+ * Use `Decoder<T, RD>` to accept "any schema that can decode to `T`" without
740
+ * constraining or depending on the encoded representation (`Encoded` is
741
+ * `unknown`) or encoding services.
742
+ *
743
+ * **Example** (Function that only needs to decode)
744
+ *
745
+ * ```ts
746
+ * import { Schema } from "effect"
747
+ *
748
+ * declare function validate<T>(decoder: Schema.Decoder<T>): (input: unknown) => T
749
+ *
750
+ * validate(Schema.String) // ok
751
+ * validate(Schema.NumberFromString) // ok
752
+ * ```
413
753
  *
414
754
  * @since 4.0.0
415
755
  */
@@ -418,11 +758,22 @@ export interface Decoder<out T, out RD = never> extends Codec<T, unknown, RD, un
418
758
  }
419
759
 
420
760
  /**
421
- * A `Codec` view intended for APIs that only *encode* values.
761
+ * A {@link Codec} view for APIs that only *encode* values.
422
762
  *
423
- * When to use:
424
- * - You want to accept "anything that can encode to `E`", without requiring decoding support.
425
- * - You are writing helpers that should not depend on the schema’s decoded `Type`.
763
+ * Use `Encoder<E, RE>` to accept "any schema that can encode to `E`" without
764
+ * constraining or depending on the decoded `Type` (`Type` is `unknown`) or
765
+ * decoding services.
766
+ *
767
+ * **Example** (Function that only needs to encode)
768
+ *
769
+ * ```ts
770
+ * import { Schema } from "effect"
771
+ *
772
+ * declare function serialize<E>(encoder: Schema.Encoder<E>): (value: unknown) => E
773
+ *
774
+ * serialize(Schema.String) // ok — encodes to string
775
+ * serialize(Schema.NumberFromString) // ok — encodes number to string
776
+ * ```
426
777
  *
427
778
  * @since 4.0.0
428
779
  */
@@ -431,6 +782,25 @@ export interface Encoder<out E, out RE = never> extends Codec<unknown, E, unknow
431
782
  }
432
783
 
433
784
  /**
785
+ * Identity function that widens a value to the full {@link Codec} interface,
786
+ * prompting TypeScript to infer all four type parameters (`T`, `E`, `RD`, `RE`).
787
+ *
788
+ * When a schema is stored in a variable typed as `Schema<T>` or `Top`, the
789
+ * encoded type and service requirements are erased. Passing the value through
790
+ * `revealCodec` recovers those parameters without any runtime cost.
791
+ *
792
+ * **Example** (Recovering encoded type from a schema variable)
793
+ *
794
+ * ```ts
795
+ * import { Schema } from "effect"
796
+ *
797
+ * const schema: Schema.Schema<number> = Schema.NumberFromString
798
+ *
799
+ * // Without revealCodec, Encoded is unknown
800
+ * const codec = Schema.revealCodec(schema)
801
+ * type Enc = typeof codec["Encoded"] // string
802
+ * ```
803
+ *
434
804
  * @since 4.0.0
435
805
  */
436
806
  export function revealCodec<T, E, RD, RE>(codec: Codec<T, E, RD, RE>) {
@@ -440,12 +810,30 @@ export function revealCodec<T, E, RD, RE>(codec: Codec<T, E, RD, RE>) {
440
810
  const SchemaErrorTypeId = "~effect/Schema/SchemaError"
441
811
 
442
812
  /**
443
- * A `SchemaError` is returned when schema decoding or encoding fails.
813
+ * Error thrown (or returned as the error channel value) when schema decoding
814
+ * or encoding fails.
815
+ *
816
+ * The `issue` field contains a structured {@link Issue.Issue} tree describing
817
+ * every validation failure, including the path to the problematic value,
818
+ * expected types, and actual values received. `message` renders the issue tree
819
+ * as a human-readable string.
820
+ *
821
+ * Use {@link isSchemaError} to narrow an unknown value to `SchemaError`.
822
+ *
823
+ * **Example** (Catching a SchemaError)
444
824
  *
445
- * This error extends `Data.TaggedError` and contains detailed information about
446
- * what went wrong during schema processing. The error includes an `issue` field
447
- * that provides comprehensive details about the validation failure, including
448
- * the path to the problematic data, expected types, and actual values.
825
+ * ```ts
826
+ * import { Schema } from "effect"
827
+ *
828
+ * try {
829
+ * Schema.decodeUnknownSync(Schema.Number)("not a number")
830
+ * } catch (err) {
831
+ * if (Schema.isSchemaError(err)) {
832
+ * console.log(err.message)
833
+ * // Expected number, actual "not a number"
834
+ * }
835
+ * }
836
+ * ```
449
837
  *
450
838
  * @since 4.0.0
451
839
  */
@@ -466,6 +854,22 @@ export class SchemaError {
466
854
  }
467
855
 
468
856
  /**
857
+ * Returns `true` if `u` is a {@link SchemaError}.
858
+ *
859
+ * **Example** (Type guard in a catch block)
860
+ *
861
+ * ```ts
862
+ * import { Schema } from "effect"
863
+ *
864
+ * try {
865
+ * Schema.decodeUnknownSync(Schema.Number)("oops")
866
+ * } catch (err) {
867
+ * if (Schema.isSchemaError(err)) {
868
+ * console.log(err._tag) // "SchemaError"
869
+ * }
870
+ * }
871
+ * ```
872
+ *
469
873
  * @since 4.0.0
470
874
  */
471
875
  export function isSchemaError(u: unknown): u is SchemaError {
@@ -564,7 +968,7 @@ export function toStandardSchemaV1<
564
968
  }),
565
969
  { scheduler }
566
970
  )
567
- scheduler.flush()
971
+ fiber.currentDispatcher?.flush()
568
972
  const exit = fiber.pollUnsafe()
569
973
  if (exit) {
570
974
  return makeStandardResult(exit)
@@ -714,6 +1118,11 @@ export const is = Parser.is
714
1118
  export const asserts = Parser.asserts
715
1119
 
716
1120
  /**
1121
+ * Decodes an `unknown` input against a schema, returning an `Effect` that
1122
+ * succeeds with the decoded value or fails with a {@link SchemaError}. Use this
1123
+ * when the input type is not statically known. Prefer {@link decodeEffect} when
1124
+ * the input is already typed as the schema's `Encoded` type.
1125
+ *
717
1126
  * @category Decoding
718
1127
  * @since 4.0.0
719
1128
  */
@@ -725,6 +1134,11 @@ export function decodeUnknownEffect<S extends Top>(schema: S) {
725
1134
  }
726
1135
 
727
1136
  /**
1137
+ * Decodes a typed input (the schema's `Encoded` type) against a schema,
1138
+ * returning an `Effect` that succeeds with the decoded value or fails with a
1139
+ * {@link SchemaError}. Use this when the input is already typed; for `unknown`
1140
+ * input use {@link decodeUnknownEffect}.
1141
+ *
728
1142
  * @category Decoding
729
1143
  * @since 4.0.0
730
1144
  */
@@ -734,6 +1148,12 @@ export const decodeEffect: <S extends Top>(
734
1148
  decodeUnknownEffect
735
1149
 
736
1150
  /**
1151
+ * Decodes an `unknown` input against a schema synchronously, returning an
1152
+ * `Exit` that is either a `Success` with the decoded value or a `Failure` with
1153
+ * a {@link SchemaError}. Only usable with schemas that have no
1154
+ * `DecodingServices` requirement. Prefer {@link decodeExit} when the input is
1155
+ * already typed as the schema's `Encoded` type.
1156
+ *
737
1157
  * @category Decoding
738
1158
  * @since 4.0.0
739
1159
  */
@@ -745,6 +1165,12 @@ export function decodeUnknownExit<S extends Top & { readonly DecodingServices: n
745
1165
  }
746
1166
 
747
1167
  /**
1168
+ * Decodes a typed input (the schema's `Encoded` type) against a schema
1169
+ * synchronously, returning an `Exit` that is either a `Success` with the
1170
+ * decoded value or a `Failure` with a {@link SchemaError}. Only usable with
1171
+ * schemas that have no `DecodingServices` requirement. For `unknown` input use
1172
+ * {@link decodeUnknownExit}.
1173
+ *
748
1174
  * @category Decoding
749
1175
  * @since 4.0.0
750
1176
  */
@@ -753,42 +1179,105 @@ export const decodeExit: <S extends Top & { readonly DecodingServices: never }>(
753
1179
  ) => (input: S["Encoded"], options?: AST.ParseOptions) => Exit_.Exit<S["Type"], SchemaError> = decodeUnknownExit
754
1180
 
755
1181
  /**
1182
+ * Decodes an `unknown` input against a schema, returning an `Option` that is
1183
+ * `Some` with the decoded value on success or `None` on failure. Prefer this
1184
+ * over {@link decodeUnknownExit} or {@link decodeUnknownEffect} when you only
1185
+ * need to know whether decoding succeeded and don't need error details. For
1186
+ * typed input use {@link decodeOption}.
1187
+ *
756
1188
  * @category Decoding
757
1189
  * @since 4.0.0
758
1190
  */
759
1191
  export const decodeUnknownOption = Parser.decodeUnknownOption
760
1192
 
761
1193
  /**
1194
+ * Decodes a typed input (the schema's `Encoded` type) against a schema,
1195
+ * returning an `Option` that is `Some` with the decoded value on success or
1196
+ * `None` on failure. For `unknown` input use {@link decodeUnknownOption}.
1197
+ *
762
1198
  * @category Decoding
763
1199
  * @since 4.0.0
764
1200
  */
765
1201
  export const decodeOption = Parser.decodeOption
766
1202
 
767
1203
  /**
1204
+ * Decodes an `unknown` input against a schema, returning a `Promise` that
1205
+ * resolves with the decoded value or rejects with a {@link SchemaError}. Useful
1206
+ * for integrating with Promise-based APIs. For typed input use
1207
+ * {@link decodePromise}.
1208
+ *
768
1209
  * @category Decoding
769
1210
  * @since 4.0.0
770
1211
  */
771
1212
  export const decodeUnknownPromise = Parser.decodeUnknownPromise
772
1213
 
773
1214
  /**
1215
+ * Decodes a typed input (the schema's `Encoded` type) against a schema,
1216
+ * returning a `Promise` that resolves with the decoded value or rejects with a
1217
+ * {@link SchemaError}. For `unknown` input use {@link decodeUnknownPromise}.
1218
+ *
774
1219
  * @category Decoding
775
1220
  * @since 4.0.0
776
1221
  */
777
1222
  export const decodePromise = Parser.decodePromise
778
1223
 
779
1224
  /**
1225
+ * Decodes an `unknown` input against a schema synchronously, throwing a
1226
+ * {@link SchemaError} on failure. Use this when you want to validate data at a
1227
+ * boundary and treat a schema mismatch as an unrecoverable error. For
1228
+ * non-throwing alternatives see {@link decodeUnknownOption},
1229
+ * {@link decodeUnknownExit}, or {@link decodeUnknownEffect}. For typed input
1230
+ * use {@link decodeSync}.
1231
+ *
1232
+ * **Example** (Decoding with a transformation schema)
1233
+ *
1234
+ * ```ts
1235
+ * import { Schema } from "effect"
1236
+ *
1237
+ * const NumberFromString = Schema.NumberFromString
1238
+ *
1239
+ * console.log(Schema.decodeUnknownSync(NumberFromString)("42"))
1240
+ * // Output: 42
1241
+ *
1242
+ * Schema.decodeUnknownSync(NumberFromString)("not a number")
1243
+ * // throws SchemaError: NumberFromString
1244
+ * // └─ Encoded side transformation failure
1245
+ * // └─ NumberFromString
1246
+ * // └─ Expected a numeric string, actual "not a number"
1247
+ * ```
1248
+ *
780
1249
  * @category Decoding
781
1250
  * @since 4.0.0
782
1251
  */
783
1252
  export const decodeUnknownSync = Parser.decodeUnknownSync
784
1253
 
785
1254
  /**
1255
+ * Decodes a typed input (the schema's `Encoded` type) against a schema
1256
+ * synchronously, throwing a {@link SchemaError} on failure. For `unknown` input
1257
+ * use {@link decodeUnknownSync}.
1258
+ *
786
1259
  * @category Decoding
787
1260
  * @since 4.0.0
788
1261
  */
789
1262
  export const decodeSync = Parser.decodeSync
790
1263
 
791
1264
  /**
1265
+ * Encodes an `unknown` input against a schema, returning an `Effect` that
1266
+ * succeeds with the encoded value or fails with a {@link SchemaError}. Use this
1267
+ * when the input type is not statically known. Prefer {@link encodeEffect} when
1268
+ * the input is already typed as the schema's `Type`.
1269
+ *
1270
+ * **Example** (Encoding a value to a string)
1271
+ *
1272
+ * ```ts
1273
+ * import { Effect, Schema } from "effect"
1274
+ *
1275
+ * const NumberFromString = Schema.NumberFromString
1276
+ *
1277
+ * Effect.runPromise(Schema.encodeUnknownEffect(NumberFromString)(42)).then(console.log)
1278
+ * // Output: "42"
1279
+ * ```
1280
+ *
792
1281
  * @category Encoding
793
1282
  * @since 4.0.0
794
1283
  */
@@ -803,6 +1292,11 @@ export function encodeUnknownEffect<S extends Top>(schema: S) {
803
1292
  }
804
1293
 
805
1294
  /**
1295
+ * Encodes a typed input (the schema's `Type`) against a schema, returning an
1296
+ * `Effect` that succeeds with the encoded value or fails with a
1297
+ * {@link SchemaError}. Use this when the input is already typed; for `unknown`
1298
+ * input use {@link encodeUnknownEffect}.
1299
+ *
806
1300
  * @category Encoding
807
1301
  * @since 4.0.0
808
1302
  */
@@ -812,6 +1306,12 @@ export const encodeEffect: <S extends Top>(
812
1306
  encodeUnknownEffect
813
1307
 
814
1308
  /**
1309
+ * Encodes an `unknown` input against a schema synchronously, returning an
1310
+ * `Exit` that is either a `Success` with the encoded value or a `Failure` with
1311
+ * a {@link SchemaError}. Only usable with schemas that have no
1312
+ * `EncodingServices` requirement. Prefer {@link encodeExit} when the input is
1313
+ * already typed as the schema's `Type`.
1314
+ *
815
1315
  * @category Encoding
816
1316
  * @since 4.0.0
817
1317
  */
@@ -823,6 +1323,12 @@ export function encodeUnknownExit<S extends Top & { readonly EncodingServices: n
823
1323
  }
824
1324
 
825
1325
  /**
1326
+ * Encodes a typed input (the schema's `Type`) against a schema synchronously,
1327
+ * returning an `Exit` that is either a `Success` with the encoded value or a
1328
+ * `Failure` with a {@link SchemaError}. Only usable with schemas that have no
1329
+ * `EncodingServices` requirement. For `unknown` input use
1330
+ * {@link encodeUnknownExit}.
1331
+ *
826
1332
  * @category Encoding
827
1333
  * @since 4.0.0
828
1334
  */
@@ -831,36 +1337,66 @@ export const encodeExit: <S extends Top & { readonly EncodingServices: never }>(
831
1337
  ) => (input: S["Type"], options?: AST.ParseOptions) => Exit_.Exit<S["Encoded"], SchemaError> = encodeUnknownExit
832
1338
 
833
1339
  /**
1340
+ * Encodes an `unknown` input against a schema, returning an `Option` that is
1341
+ * `Some` with the encoded value on success or `None` on failure. Prefer this
1342
+ * over {@link encodeUnknownExit} or {@link encodeUnknownEffect} when you only
1343
+ * need to know whether encoding succeeded and don't need error details. For
1344
+ * typed input use {@link encodeOption}.
1345
+ *
834
1346
  * @category Encoding
835
1347
  * @since 4.0.0
836
1348
  */
837
1349
  export const encodeUnknownOption = Parser.encodeUnknownOption
838
1350
 
839
1351
  /**
1352
+ * Encodes a typed input (the schema's `Type`) against a schema, returning an
1353
+ * `Option` that is `Some` with the encoded value on success or `None` on
1354
+ * failure. For `unknown` input use {@link encodeUnknownOption}.
1355
+ *
840
1356
  * @category Encoding
841
1357
  * @since 4.0.0
842
1358
  */
843
1359
  export const encodeOption = Parser.encodeOption
844
1360
 
845
1361
  /**
1362
+ * Encodes an `unknown` input against a schema, returning a `Promise` that
1363
+ * resolves with the encoded value or rejects with a {@link SchemaError}. Useful
1364
+ * for integrating with Promise-based APIs. For typed input use
1365
+ * {@link encodePromise}.
1366
+ *
846
1367
  * @category Encoding
847
1368
  * @since 4.0.0
848
1369
  */
849
1370
  export const encodeUnknownPromise = Parser.encodeUnknownPromise
850
1371
 
851
1372
  /**
1373
+ * Encodes a typed input (the schema's `Type`) against a schema, returning a
1374
+ * `Promise` that resolves with the encoded value or rejects with a
1375
+ * {@link SchemaError}. For `unknown` input use {@link encodeUnknownPromise}.
1376
+ *
852
1377
  * @category Encoding
853
1378
  * @since 4.0.0
854
1379
  */
855
1380
  export const encodePromise = Parser.encodePromise
856
1381
 
857
1382
  /**
1383
+ * Encodes an `unknown` input against a schema synchronously, throwing a
1384
+ * {@link SchemaError} on failure. Use this when you want to serialize data at a
1385
+ * boundary and treat a schema mismatch as an unrecoverable error. For
1386
+ * non-throwing alternatives see {@link encodeUnknownOption},
1387
+ * {@link encodeUnknownExit}, or {@link encodeUnknownEffect}. For typed input
1388
+ * use {@link encodeSync}.
1389
+ *
858
1390
  * @category Encoding
859
1391
  * @since 4.0.0
860
1392
  */
861
1393
  export const encodeUnknownSync = Parser.encodeUnknownSync
862
1394
 
863
1395
  /**
1396
+ * Encodes a typed input (the schema's `Type`) against a schema synchronously,
1397
+ * throwing a {@link SchemaError} on failure. For `unknown` input use
1398
+ * {@link encodeUnknownSync}.
1399
+ *
864
1400
  * @category Encoding
865
1401
  * @since 4.0.0
866
1402
  */
@@ -894,6 +1430,10 @@ export function isSchema(u: unknown): u is Top {
894
1430
  }
895
1431
 
896
1432
  /**
1433
+ * Schema type for an exact optional struct key. The key may be absent, but
1434
+ * when present must match the wrapped schema (no implicit `undefined`).
1435
+ * Produced by {@link optionalKey}.
1436
+ *
897
1437
  * @since 4.0.0
898
1438
  */
899
1439
  export interface optionalKey<S extends Top> extends
@@ -954,11 +1494,17 @@ interface requiredKeyLambda extends Lambda {
954
1494
  }
955
1495
 
956
1496
  /**
1497
+ * Reverses {@link optionalKey}, returning the inner required schema. Only
1498
+ * applicable to schemas already wrapped with `optionalKey`.
1499
+ *
957
1500
  * @since 4.0.0
958
1501
  */
959
1502
  export const requiredKey = Struct_.lambda<requiredKeyLambda>((self) => self.schema)
960
1503
 
961
1504
  /**
1505
+ * Schema type for an optional struct key that also accepts `undefined`.
1506
+ * Equivalent to `optionalKey<UndefinedOr<S>>`. Produced by {@link optional}.
1507
+ *
962
1508
  * @since 4.0.0
963
1509
  */
964
1510
  export interface optional<S extends Top> extends optionalKey<UndefinedOr<S>> {}
@@ -969,27 +1515,26 @@ interface optionalLambda extends Lambda {
969
1515
  }
970
1516
 
971
1517
  /**
972
- * Creates an optional schema field that allows both the specified type and
1518
+ * Marks a struct field as optional, allowing the key to be absent or
973
1519
  * `undefined`.
974
1520
  *
975
- * This is equivalent to `optionalKey(UndefinedOr(schema))`, creating a field
976
- * that:
977
- * - Can be omitted from the object entirely
978
- * - Can be explicitly set to `undefined`
979
- * - Can contain the specified schema type
1521
+ * explicitly set to `undefined`. Equivalent to `optionalKey(UndefinedOr(S))`.
980
1522
  *
981
- * **Example** (Creating a struct with optional)
1523
+ * Use {@link optionalKey} instead if you want exact optional semantics (absent
1524
+ * only, not `undefined`).
1525
+ *
1526
+ * **Example** (Optional field accepting undefined)
982
1527
  *
983
1528
  * ```ts
984
1529
  * import { Schema } from "effect"
985
1530
  *
986
1531
  * const schema = Schema.Struct({
987
1532
  * name: Schema.String,
988
- * age: Schema.optionalKey(Schema.Number)
1533
+ * age: Schema.optional(Schema.Number)
989
1534
  * })
990
1535
  *
991
- * // Type: { readonly name: string; readonly age?: number | undefined }
992
- * type Person = typeof schema["Type"]
1536
+ * // { readonly name: string; readonly age?: number | undefined }
1537
+ * type Person = typeof schema.Type
993
1538
  * ```
994
1539
  *
995
1540
  * @since 4.0.0
@@ -1003,11 +1548,17 @@ interface requiredLambda extends Lambda {
1003
1548
  }
1004
1549
 
1005
1550
  /**
1551
+ * Reverses {@link optional}, returning the inner schema (unwrapping `UndefinedOr`).
1552
+ * Only applicable to schemas already wrapped with `optional`.
1553
+ *
1006
1554
  * @since 4.0.0
1007
1555
  */
1008
1556
  export const required = Struct_.lambda<requiredLambda>((self) => self.schema.members[0])
1009
1557
 
1010
1558
  /**
1559
+ * Schema type for a mutable struct key. The key's property is writable.
1560
+ * Produced by {@link mutableKey}.
1561
+ *
1011
1562
  * @since 4.0.0
1012
1563
  */
1013
1564
  export interface mutableKey<S extends Top> extends
@@ -1039,6 +1590,9 @@ interface mutableKeyLambda extends Lambda {
1039
1590
  }
1040
1591
 
1041
1592
  /**
1593
+ * Makes a struct field mutable (removes the `readonly` modifier on the property).
1594
+ * Use {@link readonlyKey} to reverse.
1595
+ *
1042
1596
  * @since 4.0.0
1043
1597
  */
1044
1598
  export const mutableKey = Struct_.lambda<mutableKeyLambda>((schema) => make(AST.mutableKey(schema.ast), { schema }))
@@ -1050,11 +1604,17 @@ interface readonlyKeyLambda extends Lambda {
1050
1604
  }
1051
1605
 
1052
1606
  /**
1607
+ * Reverses {@link mutableKey}, returning the inner schema as readonly again.
1608
+ * Only applicable to schemas already wrapped with `mutableKey`.
1609
+ *
1053
1610
  * @since 4.0.0
1054
1611
  */
1055
1612
  export const readonlyKey = Struct_.lambda<readonlyKeyLambda>((self) => self.schema)
1056
1613
 
1057
1614
  /**
1615
+ * Schema type that collapses a transformation schema to its decoded `Type` on
1616
+ * both sides (Type = Encoded = S["Type"]). Produced by {@link toType}.
1617
+ *
1058
1618
  * @since 4.0.0
1059
1619
  */
1060
1620
  export interface toType<S extends Top> extends
@@ -1085,11 +1645,17 @@ interface toTypeLambda extends Lambda {
1085
1645
  }
1086
1646
 
1087
1647
  /**
1648
+ * Extracts the type-side schema: sets `Encoded` to equal the decoded `Type`,
1649
+ * discarding the encoding transformation path.
1650
+ *
1088
1651
  * @since 4.0.0
1089
1652
  */
1090
1653
  export const toType = Struct_.lambda<toTypeLambda>((schema) => make(AST.toType(schema.ast), { schema }))
1091
1654
 
1092
1655
  /**
1656
+ * Schema type that collapses a transformation schema to its `Encoded` side on
1657
+ * both sides (Type = Encoded = S["Encoded"]). Produced by {@link toEncoded}.
1658
+ *
1093
1659
  * @since 4.0.0
1094
1660
  */
1095
1661
  export interface toEncoded<S extends Top> extends
@@ -1120,6 +1686,9 @@ interface toEncodedLambda extends Lambda {
1120
1686
  }
1121
1687
 
1122
1688
  /**
1689
+ * Extracts the encoded-side schema: sets `Type` to equal the `Encoded`,
1690
+ * discarding the decoding transformation path.
1691
+ *
1123
1692
  * @since 4.0.0
1124
1693
  */
1125
1694
  export const toEncoded = Struct_.lambda<toEncodedLambda>((schema) => make(AST.toEncoded(schema.ast), { schema }))
@@ -1127,6 +1696,9 @@ export const toEncoded = Struct_.lambda<toEncodedLambda>((schema) => make(AST.to
1127
1696
  const FlipTypeId = "~effect/Schema/flip"
1128
1697
 
1129
1698
  /**
1699
+ * Schema type representing a flipped schema where `Type` and `Encoded` are
1700
+ * swapped. Produced by {@link flip}.
1701
+ *
1130
1702
  * @since 4.0.0
1131
1703
  */
1132
1704
  export interface flip<S extends Top> extends
@@ -1158,6 +1730,19 @@ function isFlip$(schema: Top): schema is flip<any> {
1158
1730
  }
1159
1731
 
1160
1732
  /**
1733
+ * Swaps the `Type` and `Encoded` of a schema, inverting the transformation
1734
+ * direction. Calling `flip` twice returns the original schema.
1735
+ *
1736
+ * **Example** (Flip a number-from-string schema)
1737
+ *
1738
+ * ```ts
1739
+ * import { Schema } from "effect"
1740
+ *
1741
+ * // NumberFromString: decodes string → number
1742
+ * const flipped = Schema.flip(Schema.NumberFromString)
1743
+ * // flipped: decodes number → string
1744
+ * ```
1745
+ *
1161
1746
  * @since 4.0.0
1162
1747
  */
1163
1748
  export function flip<S extends Top>(schema: S): S extends flip<infer F> ? F["~rebuild.out"] : flip<S>
@@ -1169,6 +1754,9 @@ export function flip<S extends Top>(schema: S): flip<S> {
1169
1754
  }
1170
1755
 
1171
1756
  /**
1757
+ * Represents a schema for a single literal value.
1758
+ *
1759
+ * @see {@link Literal} for the constructor function.
1172
1760
  * @since 4.0.0
1173
1761
  */
1174
1762
  export interface Literal<L extends AST.LiteralValue> extends Bottom<L, L, never, never, AST.Literal, Literal<L>> {
@@ -1178,6 +1766,16 @@ export interface Literal<L extends AST.LiteralValue> extends Bottom<L, L, never,
1178
1766
  }
1179
1767
 
1180
1768
  /**
1769
+ * Creates a schema for a single literal value (string, number, bigint, boolean, or null).
1770
+ *
1771
+ * **Example** (String literal)
1772
+ * ```ts
1773
+ * import { Schema } from "effect"
1774
+ *
1775
+ * const schema = Schema.Literal("hello")
1776
+ * // Type: Schema.Literal<"hello">
1777
+ * ```
1778
+ *
1181
1779
  * @see {@link Literals} for a schema that represents a union of literals.
1182
1780
  * @see {@link tag} for a schema that represents a literal value that can be
1183
1781
  * used as a discriminator field in tagged unions and has a constructor default.
@@ -1197,6 +1795,8 @@ export function Literal<L extends AST.LiteralValue>(literal: L): Literal<L> {
1197
1795
  }
1198
1796
 
1199
1797
  /**
1798
+ * Namespace for {@link TemplateLiteral} helper types.
1799
+ *
1200
1800
  * @since 4.0.0
1201
1801
  */
1202
1802
  export declare namespace TemplateLiteral {
@@ -1237,6 +1837,10 @@ export declare namespace TemplateLiteral {
1237
1837
  }
1238
1838
 
1239
1839
  /**
1840
+ * Represents a schema that validates strings matching a template literal pattern.
1841
+ * The encoded type is a string formed by concatenating the parts.
1842
+ *
1843
+ * @see {@link TemplateLiteral} for the constructor function.
1240
1844
  * @since 4.0.0
1241
1845
  */
1242
1846
  export interface TemplateLiteral<Parts extends TemplateLiteral.Parts> extends
@@ -1258,6 +1862,18 @@ function templateLiteralFromParts<Parts extends TemplateLiteral.Parts>(parts: Pa
1258
1862
  }
1259
1863
 
1260
1864
  /**
1865
+ * Creates a schema that validates strings matching a template literal pattern. Each part can be
1866
+ * a literal string/number/bigint or a schema whose encoded type is a string, number, or bigint.
1867
+ *
1868
+ * **Example** (URL path pattern)
1869
+ * ```ts
1870
+ * import { Schema } from "effect"
1871
+ *
1872
+ * const schema = Schema.TemplateLiteral(["/user/", Schema.Number])
1873
+ * // matches strings like "/user/123", "/user/42", etc.
1874
+ * ```
1875
+ *
1876
+ * @see {@link TemplateLiteralParser} for a schema that also parses matched parts into a tuple.
1261
1877
  * @since 4.0.0
1262
1878
  */
1263
1879
  export function TemplateLiteral<const Parts extends TemplateLiteral.Parts>(parts: Parts): TemplateLiteral<Parts> {
@@ -1265,6 +1881,8 @@ export function TemplateLiteral<const Parts extends TemplateLiteral.Parts>(parts
1265
1881
  }
1266
1882
 
1267
1883
  /**
1884
+ * Namespace for {@link TemplateLiteralParser} helper types.
1885
+ *
1268
1886
  * @since 4.0.0
1269
1887
  */
1270
1888
  export declare namespace TemplateLiteralParser {
@@ -1281,6 +1899,10 @@ export declare namespace TemplateLiteralParser {
1281
1899
  }
1282
1900
 
1283
1901
  /**
1902
+ * Represents a schema that validates strings matching a template literal pattern and decodes
1903
+ * them into a tuple of typed values, one per schema part.
1904
+ *
1905
+ * @see {@link TemplateLiteralParser} for the constructor function.
1284
1906
  * @since 4.0.0
1285
1907
  */
1286
1908
  export interface TemplateLiteralParser<Parts extends TemplateLiteral.Parts> extends
@@ -1298,6 +1920,18 @@ export interface TemplateLiteralParser<Parts extends TemplateLiteral.Parts> exte
1298
1920
  }
1299
1921
 
1300
1922
  /**
1923
+ * Like {@link TemplateLiteral} but decodes the matched string into a readonly tuple of typed values,
1924
+ * one element per schema part.
1925
+ *
1926
+ * **Example** (Parse path parameters)
1927
+ * ```ts
1928
+ * import { Schema } from "effect"
1929
+ *
1930
+ * const schema = Schema.TemplateLiteralParser(["/user/", Schema.NumberFromString])
1931
+ * // decodes "/user/42" => readonly ["/user/", 42]
1932
+ * ```
1933
+ *
1934
+ * @see {@link TemplateLiteral} for a validation-only version that keeps the string encoded.
1301
1935
  * @since 4.0.0
1302
1936
  */
1303
1937
  export function TemplateLiteralParser<const Parts extends TemplateLiteral.Parts>(
@@ -1307,6 +1941,10 @@ export function TemplateLiteralParser<const Parts extends TemplateLiteral.Parts>
1307
1941
  }
1308
1942
 
1309
1943
  /**
1944
+ * Represents a schema derived from a TypeScript `const enum` or a plain enum object,
1945
+ * accepting any of its values.
1946
+ *
1947
+ * @see {@link Enum} for the constructor function.
1310
1948
  * @since 4.0.0
1311
1949
  */
1312
1950
  export interface Enum<A extends { [x: string]: string | number }>
@@ -1317,6 +1955,21 @@ export interface Enum<A extends { [x: string]: string | number }>
1317
1955
  }
1318
1956
 
1319
1957
  /**
1958
+ * Creates a schema from a TypeScript enum object. Validates that the input is one of the enum's values.
1959
+ *
1960
+ * **Example** (Direction enum)
1961
+ * ```ts
1962
+ * import { Schema } from "effect"
1963
+ *
1964
+ * enum Direction {
1965
+ * Up = "Up",
1966
+ * Down = "Down"
1967
+ * }
1968
+ *
1969
+ * const schema = Schema.Enum(Direction)
1970
+ * // accepts "Up" or "Down"
1971
+ * ```
1972
+ *
1320
1973
  * @since 4.0.0
1321
1974
  */
1322
1975
  export function Enum<A extends { [x: string]: string | number }>(enums: A): Enum<A> {
@@ -1331,6 +1984,9 @@ export function Enum<A extends { [x: string]: string | number }>(enums: A): Enum
1331
1984
  }
1332
1985
 
1333
1986
  /**
1987
+ * Schema for the `never` type. Always fails validation.
1988
+ *
1989
+ * @see {@link Never} for the schema value.
1334
1990
  * @since 4.0.0
1335
1991
  */
1336
1992
  export interface Never extends Bottom<never, never, never, never, AST.Never, Never> {
@@ -1338,11 +1994,16 @@ export interface Never extends Bottom<never, never, never, never, AST.Never, Nev
1338
1994
  }
1339
1995
 
1340
1996
  /**
1997
+ * Schema for the `never` type. Always fails validation — no value satisfies it.
1998
+ *
1341
1999
  * @since 4.0.0
1342
2000
  */
1343
2001
  export const Never: Never = make(AST.never)
1344
2002
 
1345
2003
  /**
2004
+ * Schema for the `any` type. Accepts any value without validation.
2005
+ *
2006
+ * @see {@link Any} for the schema value.
1346
2007
  * @since 4.0.0
1347
2008
  */
1348
2009
  export interface Any extends Bottom<any, any, never, never, AST.Any, Any> {
@@ -1350,11 +2011,17 @@ export interface Any extends Bottom<any, any, never, never, AST.Any, Any> {
1350
2011
  }
1351
2012
 
1352
2013
  /**
2014
+ * Schema for the `any` type. Accepts any value without validation.
2015
+ *
2016
+ * @see {@link Unknown} for a safer alternative that uses `unknown`.
1353
2017
  * @since 4.0.0
1354
2018
  */
1355
2019
  export const Any: Any = make(AST.any)
1356
2020
 
1357
2021
  /**
2022
+ * Schema for the `unknown` type. Accepts any value without validation.
2023
+ *
2024
+ * @see {@link Unknown} for the schema value.
1358
2025
  * @since 4.0.0
1359
2026
  */
1360
2027
  export interface Unknown extends Bottom<unknown, unknown, never, never, AST.Unknown, Unknown> {
@@ -1362,11 +2029,17 @@ export interface Unknown extends Bottom<unknown, unknown, never, never, AST.Unkn
1362
2029
  }
1363
2030
 
1364
2031
  /**
2032
+ * Schema for the `unknown` type. Accepts any value without validation.
2033
+ *
2034
+ * @see {@link Any} for the `any` variant.
1365
2035
  * @since 4.0.0
1366
2036
  */
1367
2037
  export const Unknown: Unknown = make(AST.unknown)
1368
2038
 
1369
2039
  /**
2040
+ * Schema for the `null` literal. Validates that the input is strictly `null`.
2041
+ *
2042
+ * @see {@link Null} for the schema value.
1370
2043
  * @since 4.0.0
1371
2044
  */
1372
2045
  export interface Null extends Bottom<null, null, never, never, AST.Null, Null> {
@@ -1374,11 +2047,17 @@ export interface Null extends Bottom<null, null, never, never, AST.Null, Null> {
1374
2047
  }
1375
2048
 
1376
2049
  /**
2050
+ * Schema for the `null` literal. Validates that the input is strictly `null`.
2051
+ *
2052
+ * @see {@link NullOr} for a union with another schema.
1377
2053
  * @since 4.0.0
1378
2054
  */
1379
2055
  export const Null: Null = make(AST.null)
1380
2056
 
1381
2057
  /**
2058
+ * Schema for the `undefined` literal. Validates that the input is strictly `undefined`.
2059
+ *
2060
+ * @see {@link Undefined} for the schema value.
1382
2061
  * @since 4.0.0
1383
2062
  */
1384
2063
  export interface Undefined extends Bottom<undefined, undefined, never, never, AST.Undefined, Undefined> {
@@ -1386,11 +2065,17 @@ export interface Undefined extends Bottom<undefined, undefined, never, never, AS
1386
2065
  }
1387
2066
 
1388
2067
  /**
2068
+ * Schema for the `undefined` literal. Validates that the input is strictly `undefined`.
2069
+ *
2070
+ * @see {@link UndefinedOr} for a union with another schema.
1389
2071
  * @since 4.0.0
1390
2072
  */
1391
2073
  export const Undefined: Undefined = make(AST.undefined)
1392
2074
 
1393
2075
  /**
2076
+ * Schema for `string` values.
2077
+ *
2078
+ * @see {@link String} for the schema value.
1394
2079
  * @since 4.0.0
1395
2080
  */
1396
2081
  export interface String extends Bottom<string, string, never, never, AST.String, String> {
@@ -1398,13 +2083,16 @@ export interface String extends Bottom<string, string, never, never, AST.String,
1398
2083
  }
1399
2084
 
1400
2085
  /**
1401
- * A schema for all strings.
2086
+ * Schema for `string` values. Validates that the input is `typeof` `"string"`.
1402
2087
  *
1403
2088
  * @since 4.0.0
1404
2089
  */
1405
2090
  export const String: String = make(AST.string)
1406
2091
 
1407
2092
  /**
2093
+ * Schema for `number` values, including `NaN`, `Infinity`, and `-Infinity`.
2094
+ *
2095
+ * @see {@link Number} for the schema value.
1408
2096
  * @since 4.0.0
1409
2097
  */
1410
2098
  export interface Number extends Bottom<number, number, never, never, AST.Number, Number> {
@@ -1412,18 +2100,22 @@ export interface Number extends Bottom<number, number, never, never, AST.Number,
1412
2100
  }
1413
2101
 
1414
2102
  /**
1415
- * A schema for all numbers, including `NaN`, `Infinity`, and `-Infinity`.
2103
+ * Schema for `number` values, including `NaN`, `Infinity`, and `-Infinity`.
1416
2104
  *
1417
2105
  * **Default Json Serializer**
1418
2106
  *
1419
- * - If the number is finite, it is serialized as a number.
1420
- * - Otherwise, it is serialized as a string ("NaN", "Infinity", or "-Infinity").
2107
+ * - Finite numbers are serialized as numbers.
2108
+ * - Non-finite values are serialized as strings (`"NaN"`, `"Infinity"`, `"-Infinity"`).
1421
2109
  *
2110
+ * @see {@link Finite} for a schema that excludes non-finite values.
1422
2111
  * @since 4.0.0
1423
2112
  */
1424
2113
  export const Number: Number = make(AST.number)
1425
2114
 
1426
2115
  /**
2116
+ * Schema for `boolean` values.
2117
+ *
2118
+ * @see {@link Boolean} for the schema value.
1427
2119
  * @since 4.0.0
1428
2120
  */
1429
2121
  export interface Boolean extends Bottom<boolean, boolean, never, never, AST.Boolean, Boolean> {
@@ -1431,7 +2123,7 @@ export interface Boolean extends Bottom<boolean, boolean, never, never, AST.Bool
1431
2123
  }
1432
2124
 
1433
2125
  /**
1434
- * A schema for all booleans.
2126
+ * Schema for `boolean` values. Validates that the input is `typeof` `"boolean"`.
1435
2127
  *
1436
2128
  * @category Boolean
1437
2129
  * @since 4.0.0
@@ -1439,6 +2131,9 @@ export interface Boolean extends Bottom<boolean, boolean, never, never, AST.Bool
1439
2131
  export const Boolean: Boolean = make(AST.boolean)
1440
2132
 
1441
2133
  /**
2134
+ * Schema for `symbol` values.
2135
+ *
2136
+ * @see {@link Symbol} for the schema value.
1442
2137
  * @since 4.0.0
1443
2138
  */
1444
2139
  export interface Symbol extends Bottom<symbol, symbol, never, never, AST.Symbol, Symbol> {
@@ -1446,13 +2141,17 @@ export interface Symbol extends Bottom<symbol, symbol, never, never, AST.Symbol,
1446
2141
  }
1447
2142
 
1448
2143
  /**
1449
- * A schema for all symbols.
2144
+ * Schema for `symbol` values. Validates that the input is `typeof` `"symbol"`.
1450
2145
  *
2146
+ * @see {@link UniqueSymbol} for a schema that matches a specific symbol.
1451
2147
  * @since 4.0.0
1452
2148
  */
1453
2149
  export const Symbol: Symbol = make(AST.symbol)
1454
2150
 
1455
2151
  /**
2152
+ * Schema for `bigint` values.
2153
+ *
2154
+ * @see {@link BigInt} for the schema value.
1456
2155
  * @since 4.0.0
1457
2156
  */
1458
2157
  export interface BigInt extends Bottom<bigint, bigint, never, never, AST.BigInt, BigInt> {
@@ -1460,13 +2159,16 @@ export interface BigInt extends Bottom<bigint, bigint, never, never, AST.BigInt,
1460
2159
  }
1461
2160
 
1462
2161
  /**
1463
- * A schema for all bigints.
2162
+ * Schema for `bigint` values. Validates that the input is `typeof` `"bigint"`.
1464
2163
  *
1465
2164
  * @since 4.0.0
1466
2165
  */
1467
2166
  export const BigInt: BigInt = make(AST.bigInt)
1468
2167
 
1469
2168
  /**
2169
+ * Schema for the `void` type.
2170
+ *
2171
+ * @see {@link Void} for the schema value.
1470
2172
  * @since 4.0.0
1471
2173
  */
1472
2174
  export interface Void extends Bottom<void, void, never, never, AST.Void, Void> {
@@ -1474,13 +2176,16 @@ export interface Void extends Bottom<void, void, never, never, AST.Void, Void> {
1474
2176
  }
1475
2177
 
1476
2178
  /**
1477
- * A schema for the `void` type.
2179
+ * Schema for the `void` type. Accepts `undefined` as the encoded value.
1478
2180
  *
1479
2181
  * @since 4.0.0
1480
2182
  */
1481
2183
  export const Void: Void = make(AST.void)
1482
2184
 
1483
2185
  /**
2186
+ * Schema for the `object` type keyword.
2187
+ *
2188
+ * @see {@link ObjectKeyword} for the schema value.
1484
2189
  * @since 4.0.0
1485
2190
  */
1486
2191
  export interface ObjectKeyword extends Bottom<object, object, never, never, AST.ObjectKeyword, ObjectKeyword> {
@@ -1488,13 +2193,17 @@ export interface ObjectKeyword extends Bottom<object, object, never, never, AST.
1488
2193
  }
1489
2194
 
1490
2195
  /**
1491
- * A schema for the `object` type.
2196
+ * Schema for the `object` type. Validates that the input is a non-null object or function
2197
+ * (i.e. `typeof value === "object" && value !== null || typeof value === "function"`).
1492
2198
  *
1493
2199
  * @since 4.0.0
1494
2200
  */
1495
2201
  export const ObjectKeyword: ObjectKeyword = make(AST.objectKeyword)
1496
2202
 
1497
2203
  /**
2204
+ * Represents a schema for a specific unique symbol.
2205
+ *
2206
+ * @see {@link UniqueSymbol} for the constructor function.
1498
2207
  * @since 4.0.0
1499
2208
  */
1500
2209
  export interface UniqueSymbol<sym extends symbol>
@@ -1504,16 +2213,17 @@ export interface UniqueSymbol<sym extends symbol>
1504
2213
  }
1505
2214
 
1506
2215
  /**
1507
- * A schema for unique symbols.
1508
- *
1509
- * **Example**
2216
+ * Creates a schema for a specific symbol. Only that exact symbol satisfies the schema.
1510
2217
  *
2218
+ * **Example** (Specific symbol)
1511
2219
  * ```ts
1512
2220
  * import { Schema } from "effect"
1513
2221
  *
1514
- * const a = Symbol.for("a")
1515
- * const schema = Schema.UniqueSymbol(a)
2222
+ * const mySymbol = Symbol.for("mySymbol")
2223
+ * const schema = Schema.UniqueSymbol(mySymbol)
1516
2224
  * ```
2225
+ *
2226
+ * @see {@link Symbol} for a schema that accepts any symbol.
1517
2227
  * @since 4.0.0
1518
2228
  */
1519
2229
  export function UniqueSymbol<const sym extends symbol>(symbol: sym): UniqueSymbol<sym> {
@@ -1521,10 +2231,24 @@ export function UniqueSymbol<const sym extends symbol>(symbol: sym): UniqueSymbo
1521
2231
  }
1522
2232
 
1523
2233
  /**
2234
+ * Namespace for struct field type utilities.
2235
+ *
2236
+ * These types compute the decoded `Type`, encoded `Encoded`, and constructor
2237
+ * input `MakeIn` of a {@link Struct} from its field map, handling optional,
2238
+ * mutable, and other field modifiers automatically.
2239
+ *
2240
+ * - `Struct.Fields` — constraint for the field map object
2241
+ * - `Struct.Type<F>` — decoded type of the struct
2242
+ * - `Struct.Encoded<F>` — encoded type of the struct
2243
+ * - `Struct.MakeIn<F>` — constructor input (optional/defaulted fields may be omitted)
2244
+ * - `Struct.DecodingServices<F>` / `Struct.EncodingServices<F>` — required services
2245
+ *
1524
2246
  * @since 4.0.0
1525
2247
  */
1526
2248
  export declare namespace Struct {
1527
2249
  /**
2250
+ * Constraint for a struct field map: an object whose values are schemas.
2251
+ *
1528
2252
  * @since 4.0.0
1529
2253
  */
1530
2254
  export type Fields = { readonly [x: PropertyKey]: Top }
@@ -1699,6 +2423,34 @@ function makeStruct<const Fields extends Struct.Fields>(ast: AST.Objects, fields
1699
2423
  }
1700
2424
 
1701
2425
  /**
2426
+ * Defines a struct schema from a map of field schemas.
2427
+ *
2428
+ * Each field value is a schema. Use {@link optionalKey} or {@link optional} to
2429
+ * mark fields as optional, and {@link mutableKey} to mark them as mutable.
2430
+ *
2431
+ * The resulting schema's `Type` is a readonly object type with the fields'
2432
+ * decoded types. The `Encoded` form mirrors the field schemas' encoded types.
2433
+ *
2434
+ * **Example** (Basic struct)
2435
+ *
2436
+ * ```ts
2437
+ * import { Schema } from "effect"
2438
+ *
2439
+ * const Person = Schema.Struct({
2440
+ * name: Schema.String,
2441
+ * age: Schema.Number,
2442
+ * email: Schema.optionalKey(Schema.String)
2443
+ * })
2444
+ *
2445
+ * // { readonly name: string; readonly age: number; readonly email?: string }
2446
+ * type Person = typeof Person.Type
2447
+ *
2448
+ * const alice = Schema.decodeUnknownSync(Person)({ name: "Alice", age: 30 })
2449
+ * console.log(alice)
2450
+ * // { name: 'Alice', age: 30 }
2451
+ * ```
2452
+ *
2453
+ * @category Constructors
1702
2454
  * @since 4.0.0
1703
2455
  */
1704
2456
  export function Struct<const Fields extends Struct.Fields>(fields: Fields): Struct<Fields> {
@@ -1737,6 +2489,26 @@ export function fieldsAssign<const NewFields extends Struct.Fields>(fields: NewF
1737
2489
  }
1738
2490
 
1739
2491
  /**
2492
+ * Renames struct keys in the encoded form without changing the decoded type.
2493
+ *
2494
+ * Takes a partial mapping `{ decodedKey: encodedKey }` and produces a
2495
+ * transformation schema that decodes from the renamed keys and encodes back to
2496
+ * the renamed keys. Keys not present in the mapping are left unchanged.
2497
+ *
2498
+ * **Example** (Rename `name` to `full_name` in the encoded form)
2499
+ *
2500
+ * ```ts
2501
+ * import { Schema } from "effect"
2502
+ *
2503
+ * const Person = Schema.Struct({ name: Schema.String, age: Schema.Number })
2504
+ * const Encoded = Person.pipe(Schema.encodeKeys({ name: "full_name" }))
2505
+ *
2506
+ * // Decodes { full_name: "Alice", age: 30 } → { name: "Alice", age: 30 }
2507
+ * const alice = Schema.decodeUnknownSync(Encoded)({ full_name: "Alice", age: 30 })
2508
+ * console.log(alice)
2509
+ * // { name: 'Alice', age: 30 }
2510
+ * ```
2511
+ *
1740
2512
  * @category Struct transformations
1741
2513
  * @since 4.0.0
1742
2514
  */
@@ -1778,6 +2550,31 @@ export function encodeKeys<
1778
2550
  }
1779
2551
 
1780
2552
  /**
2553
+ * Adds derived fields to a struct schema during decoding.
2554
+ *
2555
+ * Each new field is derived from the decoded struct value via a function that
2556
+ * returns `Option`. On encoding the derived fields are stripped. This allows
2557
+ * computed or enriched fields to live in the decoded type without appearing in
2558
+ * the encoded form.
2559
+ *
2560
+ * **Example** (Add a computed `fullName` field)
2561
+ *
2562
+ * ```ts
2563
+ * import { Option, Schema } from "effect"
2564
+ *
2565
+ * const Person = Schema.Struct({ first: Schema.String, last: Schema.String })
2566
+ * const Extended = Person.pipe(
2567
+ * Schema.extendTo(
2568
+ * { fullName: Schema.String },
2569
+ * { fullName: (p) => Option.some(`${p.first} ${p.last}`) }
2570
+ * )
2571
+ * )
2572
+ *
2573
+ * const alice = Schema.decodeUnknownSync(Extended)({ first: "Alice", last: "Smith" })
2574
+ * console.log(alice.fullName)
2575
+ * // Alice Smith
2576
+ * ```
2577
+ *
1781
2578
  * @since 4.0.0
1782
2579
  * @experimental
1783
2580
  */
@@ -1819,6 +2616,12 @@ export function extendTo<S extends Struct<Struct.Fields>, const Fields extends S
1819
2616
  }
1820
2617
 
1821
2618
  /**
2619
+ * Namespace for `Record` type utilities.
2620
+ *
2621
+ * - `Record.Key` — constraint for the key schema (must encode to `PropertyKey`)
2622
+ * - `Record.Type<K, V>` — decoded type of the record
2623
+ * - `Record.Encoded<K, V>` — encoded type of the record
2624
+ *
1822
2625
  * @since 4.0.0
1823
2626
  */
1824
2627
  export declare namespace Record {
@@ -1886,6 +2689,9 @@ export declare namespace Record {
1886
2689
  }
1887
2690
 
1888
2691
  /**
2692
+ * Schema type for a key-value record (map) with a typed key and value schema.
2693
+ * Produced by {@link Record}.
2694
+ *
1889
2695
  * @since 4.0.0
1890
2696
  */
1891
2697
  export interface $Record<Key extends Record.Key, Value extends Top> extends
@@ -1906,6 +2712,24 @@ export interface $Record<Key extends Record.Key, Value extends Top> extends
1906
2712
  }
1907
2713
 
1908
2714
  /**
2715
+ * Defines a record (dictionary) schema with typed keys and values.
2716
+ *
2717
+ * **Example** (String-keyed record of numbers)
2718
+ *
2719
+ * ```ts
2720
+ * import { Schema } from "effect"
2721
+ *
2722
+ * const schema = Schema.Record(Schema.String, Schema.Number)
2723
+ *
2724
+ * // { readonly [x: string]: number }
2725
+ * type R = typeof schema.Type
2726
+ *
2727
+ * const result = Schema.decodeUnknownSync(schema)({ a: 1, b: 2 })
2728
+ * console.log(result)
2729
+ * // { a: 1, b: 2 }
2730
+ * ```
2731
+ *
2732
+ * @category Constructors
1909
2733
  * @since 4.0.0
1910
2734
  */
1911
2735
  export function Record<Key extends Record.Key, Value extends Top>(
@@ -1925,6 +2749,11 @@ export function Record<Key extends Record.Key, Value extends Top>(
1925
2749
  }
1926
2750
 
1927
2751
  /**
2752
+ * Namespace for `StructWithRest` type utilities.
2753
+ *
2754
+ * - `StructWithRest.Type<S, R>` — decoded type (struct type intersected with record types)
2755
+ * - `StructWithRest.Encoded<S, R>` — encoded type
2756
+ *
1928
2757
  * @since 4.0.0
1929
2758
  */
1930
2759
  export declare namespace StructWithRest {
@@ -1986,6 +2815,9 @@ export declare namespace StructWithRest {
1986
2815
  }
1987
2816
 
1988
2817
  /**
2818
+ * Schema type for a struct combined with one or more record schemas. Produced
2819
+ * by {@link StructWithRest}.
2820
+ *
1989
2821
  * @since 4.0.0
1990
2822
  */
1991
2823
  export interface StructWithRest<
@@ -2009,6 +2841,24 @@ export interface StructWithRest<
2009
2841
  }
2010
2842
 
2011
2843
  /**
2844
+ * Extends a struct schema with one or more record (index-signature) schemas,
2845
+ * producing a schema whose decoded type intersects the struct and all records.
2846
+ *
2847
+ * **Example** (Struct with string-indexed extra keys)
2848
+ *
2849
+ * ```ts
2850
+ * import { Schema } from "effect"
2851
+ *
2852
+ * const schema = Schema.StructWithRest(
2853
+ * Schema.Struct({ id: Schema.Number }),
2854
+ * [Schema.Record(Schema.String, Schema.String)]
2855
+ * )
2856
+ *
2857
+ * // { readonly id: number } & { readonly [x: string]: string }
2858
+ * type T = typeof schema.Type
2859
+ * ```
2860
+ *
2861
+ * @category Constructors
2012
2862
  * @since 4.0.0
2013
2863
  */
2014
2864
  export function StructWithRest<
@@ -2022,6 +2872,13 @@ export function StructWithRest<
2022
2872
  }
2023
2873
 
2024
2874
  /**
2875
+ * Namespace for `Tuple` type utilities.
2876
+ *
2877
+ * - `Tuple.Elements` — constraint for the element schema array
2878
+ * - `Tuple.Type<E>` — decoded tuple type
2879
+ * - `Tuple.Encoded<E>` — encoded tuple type
2880
+ * - `Tuple.MakeIn<E>` — constructor input tuple
2881
+ *
2025
2882
  * @since 4.0.0
2026
2883
  */
2027
2884
  export declare namespace Tuple {
@@ -2104,6 +2961,8 @@ export declare namespace Tuple {
2104
2961
  }
2105
2962
 
2106
2963
  /**
2964
+ * Schema type for a fixed-length tuple. Produced by {@link Tuple}.
2965
+ *
2107
2966
  * @since 4.0.0
2108
2967
  */
2109
2968
  export interface Tuple<Elements extends Tuple.Elements> extends
@@ -2159,6 +3018,20 @@ function makeTuple<Elements extends Tuple.Elements>(ast: AST.Arrays, elements: E
2159
3018
  }
2160
3019
 
2161
3020
  /**
3021
+ * Defines a fixed-length tuple schema from an array of element schemas.
3022
+ *
3023
+ * **Example** (Pair of string and number)
3024
+ *
3025
+ * ```ts
3026
+ * import { Schema } from "effect"
3027
+ *
3028
+ * const schema = Schema.Tuple([Schema.String, Schema.Number])
3029
+ *
3030
+ * const pair = Schema.decodeUnknownSync(schema)(["hello", 42])
3031
+ * console.log(pair)
3032
+ * // [ 'hello', 42 ]
3033
+ * ```
3034
+ *
2162
3035
  * @category Constructors
2163
3036
  * @since 4.0.0
2164
3037
  */
@@ -2167,6 +3040,13 @@ export function Tuple<const Elements extends ReadonlyArray<Top>>(elements: Eleme
2167
3040
  }
2168
3041
 
2169
3042
  /**
3043
+ * Namespace for `TupleWithRest` type utilities.
3044
+ *
3045
+ * - `TupleWithRest.TupleType` — constraint for the leading tuple schema
3046
+ * - `TupleWithRest.Rest` — the rest element schema(s)
3047
+ * - `TupleWithRest.Type<T, R>` — decoded type (fixed elements + rest)
3048
+ * - `TupleWithRest.Encoded<T, R>` — encoded type
3049
+ *
2170
3050
  * @since 4.0.0
2171
3051
  */
2172
3052
  export declare namespace TupleWithRest {
@@ -2232,6 +3112,9 @@ export declare namespace TupleWithRest {
2232
3112
  }
2233
3113
 
2234
3114
  /**
3115
+ * Schema type for a tuple with additional rest elements. Produced by
3116
+ * {@link TupleWithRest}.
3117
+ *
2235
3118
  * @since 4.0.0
2236
3119
  */
2237
3120
  export interface TupleWithRest<
@@ -2255,6 +3138,26 @@ export interface TupleWithRest<
2255
3138
  }
2256
3139
 
2257
3140
  /**
3141
+ * Extends a fixed-length tuple schema with rest elements, creating a variadic
3142
+ * tuple that starts with the fixed elements and ends with zero or more rest
3143
+ * elements.
3144
+ *
3145
+ * **Example** (Tuple with rest)
3146
+ *
3147
+ * ```ts
3148
+ * import { Schema } from "effect"
3149
+ *
3150
+ * // [string, number, ...boolean[]]
3151
+ * const schema = Schema.TupleWithRest(
3152
+ * Schema.Tuple([Schema.String, Schema.Number]),
3153
+ * [Schema.Boolean]
3154
+ * )
3155
+ *
3156
+ * const result = Schema.decodeUnknownSync(schema)(["hello", 1, true, false])
3157
+ * console.log(result)
3158
+ * // [ 'hello', 1, true, false ]
3159
+ * ```
3160
+ *
2258
3161
  * @category Constructors
2259
3162
  * @since 4.0.0
2260
3163
  */
@@ -2266,6 +3169,8 @@ export function TupleWithRest<S extends Tuple<Tuple.Elements>, const Rest extend
2266
3169
  }
2267
3170
 
2268
3171
  /**
3172
+ * Schema type for a `ReadonlyArray`. Produced by {@link Array}.
3173
+ *
2269
3174
  * @since 4.0.0
2270
3175
  */
2271
3176
  export interface $Array<S extends Top> extends
@@ -2290,12 +3195,28 @@ interface ArrayLambda extends Lambda {
2290
3195
  }
2291
3196
 
2292
3197
  /**
3198
+ * Defines a `ReadonlyArray` schema for a given element schema.
3199
+ *
3200
+ * **Example** (Array of strings)
3201
+ *
3202
+ * ```ts
3203
+ * import { Schema } from "effect"
3204
+ *
3205
+ * const schema = Schema.Array(Schema.String)
3206
+ *
3207
+ * const result = Schema.decodeUnknownSync(schema)(["a", "b", "c"])
3208
+ * console.log(result)
3209
+ * // [ 'a', 'b', 'c' ]
3210
+ * ```
3211
+ *
2293
3212
  * @category Constructors
2294
3213
  * @since 4.0.0
2295
3214
  */
2296
3215
  export const Array = Struct_.lambda<ArrayLambda>((schema) => make(new AST.Arrays(false, [], [schema.ast]), { schema }))
2297
3216
 
2298
3217
  /**
3218
+ * Schema type for a non-empty `ReadonlyArray`. Produced by {@link NonEmptyArray}.
3219
+ *
2299
3220
  * @since 4.0.0
2300
3221
  */
2301
3222
  export interface NonEmptyArray<S extends Top> extends
@@ -2320,6 +3241,20 @@ interface NonEmptyArrayLambda extends Lambda {
2320
3241
  }
2321
3242
 
2322
3243
  /**
3244
+ * Defines a non-empty `ReadonlyArray` schema — at least one element required.
3245
+ * Type is `readonly [T, ...T[]]`.
3246
+ *
3247
+ * **Example** (Non-empty array of numbers)
3248
+ *
3249
+ * ```ts
3250
+ * import { Schema } from "effect"
3251
+ *
3252
+ * const schema = Schema.NonEmptyArray(Schema.Number)
3253
+ *
3254
+ * Schema.decodeUnknownSync(schema)([1, 2, 3]) // ok
3255
+ * Schema.decodeUnknownSync(schema)([]) // throws
3256
+ * ```
3257
+ *
2323
3258
  * @category Constructors
2324
3259
  * @since 4.0.0
2325
3260
  */
@@ -2328,6 +3263,8 @@ export const NonEmptyArray = Struct_.lambda<NonEmptyArrayLambda>((schema) =>
2328
3263
  )
2329
3264
 
2330
3265
  /**
3266
+ * Schema type for an array with unique elements. Produced by {@link UniqueArray}.
3267
+ *
2331
3268
  * @since 4.0.0
2332
3269
  */
2333
3270
  export interface UniqueArray<S extends Top> extends $Array<S> {}
@@ -2346,6 +3283,9 @@ export function UniqueArray<S extends Top>(item: S): UniqueArray<S> {
2346
3283
  }
2347
3284
 
2348
3285
  /**
3286
+ * Schema type that makes array or tuple elements mutable (removes `readonly`).
3287
+ * Produced by {@link mutable}.
3288
+ *
2349
3289
  * @since 4.0.0
2350
3290
  */
2351
3291
  export interface mutable<S extends Top & { readonly "ast": AST.Arrays }> extends
@@ -2379,7 +3319,18 @@ interface mutableLambda extends Lambda {
2379
3319
  }
2380
3320
 
2381
3321
  /**
2382
- * Makes arrays or tuples mutable.
3322
+ * Makes an array or tuple schema mutable, removing the `readonly` modifier.
3323
+ *
3324
+ * **Example** (Mutable array)
3325
+ *
3326
+ * ```ts
3327
+ * import { Schema } from "effect"
3328
+ *
3329
+ * const schema = Schema.mutable(Schema.Array(Schema.Number))
3330
+ *
3331
+ * // number[] (mutable)
3332
+ * type T = typeof schema.Type
3333
+ * ```
2383
3334
  *
2384
3335
  * @since 4.0.0
2385
3336
  */
@@ -2388,6 +3339,8 @@ export const mutable = Struct_.lambda<mutableLambda>((schema) => {
2388
3339
  })
2389
3340
 
2390
3341
  /**
3342
+ * Schema type for a union of multiple schemas. Produced by {@link Union}.
3343
+ *
2391
3344
  * @since 4.0.0
2392
3345
  */
2393
3346
  export interface Union<Members extends ReadonlyArray<Top>> extends
@@ -2449,12 +3402,23 @@ function makeUnion<Members extends ReadonlyArray<Top>>(
2449
3402
  }
2450
3403
 
2451
3404
  /**
2452
- * Creates a schema that represents a union of multiple schemas. Members are checked in order, and the first match is returned.
3405
+ * Creates a union schema from an array of member schemas. Members are tested in
3406
+ * order; the first match is returned.
2453
3407
  *
2454
- * Optionally, you can specify the `mode` to be `"anyOf"` or `"oneOf"`.
3408
+ * Optionally, specify `mode`:
3409
+ * - `"anyOf"` (default) — matches if any member matches.
3410
+ * - `"oneOf"` — matches if exactly one member matches.
2455
3411
  *
2456
- * - `"anyOf"` - The union matches if any member matches.
2457
- * - `"oneOf"` - The union matches if exactly one member matches.
3412
+ * **Example** (String or number union)
3413
+ *
3414
+ * ```ts
3415
+ * import { Schema } from "effect"
3416
+ *
3417
+ * const schema = Schema.Union([Schema.String, Schema.Number])
3418
+ *
3419
+ * Schema.decodeUnknownSync(schema)("hello") // "hello"
3420
+ * Schema.decodeUnknownSync(schema)(42) // 42
3421
+ * ```
2458
3422
  *
2459
3423
  * @category Constructors
2460
3424
  * @since 4.0.0
@@ -2467,6 +3431,9 @@ export function Union<const Members extends ReadonlyArray<Top>>(
2467
3431
  }
2468
3432
 
2469
3433
  /**
3434
+ * Represents a union schema of multiple literal values.
3435
+ *
3436
+ * @see {@link Literals} for the constructor function.
2470
3437
  * @since 4.0.0
2471
3438
  */
2472
3439
  export interface Literals<L extends ReadonlyArray<AST.LiteralValue>>
@@ -2488,6 +3455,16 @@ export interface Literals<L extends ReadonlyArray<AST.LiteralValue>>
2488
3455
  }
2489
3456
 
2490
3457
  /**
3458
+ * Creates a union schema from an array of literal values.
3459
+ *
3460
+ * **Example** (Status codes)
3461
+ * ```ts
3462
+ * import { Schema } from "effect"
3463
+ *
3464
+ * const schema = Schema.Literals(["active", "inactive", "pending"])
3465
+ * // accepts "active", "inactive", or "pending"
3466
+ * ```
3467
+ *
2491
3468
  * @see {@link Literal} for a schema that represents a single literal.
2492
3469
  * @category Constructors
2493
3470
  * @since 4.0.0
@@ -2515,6 +3492,8 @@ export function Literals<const L extends ReadonlyArray<AST.LiteralValue>>(litera
2515
3492
  }
2516
3493
 
2517
3494
  /**
3495
+ * Schema type for `S | null`. Produced by {@link NullOr}.
3496
+ *
2518
3497
  * @since 4.0.0
2519
3498
  */
2520
3499
  export interface NullOr<S extends Top> extends Union<readonly [S, Null]> {}
@@ -2525,12 +3504,16 @@ interface NullOrLambda extends Lambda {
2525
3504
  }
2526
3505
 
2527
3506
  /**
3507
+ * Creates a union schema of `S | null`.
3508
+ *
2528
3509
  * @category Constructors
2529
3510
  * @since 4.0.0
2530
3511
  */
2531
3512
  export const NullOr = Struct_.lambda<NullOrLambda>((self) => Union([self, Null]))
2532
3513
 
2533
3514
  /**
3515
+ * Schema type for `S | undefined`. Produced by {@link UndefinedOr}.
3516
+ *
2534
3517
  * @since 4.0.0
2535
3518
  */
2536
3519
  export interface UndefinedOr<S extends Top> extends Union<readonly [S, Undefined]> {}
@@ -2541,12 +3524,15 @@ interface UndefinedOrLambda extends Lambda {
2541
3524
  }
2542
3525
 
2543
3526
  /**
3527
+ * Creates a union schema of `S | undefined`.
3528
+ *
2544
3529
  * @category Constructors
2545
3530
  * @since 4.0.0
2546
3531
  */
2547
3532
  export const UndefinedOr = Struct_.lambda<UndefinedOrLambda>((self) => Union([self, Undefined]))
2548
3533
 
2549
3534
  /**
3535
+ * Schema type for `S | null | undefined`. Produced by {@link NullishOr}.
2550
3536
  * @since 4.0.0
2551
3537
  */
2552
3538
  export interface NullishOr<S extends Top> extends Union<readonly [S, Null, Undefined]> {}
@@ -2557,12 +3543,14 @@ interface NullishOrLambda extends Lambda {
2557
3543
  }
2558
3544
 
2559
3545
  /**
3546
+ * Creates a union schema of `S | null | undefined`.
2560
3547
  * @category Constructors
2561
3548
  * @since 4.0.0
2562
3549
  */
2563
3550
  export const NullishOr = Struct_.lambda<NullishOrLambda>((self) => Union([self, Null, Undefined]))
2564
3551
 
2565
3552
  /**
3553
+ * Schema type wrapping a lazily-evaluated schema. Produced by {@link suspend}.
2566
3554
  * @since 4.0.0
2567
3555
  */
2568
3556
  export interface suspend<S extends Top> extends
@@ -2592,6 +3580,21 @@ export interface suspend<S extends Top> extends
2592
3580
  * essential for creating recursive schemas where a schema references itself,
2593
3581
  * preventing infinite recursion during schema definition.
2594
3582
  *
3583
+ * **Example** (Recursive tree schema)
3584
+ * ```ts
3585
+ * import { Schema } from "effect"
3586
+ *
3587
+ * interface Tree {
3588
+ * readonly value: number
3589
+ * readonly children: ReadonlyArray<Tree>
3590
+ * }
3591
+ *
3592
+ * const Tree = Schema.Struct({
3593
+ * value: Schema.Number,
3594
+ * children: Schema.Array(Schema.suspend((): Schema.Codec<Tree> => Tree))
3595
+ * })
3596
+ * ```
3597
+ *
2595
3598
  * @category Constructors
2596
3599
  * @since 4.0.0
2597
3600
  */
@@ -2600,6 +3603,18 @@ export function suspend<S extends Top>(f: () => S): suspend<S> {
2600
3603
  }
2601
3604
 
2602
3605
  /**
3606
+ * Pipeable function that attaches one or more filter checks to a schema without
3607
+ * changing the TypeScript type.
3608
+ *
3609
+ * **Example** (Adding checks to a schema)
3610
+ * ```ts
3611
+ * import { Schema } from "effect"
3612
+ *
3613
+ * const AgeSchema = Schema.Number.pipe(
3614
+ * Schema.check(Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(120))
3615
+ * )
3616
+ * ```
3617
+ *
2603
3618
  * @category Filtering
2604
3619
  * @since 4.0.0
2605
3620
  */
@@ -2608,6 +3623,9 @@ export function check<S extends Top>(...checks: readonly [AST.Check<S["Type"]>,
2608
3623
  }
2609
3624
 
2610
3625
  /**
3626
+ * The output type of {@link refine}, narrowing the schema's `Type` to `T` via a
3627
+ * type guard.
3628
+ *
2611
3629
  * @since 4.0.0
2612
3630
  */
2613
3631
  export interface refine<T extends S["Type"], S extends Top> extends
@@ -2634,6 +3652,9 @@ export interface refine<T extends S["Type"], S extends Top> extends
2634
3652
  }
2635
3653
 
2636
3654
  /**
3655
+ * Narrows the TypeScript type of a schema's output via a type guard predicate,
3656
+ * attaching the guard as a runtime filter check.
3657
+ *
2637
3658
  * @category Filtering
2638
3659
  * @since 4.0.0
2639
3660
  */
@@ -2648,6 +3669,9 @@ export function refine<S extends Top, T extends S["Type"]>(
2648
3669
  type DistributeBrands<B> = UnionToIntersection<B extends infer U extends string ? Brand.Brand<U> : never>
2649
3670
 
2650
3671
  /**
3672
+ * The output type of {@link brand}, intersecting the schema's `Type` with one or
3673
+ * more {@link Brand.Brand} tags.
3674
+ *
2651
3675
  * @since 4.0.0
2652
3676
  */
2653
3677
  export interface brand<S extends Top, B> extends
@@ -2675,7 +3699,8 @@ export interface brand<S extends Top, B> extends
2675
3699
  }
2676
3700
 
2677
3701
  /**
2678
- * Adds a brand to a schema.
3702
+ * Adds a nominal brand to a schema, intersecting the output type with
3703
+ * `Brand.Brand<B>` to prevent accidental mixing of structurally identical types.
2679
3704
  *
2680
3705
  * @category Branding
2681
3706
  * @since 4.0.0
@@ -2686,7 +3711,10 @@ export function brand<B extends string>(identifier: B) {
2686
3711
  }
2687
3712
 
2688
3713
  /**
2689
- * @category Constructors
3714
+ * Creates a branded schema from a {@link Brand.Constructor}, applying the
3715
+ * constructor's checks and brand tag to the underlying schema.
3716
+ *
3717
+ * @category Branding
2690
3718
  * @since 4.0.0
2691
3719
  */
2692
3720
  export function fromBrand<A extends Brand.Brand<any>>(identifier: string, ctor: Brand.Constructor<A>) {
@@ -2698,6 +3726,12 @@ export function fromBrand<A extends Brand.Brand<any>>(identifier: string, ctor:
2698
3726
  }
2699
3727
 
2700
3728
  /**
3729
+ * A schema that wraps another schema and intercepts its decoding pipeline.
3730
+ *
3731
+ * The interceptor receives the full decoding `Effect` and may replace, modify,
3732
+ * or augment it — including adding service requirements via `RD`.
3733
+ *
3734
+ * @see {@link middlewareDecoding} for the constructor
2701
3735
  * @since 4.0.0
2702
3736
  */
2703
3737
  export interface middlewareDecoding<S extends Top, RD> extends
@@ -2724,6 +3758,25 @@ export interface middlewareDecoding<S extends Top, RD> extends
2724
3758
  }
2725
3759
 
2726
3760
  /**
3761
+ * Intercepts the decoding pipeline of a schema.
3762
+ *
3763
+ * The provided function receives the current decoding `Effect` and `ParseOptions`,
3764
+ * and returns a new `Effect` — potentially adding service requirements (`RD`),
3765
+ * recovering from errors, or augmenting the result.
3766
+ *
3767
+ * **Example** (Logging decode failures)
3768
+ *
3769
+ * ```ts
3770
+ * import { Effect, Schema } from "effect"
3771
+ *
3772
+ * const Logged = Schema.String.pipe(
3773
+ * Schema.middlewareDecoding((effect) =>
3774
+ * Effect.tapError(effect, (issue) => Effect.log("decode failed", issue))
3775
+ * )
3776
+ * )
3777
+ * ```
3778
+ *
3779
+ * @see {@link catchDecoding} for a simpler error-recovery variant
2727
3780
  * @since 4.0.0
2728
3781
  */
2729
3782
  export function middlewareDecoding<S extends Top, RD>(
@@ -2740,6 +3793,12 @@ export function middlewareDecoding<S extends Top, RD>(
2740
3793
  }
2741
3794
 
2742
3795
  /**
3796
+ * A schema that wraps another schema and intercepts its encoding pipeline.
3797
+ *
3798
+ * The interceptor receives the full encoding `Effect` and may replace, modify,
3799
+ * or augment it — including adding service requirements via `RE`.
3800
+ *
3801
+ * @see {@link middlewareEncoding} for the constructor
2743
3802
  * @since 4.0.0
2744
3803
  */
2745
3804
  export interface middlewareEncoding<S extends Top, RE> extends
@@ -2766,6 +3825,25 @@ export interface middlewareEncoding<S extends Top, RE> extends
2766
3825
  }
2767
3826
 
2768
3827
  /**
3828
+ * Intercepts the encoding pipeline of a schema.
3829
+ *
3830
+ * The provided function receives the current encoding `Effect` and `ParseOptions`,
3831
+ * and returns a new `Effect` — potentially adding service requirements (`RE`),
3832
+ * recovering from errors, or augmenting the result.
3833
+ *
3834
+ * **Example** (Logging encode failures)
3835
+ *
3836
+ * ```ts
3837
+ * import { Effect, Schema } from "effect"
3838
+ *
3839
+ * const Logged = Schema.String.pipe(
3840
+ * Schema.middlewareEncoding((effect) =>
3841
+ * Effect.tapError(effect, (issue) => Effect.log("encode failed", issue))
3842
+ * )
3843
+ * )
3844
+ * ```
3845
+ *
3846
+ * @see {@link catchEncoding} for a simpler error-recovery variant
2769
3847
  * @since 4.0.0
2770
3848
  */
2771
3849
  export function middlewareEncoding<S extends Top, RE>(
@@ -2782,6 +3860,22 @@ export function middlewareEncoding<S extends Top, RE>(
2782
3860
  }
2783
3861
 
2784
3862
  /**
3863
+ * Recovers from a decoding error by providing a fallback value.
3864
+ *
3865
+ * The handler receives the `Issue` and returns an `Effect` that either
3866
+ * succeeds with a fallback value or re-fails with a (possibly different) issue.
3867
+ *
3868
+ * **Example** (Returning a default on decode failure)
3869
+ *
3870
+ * ```ts
3871
+ * import { Effect, Option, Schema } from "effect"
3872
+ *
3873
+ * const schema = Schema.Number.pipe(
3874
+ * Schema.catchDecoding((_issue) => Effect.succeed(Option.some(0)))
3875
+ * )
3876
+ * ```
3877
+ *
3878
+ * @see {@link catchDecodingWithContext} to add service requirements to the handler
2785
3879
  * @since 4.0.0
2786
3880
  */
2787
3881
  export function catchDecoding<S extends Top>(
@@ -2791,6 +3885,8 @@ export function catchDecoding<S extends Top>(
2791
3885
  }
2792
3886
 
2793
3887
  /**
3888
+ * Like {@link catchDecoding}, but the handler may require Effect services (`R`).
3889
+ *
2794
3890
  * @since 4.0.0
2795
3891
  */
2796
3892
  export function catchDecodingWithContext<S extends Top, R = never>(
@@ -2801,6 +3897,12 @@ export function catchDecodingWithContext<S extends Top, R = never>(
2801
3897
  }
2802
3898
 
2803
3899
  /**
3900
+ * Recovers from an encoding error by providing a fallback value.
3901
+ *
3902
+ * The handler receives the `Issue` and returns an `Effect` that either
3903
+ * succeeds with a fallback value or re-fails with a (possibly different) issue.
3904
+ *
3905
+ * @see {@link catchEncodingWithContext} to add service requirements to the handler
2804
3906
  * @since 4.0.0
2805
3907
  */
2806
3908
  export function catchEncoding<S extends Top>(
@@ -2810,6 +3912,8 @@ export function catchEncoding<S extends Top>(
2810
3912
  }
2811
3913
 
2812
3914
  /**
3915
+ * Like {@link catchEncoding}, but the handler may require Effect services (`R`).
3916
+ *
2813
3917
  * @since 4.0.0
2814
3918
  */
2815
3919
  export function catchEncodingWithContext<S extends Top, R = never>(
@@ -2820,6 +3924,12 @@ export function catchEncodingWithContext<S extends Top, R = never>(
2820
3924
  }
2821
3925
 
2822
3926
  /**
3927
+ * The type produced by {@link decodeTo} when a custom transformation is provided.
3928
+ *
3929
+ * - `Type` is `To["Type"]`, `Encoded` is `From["Encoded"]`
3930
+ * - Decoding services from both `from` and `to` are combined
3931
+ *
3932
+ * @see {@link compose} for the passthrough (no transformation) variant
2823
3933
  * @since 4.0.0
2824
3934
  */
2825
3935
  export interface decodeTo<To extends Top, From extends Top, RD = never, RE = never> extends
@@ -2847,6 +3957,12 @@ export interface decodeTo<To extends Top, From extends Top, RD = never, RE = nev
2847
3957
  }
2848
3958
 
2849
3959
  /**
3960
+ * The type produced by {@link decodeTo} when called without a custom transformation (passthrough composition).
3961
+ *
3962
+ * Equivalent to {@link decodeTo} with `RD = never` and `RE = never`, meaning the schemas
3963
+ * are composed using their natural encoding/decoding chain.
3964
+ *
3965
+ * @see {@link decodeTo} for the transformation variant
2850
3966
  * @since 4.0.0
2851
3967
  */
2852
3968
  export interface compose<To extends Top, From extends Top> extends decodeTo<To, From> {}
@@ -2970,6 +4086,25 @@ export function decode<S extends Top, RD = never, RE = never>(transformation: {
2970
4086
  }
2971
4087
 
2972
4088
  /**
4089
+ * Like {@link decodeTo} but reverses the direction: the `from` schema acts as the target (decoded type)
4090
+ * and `to` acts as the encoded source.
4091
+ *
4092
+ * `encodeTo(to)(from)` is equivalent to `to.pipe(decodeTo(from))` — useful when it reads more
4093
+ * naturally to specify the encoded schema first.
4094
+ *
4095
+ * **Example** (Encode a number back to string)
4096
+ *
4097
+ * ```ts
4098
+ * import { Schema, SchemaGetter } from "effect"
4099
+ *
4100
+ * const NumberFromString = Schema.Number.pipe(
4101
+ * Schema.encodeTo(Schema.String, {
4102
+ * decode: SchemaGetter.transform((s: string) => Number(s)),
4103
+ * encode: SchemaGetter.transform((n: number) => String(n))
4104
+ * })
4105
+ * )
4106
+ * ```
4107
+ *
2973
4108
  * @since 4.0.0
2974
4109
  */
2975
4110
  export function encodeTo<To extends Top>(
@@ -2997,6 +4132,25 @@ export function encodeTo<To extends Top, From extends Top, RD = never, RE = neve
2997
4132
  }
2998
4133
 
2999
4134
  /**
4135
+ * Applies a transformation to a schema's encoded type, creating a new schema where encoding/decoding
4136
+ * operate on `S["Encoded"]` rather than `S["Type"]`.
4137
+ *
4138
+ * The `decode` getter maps `S["Encoded"]` → `S["Encoded"]` (applied during decoding),
4139
+ * and the `encode` getter maps `S["Encoded"]` → `S["Encoded"]` (applied during encoding).
4140
+ *
4141
+ * **Example** (Upper-casing encoded strings)
4142
+ *
4143
+ * ```ts
4144
+ * import { Schema, SchemaGetter } from "effect"
4145
+ *
4146
+ * const UpperFromLower = Schema.String.pipe(
4147
+ * Schema.encode({
4148
+ * decode: SchemaGetter.transform((s: string) => s.toLowerCase()),
4149
+ * encode: SchemaGetter.transform((s: string) => s.toUpperCase())
4150
+ * })
4151
+ * )
4152
+ * ```
4153
+ *
3000
4154
  * @since 4.0.0
3001
4155
  */
3002
4156
  export function encode<S extends Top, RD = never, RE = never>(transformation: {
@@ -3009,6 +4163,10 @@ export function encode<S extends Top, RD = never, RE = never>(transformation: {
3009
4163
  }
3010
4164
 
3011
4165
  /**
4166
+ * Constraint used to ensure a schema field does not already have a constructor default.
4167
+ *
4168
+ * Only schemas that satisfy this constraint can be passed to {@link withConstructorDefault}.
4169
+ *
3012
4170
  * @since 4.0.0
3013
4171
  */
3014
4172
  export interface WithoutConstructorDefault {
@@ -3016,6 +4174,9 @@ export interface WithoutConstructorDefault {
3016
4174
  }
3017
4175
 
3018
4176
  /**
4177
+ * The type produced by {@link withConstructorDefault} — a schema with `"~type.constructor.default": "with-default"`.
4178
+ *
4179
+ * @see {@link withConstructorDefault} for the constructor
3019
4180
  * @since 4.0.0
3020
4181
  */
3021
4182
  export interface withConstructorDefault<S extends Top & WithoutConstructorDefault> extends
@@ -3042,6 +4203,32 @@ export interface withConstructorDefault<S extends Top & WithoutConstructorDefaul
3042
4203
  }
3043
4204
 
3044
4205
  /**
4206
+ * Attaches a constructor default value to a schema field.
4207
+ *
4208
+ * The `defaultValue` function receives `Option.some(undefined)` when the field is
4209
+ * explicitly set to `undefined`, or `Option.none()` when the field is absent.
4210
+ * Return `Option.some(value)` to supply a default, or `Option.none()` to leave the
4211
+ * field required. An `Effect` may be returned for async or service-dependent defaults.
4212
+ *
4213
+ * Constructor defaults are applied only during `makeUnsafe` / `make`, not during
4214
+ * decoding or encoding.
4215
+ *
4216
+ * **Example** (Optional field with a static default)
4217
+ *
4218
+ * ```ts
4219
+ * import { Option, Schema } from "effect"
4220
+ *
4221
+ * const MySchema = Schema.Struct({
4222
+ * name: Schema.String.pipe(
4223
+ * Schema.optionalKey,
4224
+ * Schema.withConstructorDefault(() => Option.some("anonymous"))
4225
+ * )
4226
+ * })
4227
+ *
4228
+ * const value = MySchema.makeUnsafe({})
4229
+ * // value: { name: "anonymous" }
4230
+ * ```
4231
+ *
3045
4232
  * @since 4.0.0
3046
4233
  */
3047
4234
  export function withConstructorDefault<S extends Top & WithoutConstructorDefault>(
@@ -3060,11 +4247,20 @@ export function withConstructorDefault<S extends Top & WithoutConstructorDefault
3060
4247
  }
3061
4248
 
3062
4249
  /**
4250
+ * The type produced by {@link withDecodingDefaultKey} — a schema that decodes from an `optionalKey` encoded source.
4251
+ *
4252
+ * @see {@link withDecodingDefaultKey} for the constructor
3063
4253
  * @since 4.0.0
3064
4254
  */
3065
4255
  export interface withDecodingDefaultKey<S extends Top> extends decodeTo<S, optionalKey<toEncoded<S>>> {}
3066
4256
 
3067
4257
  /**
4258
+ * Options for {@link withDecodingDefaultKey} and {@link withDecodingDefault}.
4259
+ *
4260
+ * - `encodingStrategy`:
4261
+ * - `"passthrough"` (default): pass the value through during encoding
4262
+ * - `"omit"`: omit the key from the encoded output
4263
+ *
3068
4264
  * @since 4.0.0
3069
4265
  */
3070
4266
  export type DecodingDefaultOptions = {
@@ -3078,6 +4274,27 @@ export type DecodingDefaultOptions = {
3078
4274
  * - `passthrough`: (default) Pass the default value through to the output.
3079
4275
  * - `omit`: Omit the value from the output.
3080
4276
  *
4277
+ * Provides a default value for a missing key during decoding.
4278
+ *
4279
+ * When the key is absent from the input, `defaultValue()` is called to supply a value.
4280
+ * During encoding, the behavior is controlled by `options.encodingStrategy`:
4281
+ * - `"passthrough"` (default): include the value in the output
4282
+ * - `"omit"`: omit the key from the output
4283
+ *
4284
+ * **Example** (Default for a missing struct key)
4285
+ *
4286
+ * ```ts
4287
+ * import { Schema } from "effect"
4288
+ *
4289
+ * const MySchema = Schema.Struct({
4290
+ * name: Schema.String.pipe(Schema.withDecodingDefaultKey(() => "anonymous"))
4291
+ * })
4292
+ *
4293
+ * const result = Schema.decodeUnknownSync(MySchema)({})
4294
+ * // result: { name: "anonymous" }
4295
+ * ```
4296
+ *
4297
+ * @see {@link withDecodingDefault} for the `optional` (value-level) variant
3081
4298
  * @since 4.0.0
3082
4299
  */
3083
4300
  export function withDecodingDefaultKey<S extends Top>(
@@ -3094,6 +4311,9 @@ export function withDecodingDefaultKey<S extends Top>(
3094
4311
  }
3095
4312
 
3096
4313
  /**
4314
+ * The type produced by {@link withDecodingDefault} — a schema that decodes from an `optional` encoded source.
4315
+ *
4316
+ * @see {@link withDecodingDefault} for the constructor
3097
4317
  * @since 4.0.0
3098
4318
  */
3099
4319
  export interface withDecodingDefault<S extends Top> extends decodeTo<S, optional<toEncoded<S>>> {}
@@ -3105,6 +4325,30 @@ export interface withDecodingDefault<S extends Top> extends decodeTo<S, optional
3105
4325
  * - `passthrough`: (default) Pass the default value through to the output.
3106
4326
  * - `omit`: Omit the value from the output.
3107
4327
  *
4328
+ * Provides a default value for an `optional` field during decoding.
4329
+ *
4330
+ * Similar to {@link withDecodingDefaultKey} but works on `optional` (value-level optional)
4331
+ * rather than `optionalKey` (key-level optional).
4332
+ *
4333
+ * When the value is `undefined` or absent, `defaultValue()` is called to supply a value.
4334
+ * During encoding, the behavior is controlled by `options.encodingStrategy`:
4335
+ * - `"passthrough"` (default): include the value in the output
4336
+ * - `"omit"`: omit the value from the output
4337
+ *
4338
+ * **Example** (Default for an optional field value)
4339
+ *
4340
+ * ```ts
4341
+ * import { Schema } from "effect"
4342
+ *
4343
+ * const MySchema = Schema.Struct({
4344
+ * name: Schema.String.pipe(Schema.optional, Schema.withDecodingDefault(() => "anonymous"))
4345
+ * })
4346
+ *
4347
+ * const result = Schema.decodeUnknownSync(MySchema)({ name: undefined })
4348
+ * // result: { name: "anonymous" }
4349
+ * ```
4350
+ *
4351
+ * @see {@link withDecodingDefaultKey} for the key-level variant
3108
4352
  * @since 4.0.0
3109
4353
  */
3110
4354
  export function withDecodingDefault<S extends Top>(
@@ -3121,19 +4365,34 @@ export function withDecodingDefault<S extends Top>(
3121
4365
  }
3122
4366
 
3123
4367
  /**
4368
+ * The type produced by {@link tag} — a literal schema with a constructor default.
4369
+ *
4370
+ * Used as the type of the `_tag` field in {@link TaggedStruct} and related helpers.
4371
+ *
4372
+ * @see {@link tag} for the constructor
3124
4373
  * @since 4.0.0
3125
4374
  */
3126
4375
  export interface tag<Tag extends AST.LiteralValue> extends withConstructorDefault<Literal<Tag>> {}
3127
4376
 
3128
4377
  /**
3129
- * Creates a schema for a literal value and automatically provides itself as a
3130
- * default.
4378
+ * Combines a {@link Literal} schema with {@link withConstructorDefault}, making it ideal
4379
+ * for discriminator fields in tagged unions. When constructing via `makeUnsafe`, the
4380
+ * `_tag` field can be omitted and will be filled automatically.
3131
4381
  *
3132
- * The `tag` function combines a literal schema with a constructor default,
3133
- * making it perfect for discriminated unions and tagged data structures. The
3134
- * tag value is automatically provided when the field is missing during
3135
- * construction.
4382
+ * **Example** (Discriminated union tag)
3136
4383
  *
4384
+ * ```ts
4385
+ * import { Schema } from "effect"
4386
+ *
4387
+ * const A = Schema.Struct({ _tag: Schema.tag("A"), value: Schema.Number })
4388
+ *
4389
+ * // _tag is optional in makeUnsafe, auto-filled to "A"
4390
+ * const a = A.makeUnsafe({ value: 42 })
4391
+ * // a: { _tag: "A", value: 42 }
4392
+ * ```
4393
+ *
4394
+ * @see {@link tagDefaultOmit} to also omit the tag during encoding
4395
+ * @see {@link TaggedStruct} for a shorthand that adds `_tag` automatically
3137
4396
  * @since 4.0.0
3138
4397
  */
3139
4398
  export function tag<Tag extends AST.LiteralValue>(literal: Tag): tag<Tag> {
@@ -3141,9 +4400,26 @@ export function tag<Tag extends AST.LiteralValue>(literal: Tag): tag<Tag> {
3141
4400
  }
3142
4401
 
3143
4402
  /**
3144
- * Similar to `tag`, but provides itself as a default when decoding and omits
3145
- * the value from the output when encoding.
4403
+ * Like {@link tag}, but additionally omits the tag field from the encoded output.
4404
+ * Useful when the encoded form (e.g. JSON) does not include the discriminator key,
4405
+ * but the decoded type and constructor still need it.
4406
+ *
4407
+ * **Example** (Tag omitted during encoding)
4408
+ *
4409
+ * ```ts
4410
+ * import { Schema } from "effect"
4411
+ *
4412
+ * const A = Schema.Struct({
4413
+ * _tag: Schema.tagDefaultOmit("A"),
4414
+ * value: Schema.Number
4415
+ * })
3146
4416
  *
4417
+ * // Encode strips the _tag field
4418
+ * const encoded = Schema.encodeUnknownSync(A)({ _tag: "A", value: 1 })
4419
+ * // encoded: { value: 1 }
4420
+ * ```
4421
+ *
4422
+ * @see {@link tag} for the variant that keeps the tag during encoding
3147
4423
  * @since 4.0.0
3148
4424
  */
3149
4425
  export function tagDefaultOmit<Tag extends AST.LiteralValue>(literal: Tag) {
@@ -3151,6 +4427,9 @@ export function tagDefaultOmit<Tag extends AST.LiteralValue>(literal: Tag) {
3151
4427
  }
3152
4428
 
3153
4429
  /**
4430
+ * The type produced by {@link TaggedStruct} — a {@link Struct} with an extra `_tag` field of type {@link tag}.
4431
+ *
4432
+ * @see {@link TaggedStruct} for the constructor
3154
4433
  * @since 4.0.0
3155
4434
  */
3156
4435
  export type TaggedStruct<Tag extends AST.LiteralValue, Fields extends Struct.Fields> = Struct<
@@ -3244,6 +4523,9 @@ type TaggedUnionUtils<
3244
4523
  }
3245
4524
 
3246
4525
  /**
4526
+ * The type produced by {@link toTaggedUnion} — a {@link Union} augmented with `cases`, `guards`, `isAnyOf`, and `match` utilities.
4527
+ *
4528
+ * @see {@link toTaggedUnion} for the constructor
3247
4529
  * @since 4.0.0
3248
4530
  * @experimental
3249
4531
  */
@@ -3253,6 +4535,26 @@ export type toTaggedUnion<
3253
4535
  > = Union<Members> & TaggedUnionUtils<Tag, Members>
3254
4536
 
3255
4537
  /**
4538
+ * Augments an existing {@link Union} of tagged structs with utility methods keyed by the discriminant field.
4539
+ *
4540
+ * **Example** (Adding tagged-union utilities to an existing union)
4541
+ *
4542
+ * ```ts
4543
+ * import { Schema } from "effect"
4544
+ *
4545
+ * const A = Schema.TaggedStruct("A", { value: Schema.Number })
4546
+ * const B = Schema.TaggedStruct("B", { name: Schema.String })
4547
+ *
4548
+ * const MyUnion = Schema.Union([A, B]).pipe(Schema.toTaggedUnion("_tag"))
4549
+ *
4550
+ * // Pattern-match on the union
4551
+ * const result = MyUnion.match({ _tag: "A", value: 1 }, {
4552
+ * A: (a) => `number: ${a.value}`,
4553
+ * B: (b) => `name: ${b.name}`
4554
+ * })
4555
+ * ```
4556
+ *
4557
+ * @see {@link TaggedUnion} for a shorthand that builds the union from scratch
3256
4558
  * @since 4.0.0
3257
4559
  * @experimental
3258
4560
  */
@@ -3306,6 +4608,10 @@ export function toTaggedUnion<const Tag extends PropertyKey>(tag: Tag) {
3306
4608
  }
3307
4609
 
3308
4610
  /**
4611
+ * A union schema that exposes `cases`, `guards`, `isAnyOf`, and `match` utilities keyed by the `_tag` discriminant.
4612
+ * Produced by {@link TaggedUnion}.
4613
+ *
4614
+ * @see {@link TaggedUnion} for the constructor
3309
4615
  * @since 4.0.0
3310
4616
  * @experimental
3311
4617
  */
@@ -3338,6 +4644,28 @@ export interface TaggedUnion<Cases extends Record<string, Top>> extends
3338
4644
  }
3339
4645
 
3340
4646
  /**
4647
+ * Builds a discriminated union from a record of field sets, one per variant.
4648
+ * Each key becomes the `_tag` literal and the value is passed to {@link TaggedStruct}.
4649
+ * The result includes `cases`, `guards`, `isAnyOf`, and `match` utilities.
4650
+ *
4651
+ * **Example** (Discriminated union with pattern matching)
4652
+ *
4653
+ * ```ts
4654
+ * import { Schema } from "effect"
4655
+ *
4656
+ * const Shape = Schema.TaggedUnion({
4657
+ * Circle: { radius: Schema.Number },
4658
+ * Rectangle: { width: Schema.Number, height: Schema.Number }
4659
+ * })
4660
+ *
4661
+ * // Pattern-match on a decoded value
4662
+ * const area = Shape.match({ _tag: "Circle", radius: 5 }, {
4663
+ * Circle: (c) => Math.PI * c.radius ** 2,
4664
+ * Rectangle: (r) => r.width * r.height
4665
+ * })
4666
+ * ```
4667
+ *
4668
+ * @see {@link toTaggedUnion} to augment an existing union instead
3341
4669
  * @category Constructors
3342
4670
  * @since 4.0.0
3343
4671
  */
@@ -3355,6 +4683,11 @@ export function TaggedUnion<const CasesByTag extends Record<string, Struct.Field
3355
4683
  }
3356
4684
 
3357
4685
  /**
4686
+ * The interface type for schemas created by {@link Opaque}.
4687
+ * Carries the same encoded/decoded shape as `S` but replaces `Type` with `Self & Brand`,
4688
+ * making the decoded value nominally distinct.
4689
+ *
4690
+ * @see {@link Opaque} for the constructor
3358
4691
  * @since 4.0.0
3359
4692
  */
3360
4693
  export interface Opaque<Self, S extends Top, Brand> extends
@@ -3381,6 +4714,23 @@ export interface Opaque<Self, S extends Top, Brand> extends
3381
4714
  }
3382
4715
 
3383
4716
  /**
4717
+ * Wraps a schema so that its decoded `Type` becomes a nominally distinct type `Self`.
4718
+ * Useful for creating opaque types that are structurally identical to a base schema
4719
+ * but type-incompatible with it.
4720
+ *
4721
+ * **Example** (Opaque user ID)
4722
+ *
4723
+ * ```ts
4724
+ * import { Schema } from "effect"
4725
+ *
4726
+ * type UserId = string & { readonly _tag: "UserId" }
4727
+ * const UserId = Schema.Opaque<UserId>()(Schema.String)
4728
+ *
4729
+ * // Decoded value is UserId, not plain string
4730
+ * const id = Schema.decodeUnknownSync(UserId)("abc")
4731
+ * // id: UserId
4732
+ * ```
4733
+ *
3384
4734
  * @since 4.0.0
3385
4735
  */
3386
4736
  export function Opaque<Self, Brand = {}>() {
@@ -3393,6 +4743,9 @@ export function Opaque<Self, Brand = {}>() {
3393
4743
  }
3394
4744
 
3395
4745
  /**
4746
+ * The type produced by {@link instanceOf} — a declaration schema that validates class instances.
4747
+ *
4748
+ * @see {@link instanceOf} for the constructor
3396
4749
  * @since 4.0.0
3397
4750
  */
3398
4751
  export interface instanceOf<T, Iso = T> extends declare<T, Iso> {
@@ -3400,7 +4753,19 @@ export interface instanceOf<T, Iso = T> extends declare<T, Iso> {
3400
4753
  }
3401
4754
 
3402
4755
  /**
3403
- * Creates a schema that validates an instance of a specific class constructor.
4756
+ * Creates a schema that validates values using `instanceof`.
4757
+ * Decoding and encoding pass the value through unchanged.
4758
+ *
4759
+ * **Example** (Schema for a built-in class)
4760
+ *
4761
+ * ```ts
4762
+ * import { Schema } from "effect"
4763
+ *
4764
+ * const DateSchema = Schema.instanceOf(Date)
4765
+ *
4766
+ * const decoded = Schema.decodeUnknownSync(DateSchema)(new Date("2024-01-01"))
4767
+ * // decoded: Date
4768
+ * ```
3404
4769
  *
3405
4770
  * @category Constructors
3406
4771
  * @since 4.0.0
@@ -3413,6 +4778,9 @@ export function instanceOf<C extends abstract new(...args: any) => any, Iso = In
3413
4778
  }
3414
4779
 
3415
4780
  /**
4781
+ * Constructs an `AST.Link` that describes how a value of type `T` encodes to and decodes from a `To` schema.
4782
+ * Used when building low-level AST transformations that bridge two schema types.
4783
+ *
3416
4784
  * @since 4.0.0
3417
4785
  * @experimental
3418
4786
  */
@@ -3433,6 +4801,22 @@ export function link<T>() { // TODO: better name
3433
4801
  // -----------------------------------------------------------------------------
3434
4802
 
3435
4803
  /**
4804
+ * Creates a custom filter check from a predicate function. The predicate
4805
+ * receives the input value, the schema's AST, and parse options, and returns
4806
+ * `true`/`undefined` on success or a failure description on error.
4807
+ *
4808
+ * **Example** (Custom filter check)
4809
+ * ```ts
4810
+ * import { Schema } from "effect"
4811
+ *
4812
+ * // Check that a number is even
4813
+ * const isEven = Schema.makeFilter(
4814
+ * (n: number) => n % 2 === 0 || "expected an even number"
4815
+ * )
4816
+ *
4817
+ * const EvenNumber = Schema.Number.check(isEven)
4818
+ * ```
4819
+ *
3436
4820
  * @category Checks Constructors
3437
4821
  * @since 4.0.0
3438
4822
  */
@@ -3446,6 +4830,9 @@ export const makeFilter: <T>(
3446
4830
  ) => AST.Filter<T> = AST.makeFilter
3447
4831
 
3448
4832
  /**
4833
+ * Groups multiple checks into a single {@link AST.FilterGroup}, applying
4834
+ * optional shared annotations to the group as a whole.
4835
+ *
3449
4836
  * @category Checks Constructors
3450
4837
  * @since 4.0.0
3451
4838
  */
@@ -4002,6 +5389,9 @@ export function isFinite(annotations?: Annotations.Filter) {
4002
5389
  }
4003
5390
 
4004
5391
  /**
5392
+ * Generic factory for creating a "greater than" (`>`) check for any ordered
5393
+ * type by supplying an {@link Order.Order} instance.
5394
+ *
4005
5395
  * @category Order checks
4006
5396
  * @since 4.0.0
4007
5397
  */
@@ -4025,6 +5415,9 @@ export function makeIsGreaterThan<T>(options: {
4025
5415
  }
4026
5416
 
4027
5417
  /**
5418
+ * Generic factory for creating a ">=" check for any ordered type by supplying
5419
+ * an {@link Order.Order} instance.
5420
+ *
4028
5421
  * @category Order checks
4029
5422
  * @since 4.0.0
4030
5423
  */
@@ -4048,6 +5441,9 @@ export function makeIsGreaterThanOrEqualTo<T>(options: {
4048
5441
  }
4049
5442
 
4050
5443
  /**
5444
+ * Generic factory for creating a "<" check for any ordered type by supplying
5445
+ * an {@link Order.Order} instance.
5446
+ *
4051
5447
  * @category Order checks
4052
5448
  * @since 4.0.0
4053
5449
  */
@@ -4071,6 +5467,9 @@ export function makeIsLessThan<T>(options: {
4071
5467
  }
4072
5468
 
4073
5469
  /**
5470
+ * Generic factory for creating a "<=" check for any ordered type by supplying
5471
+ * an {@link Order.Order} instance.
5472
+ *
4074
5473
  * @category Order checks
4075
5474
  * @since 4.0.0
4076
5475
  */
@@ -4094,6 +5493,9 @@ export function makeIsLessThanOrEqualTo<T>(options: {
4094
5493
  }
4095
5494
 
4096
5495
  /**
5496
+ * Generic factory for creating an inclusive/exclusive range check for any
5497
+ * ordered type by supplying an {@link Order.Order} instance.
5498
+ *
4097
5499
  * @category Order checks
4098
5500
  * @since 4.0.0
4099
5501
  */
@@ -4136,6 +5538,9 @@ export function makeIsBetween<T>(deriveOptions: {
4136
5538
  }
4137
5539
 
4138
5540
  /**
5541
+ * Generic factory for creating a divisibility check for any numeric type by
5542
+ * supplying a remainder function and a zero value.
5543
+ *
4139
5544
  * @category Numeric checks
4140
5545
  * @since 4.0.0
4141
5546
  */
@@ -4846,6 +6251,14 @@ export const isBetweenBigDecimal = makeIsBetween({
4846
6251
  * constraint to ensure generated strings or arrays have at least the required
4847
6252
  * length.
4848
6253
  *
6254
+ * **Example** (Minimum length check)
6255
+ * ```ts
6256
+ * import { Schema } from "effect"
6257
+ *
6258
+ * const NonEmptyStringSchema = Schema.String.check(Schema.isMinLength(1))
6259
+ * const NonEmptyArraySchema = Schema.Array(Schema.Number).check(Schema.isMinLength(1))
6260
+ * ```
6261
+ *
4849
6262
  * @category Length checks
4850
6263
  * @since 4.0.0
4851
6264
  */
@@ -5285,6 +6698,7 @@ export function isPropertyNames(keySchema: Top, annotations?: Annotations.Filter
5285
6698
  * constraint using the provided equivalence function to ensure generated arrays
5286
6699
  * contain only unique items.
5287
6700
  *
6701
+ * @category Array checks
5288
6702
  * @since 4.0.0
5289
6703
  */
5290
6704
  export function isUnique<T>(annotations?: Annotations.Filter) {
@@ -5326,6 +6740,23 @@ export const NonEmptyString = String.check(isNonEmpty())
5326
6740
  export const Char = String.check(isLengthBetween(1, 1))
5327
6741
 
5328
6742
  /**
6743
+ * Schema for the `Option<A>` type, representing an optional value that is
6744
+ * either `None` or `Some<A>`.
6745
+ *
6746
+ * **Example** (Option schema)
6747
+ *
6748
+ * ```ts
6749
+ * import { Schema } from "effect"
6750
+ * import { Option } from "effect"
6751
+ *
6752
+ * const schema = Schema.Option(Schema.Number)
6753
+ *
6754
+ * Schema.decodeUnknownSync(schema)(Option.some(1))
6755
+ * // => Some(1)
6756
+ * Schema.decodeUnknownSync(schema)(Option.none())
6757
+ * // => None
6758
+ * ```
6759
+ *
5329
6760
  * @category Option
5330
6761
  * @since 4.0.0
5331
6762
  */
@@ -5349,6 +6780,8 @@ export type OptionIso<A extends Top> =
5349
6780
  | { readonly _tag: "Some"; readonly value: A["Iso"] }
5350
6781
 
5351
6782
  /**
6783
+ * Creates a schema for `Option<A>`. See {@link Option} for details.
6784
+ *
5352
6785
  * @category Option
5353
6786
  * @since 4.0.0
5354
6787
  */
@@ -5414,6 +6847,9 @@ export function Option<A extends Top>(value: A): Option<A> {
5414
6847
  }
5415
6848
 
5416
6849
  /**
6850
+ * Schema type for {@link OptionFromNullOr}.
6851
+ *
6852
+ * @category Option
5417
6853
  * @since 4.0.0
5418
6854
  */
5419
6855
  export interface OptionFromNullOr<S extends Top> extends decodeTo<Option<toType<S>>, NullOr<S>> {}
@@ -5440,6 +6876,9 @@ export function OptionFromNullOr<S extends Top>(schema: S): OptionFromNullOr<S>
5440
6876
  }
5441
6877
 
5442
6878
  /**
6879
+ * Schema type for {@link OptionFromUndefinedOr}.
6880
+ *
6881
+ * @category Option
5443
6882
  * @since 4.0.0
5444
6883
  */
5445
6884
  export interface OptionFromUndefinedOr<S extends Top> extends decodeTo<Option<toType<S>>, UndefinedOr<S>> {}
@@ -5466,6 +6905,9 @@ export function OptionFromUndefinedOr<S extends Top>(schema: S): OptionFromUndef
5466
6905
  }
5467
6906
 
5468
6907
  /**
6908
+ * Schema type for {@link OptionFromNullishOr}.
6909
+ *
6910
+ * @category Option
5469
6911
  * @since 4.0.0
5470
6912
  */
5471
6913
  export interface OptionFromNullishOr<S extends Top> extends decodeTo<Option<toType<S>>, NullishOr<S>> {}
@@ -5497,6 +6939,9 @@ export function OptionFromNullishOr<S extends Top>(
5497
6939
  }
5498
6940
 
5499
6941
  /**
6942
+ * Schema type for {@link OptionFromOptionalKey}.
6943
+ *
6944
+ * @category Option
5500
6945
  * @since 4.0.0
5501
6946
  */
5502
6947
  export interface OptionFromOptionalKey<S extends Top> extends decodeTo<Option<toType<S>>, optionalKey<S>> {}
@@ -5523,6 +6968,9 @@ export function OptionFromOptionalKey<S extends Top>(schema: S): OptionFromOptio
5523
6968
  }
5524
6969
 
5525
6970
  /**
6971
+ * Schema type for {@link OptionFromOptional}.
6972
+ *
6973
+ * @category Option
5526
6974
  * @since 4.0.0
5527
6975
  */
5528
6976
  export interface OptionFromOptional<S extends Top> extends decodeTo<Option<toType<S>>, optional<S>> {}
@@ -5551,6 +6999,57 @@ export function OptionFromOptional<S extends Top>(schema: S): OptionFromOptional
5551
6999
  }
5552
7000
 
5553
7001
  /**
7002
+ * Schema type for {@link OptionFromOptionalNullOr}.
7003
+ *
7004
+ * @category Option
7005
+ * @since 4.0.0
7006
+ */
7007
+ export interface OptionFromOptionalNullOr<S extends Top> extends decodeTo<Option<toType<S>>, optional<NullOr<S>>> {}
7008
+
7009
+ /**
7010
+ * Decodes an optional or `null` or `undefined` value `A` to a required `Option<A>`
7011
+ * value.
7012
+ *
7013
+ * Decoding:
7014
+ * - a missing key is decoded as `None`
7015
+ * - a present key with an `undefined` value is decoded as `None`
7016
+ * - a present key with a `null` value is decoded as `None`
7017
+ * - all other values are decoded as `Some`
7018
+ *
7019
+ * Encoding (controlled by `options.onNoneEncoding`):
7020
+ * - `"omit"` (default): `None` is encoded as a missing key
7021
+ * - `null`: `None` is encoded as `null`
7022
+ * - `undefined`: `None` is encoded as `undefined`
7023
+ * - `Some` is always encoded as the value
7024
+ *
7025
+ * @category Option
7026
+ * @since 4.0.0
7027
+ */
7028
+ export function OptionFromOptionalNullOr<S extends Top>(
7029
+ schema: S,
7030
+ options?: {
7031
+ readonly onNoneEncoding: "omit" | null | undefined
7032
+ }
7033
+ ): OptionFromOptionalNullOr<S> {
7034
+ const onNoneEncoding = options === undefined ? "omit" : options.onNoneEncoding
7035
+ const noneValue = onNoneEncoding === null
7036
+ ? null as S["Type"] | null | undefined
7037
+ : undefined as S["Type"] | null | undefined
7038
+ return optional(NullOr(schema)).pipe(decodeTo(
7039
+ Option(toType(schema)),
7040
+ Transformation.transformOptional<Option_.Option<S["Type"]>, S["Type"] | null | undefined>({
7041
+ decode: (oe) => oe.pipe(Option_.filter(Predicate.isNotNullish), Option_.some),
7042
+ encode: onNoneEncoding === "omit"
7043
+ ? Option_.flatten
7044
+ : (ot) => Option_.some(Option_.getOrElse(Option_.flatten(ot), () => noneValue))
7045
+ })
7046
+ ))
7047
+ }
7048
+
7049
+ /**
7050
+ * Schema for the `Result<A, E>` type, representing a computation that either
7051
+ * succeeds with `A` or fails with `E`.
7052
+ *
5554
7053
  * @category Result
5555
7054
  * @since 4.0.0
5556
7055
  */
@@ -5575,6 +7074,8 @@ export type ResultIso<A extends Top, E extends Top> =
5575
7074
  | { readonly _tag: "Failure"; readonly failure: E["Iso"] }
5576
7075
 
5577
7076
  /**
7077
+ * Creates a schema for `Result<A, E>`. See {@link Result} for details.
7078
+ *
5578
7079
  * @category Result
5579
7080
  * @since 4.0.0
5580
7081
  */
@@ -5649,6 +7150,9 @@ export function Result<A extends Top, E extends Top>(
5649
7150
  }
5650
7151
 
5651
7152
  /**
7153
+ * Schema for the `Redacted<A>` type, providing secure handling of sensitive
7154
+ * values. The inner value is hidden from error messages.
7155
+ *
5652
7156
  * @category Redacted
5653
7157
  * @since 4.0.0
5654
7158
  */
@@ -5750,6 +7254,8 @@ export function Redacted<S extends Top>(value: S, options?: {
5750
7254
  }
5751
7255
 
5752
7256
  /**
7257
+ * Schema type for {@link RedactedFromValue}.
7258
+ *
5753
7259
  * @category Redacted
5754
7260
  * @since 4.0.0
5755
7261
  */
@@ -5758,6 +7264,9 @@ export interface RedactedFromValue<S extends Top>
5758
7264
  {}
5759
7265
 
5760
7266
  /**
7267
+ * Middleware that wraps decoded errors in `Redacted`, preventing sensitive
7268
+ * schema details from leaking in error messages.
7269
+ *
5761
7270
  * @category Redacted
5762
7271
  * @since 4.0.0
5763
7272
  */
@@ -5766,6 +7275,10 @@ export function redact<S extends Top>(schema: S): middlewareDecoding<S, S["Decod
5766
7275
  }
5767
7276
 
5768
7277
  /**
7278
+ * Decodes a value and wraps it in `Redacted<A>`. Unlike {@link Redacted} which
7279
+ * expects the input to already be a `Redacted` instance, this schema decodes
7280
+ * the raw value and wraps it.
7281
+ *
5769
7282
  * @category Redacted
5770
7283
  * @since 4.0.0
5771
7284
  */
@@ -5784,6 +7297,10 @@ export function RedactedFromValue<S extends Top>(value: S, options?: {
5784
7297
  }
5785
7298
 
5786
7299
  /**
7300
+ * Schema for a single `Cause.Reason<E>`, representing one reason a fiber may
7301
+ * fail: a typed error (`Fail`), an unexpected defect (`Die`), or an interrupt
7302
+ * (`Interrupt`).
7303
+ *
5787
7304
  * @category CauseReason
5788
7305
  * @since 4.0.0
5789
7306
  */
@@ -5815,6 +7332,8 @@ export type CauseReasonIso<E extends Top, D extends Top> = {
5815
7332
  }
5816
7333
 
5817
7334
  /**
7335
+ * Creates a schema for `Cause.Reason<E>`. See {@link CauseReason} for details.
7336
+ *
5818
7337
  * @category CauseReason
5819
7338
  * @since 4.0.0
5820
7339
  */
@@ -5926,6 +7445,9 @@ function causeReasonToFormatter<E>(error: Formatter<E>, defect: Formatter<unknow
5926
7445
  }
5927
7446
 
5928
7447
  /**
7448
+ * Schema for `Cause<E>`, an ordered collection of reasons a fiber failed,
7449
+ * combining typed errors, defects, and interrupts.
7450
+ *
5929
7451
  * @category Cause
5930
7452
  * @since 4.0.0
5931
7453
  */
@@ -5948,6 +7470,8 @@ export interface Cause<E extends Top, D extends Top> extends
5948
7470
  export type CauseIso<E extends Top, D extends Top> = ReadonlyArray<CauseReasonIso<E, D>>
5949
7471
 
5950
7472
  /**
7473
+ * Creates a schema for `Cause<E>`. See {@link Cause} for details.
7474
+ *
5951
7475
  * @category Cause
5952
7476
  * @since 4.0.0
5953
7477
  */
@@ -6009,6 +7533,9 @@ function causeToFormatter<E>(error: Formatter<E>, defect: Formatter<unknown>) {
6009
7533
  }
6010
7534
 
6011
7535
  /**
7536
+ * Schema type for {@link Error}.
7537
+ *
7538
+ * @category Schemas
6012
7539
  * @since 4.0.0
6013
7540
  */
6014
7541
  export interface Error extends instanceOf<globalThis.Error> {}
@@ -6070,6 +7597,9 @@ export const ErrorWithStack: Error = instanceOf(globalThis.Error, {
6070
7597
  })
6071
7598
 
6072
7599
  /**
7600
+ * Schema type for {@link Defect}.
7601
+ *
7602
+ * @category Schemas
6073
7603
  * @since 4.0.0
6074
7604
  */
6075
7605
  export interface Defect extends
@@ -6140,6 +7670,9 @@ export const DefectWithStack: Defect = Union([
6140
7670
  ])
6141
7671
 
6142
7672
  /**
7673
+ * Schema for `Exit<A, E>`, representing the result of a fiber execution —
7674
+ * either a success with value `A` or a failure with `Cause<E>`.
7675
+ *
6143
7676
  * @category Exit
6144
7677
  * @since 4.0.0
6145
7678
  */
@@ -6169,6 +7702,8 @@ export type ExitIso<A extends Top, E extends Top, D extends Top> = {
6169
7702
  }
6170
7703
 
6171
7704
  /**
7705
+ * Creates a schema for `Exit<A, E>`. See {@link Exit} for details.
7706
+ *
6172
7707
  * @category Exit
6173
7708
  * @since 4.0.0
6174
7709
  */
@@ -6267,6 +7802,8 @@ export function Exit<A extends Top, E extends Top, D extends Top>(value: A, erro
6267
7802
  }
6268
7803
 
6269
7804
  /**
7805
+ * Schema type for {@link ReadonlyMap}.
7806
+ *
6270
7807
  * @category ReadonlyMap
6271
7808
  * @since 4.0.0
6272
7809
  */
@@ -6357,6 +7894,9 @@ export function ReadonlyMap<Key extends Top, Value extends Top>(key: Key, value:
6357
7894
  }
6358
7895
 
6359
7896
  /**
7897
+ * Schema for an Effect `HashMap` where keys and values must conform to the
7898
+ * provided schemas.
7899
+ *
6360
7900
  * @category HashMap
6361
7901
  * @since 4.0.0
6362
7902
  */
@@ -6448,6 +7988,8 @@ export function HashMap<Key extends Top, Value extends Top>(key: Key, value: Val
6448
7988
  }
6449
7989
 
6450
7990
  /**
7991
+ * Schema type for {@link ReadonlySet}.
7992
+ *
6451
7993
  * @category ReadonlySet
6452
7994
  * @since 4.0.0
6453
7995
  */
@@ -6534,6 +8076,9 @@ export function ReadonlySet<Value extends Top>(value: Value): $ReadonlySet<Value
6534
8076
  }
6535
8077
 
6536
8078
  /**
8079
+ * Schema for an Effect `HashSet` where values must conform to the provided
8080
+ * schema.
8081
+ *
6537
8082
  * @category HashSet
6538
8083
  * @since 4.0.0
6539
8084
  */
@@ -6623,6 +8168,9 @@ export function HashSet<Value extends Top>(value: Value): HashSet<Value> {
6623
8168
  }
6624
8169
 
6625
8170
  /**
8171
+ * Schema for an Effect `Chunk` (immutable array-like collection) where values
8172
+ * must conform to the provided schema.
8173
+ *
6626
8174
  * @category Chunk
6627
8175
  * @since 4.0.0
6628
8176
  */
@@ -6712,11 +8260,19 @@ export function Chunk<Value extends Top>(value: Value): Chunk<Value> {
6712
8260
  }
6713
8261
 
6714
8262
  /**
8263
+ * Schema type for {@link RegExp}.
8264
+ *
8265
+ * @category Schemas
6715
8266
  * @since 4.0.0
6716
8267
  */
6717
8268
  export interface RegExp extends instanceOf<globalThis.RegExp> {}
6718
8269
 
6719
8270
  /**
8271
+ * Schema for JavaScript `RegExp` objects.
8272
+ *
8273
+ * The default JSON serializer encodes a `RegExp` as `{ source, flags }`.
8274
+ *
8275
+ * @category Schemas
6720
8276
  * @since 4.0.0
6721
8277
  */
6722
8278
  export const RegExp: RegExp = instanceOf(
@@ -6776,6 +8332,9 @@ export const RegExp: RegExp = instanceOf(
6776
8332
  )
6777
8333
 
6778
8334
  /**
8335
+ * Schema type for {@link URL}.
8336
+ *
8337
+ * @category URL
6779
8338
  * @since 4.0.0
6780
8339
  */
6781
8340
  export interface URL extends instanceOf<globalThis.URL> {}
@@ -6812,6 +8371,9 @@ export const URL: URL = instanceOf(
6812
8371
  )
6813
8372
 
6814
8373
  /**
8374
+ * Schema type for {@link URLFromString}.
8375
+ *
8376
+ * @category URL
6815
8377
  * @since 4.0.0
6816
8378
  */
6817
8379
  export interface URLFromString extends decodeTo<URL, String> {}
@@ -6832,6 +8394,9 @@ export const URLFromString: URLFromString = String.annotate({ expected: "a strin
6832
8394
  .pipe(decodeTo(URL, Transformation.urlFromString)) // TODO: remove duplication with URL schema
6833
8395
 
6834
8396
  /**
8397
+ * Schema type for {@link Date}.
8398
+ *
8399
+ * @category Schemas
6835
8400
  * @since 4.0.0
6836
8401
  */
6837
8402
  export interface Date extends instanceOf<globalThis.Date> {}
@@ -6840,8 +8405,19 @@ export interface Date extends instanceOf<globalThis.Date> {}
6840
8405
  * A schema for JavaScript `Date` objects.
6841
8406
  *
6842
8407
  * This schema accepts any `Date` instance, including invalid dates (e.g., `new
6843
- * Date("invalid")`). For validating only valid dates, use `ValidDate` instead.
8408
+ * Date("invalid")`). For validating only valid dates, use {@link DateValid}
8409
+ * instead. The default JSON serializer encodes `Date` as an ISO 8601 string.
8410
+ *
8411
+ * **Example** (Date schema)
8412
+ *
8413
+ * ```ts
8414
+ * import { Schema } from "effect"
8415
+ *
8416
+ * Schema.decodeUnknownSync(Schema.Date)(new Date("2024-01-01"))
8417
+ * // => Date { 2024-01-01T00:00:00.000Z }
8418
+ * ```
6844
8419
  *
8420
+ * @category Schemas
6845
8421
  * @since 4.0.0
6846
8422
  */
6847
8423
  export const Date: Date = instanceOf(
@@ -6868,6 +8444,9 @@ export const Date: Date = instanceOf(
6868
8444
  )
6869
8445
 
6870
8446
  /**
8447
+ * Schema type for {@link DateValid}.
8448
+ *
8449
+ * @category Schemas
6871
8450
  * @since 4.0.0
6872
8451
  */
6873
8452
  export interface DateValid extends Date {}
@@ -6883,6 +8462,9 @@ export interface DateValid extends Date {}
6883
8462
  export const DateValid = Date.check(isDateValid())
6884
8463
 
6885
8464
  /**
8465
+ * Schema type for {@link Duration}.
8466
+ *
8467
+ * @category Duration
6886
8468
  * @since 4.0.0
6887
8469
  */
6888
8470
  export interface Duration extends declare<Duration_.Duration> {}
@@ -6890,9 +8472,20 @@ export interface Duration extends declare<Duration_.Duration> {}
6890
8472
  /**
6891
8473
  * A schema for `Duration` values.
6892
8474
  *
6893
- * **Default JSON serializer**
8475
+ * The default JSON serializer encodes `Duration` as a tagged object with the
8476
+ * duration type and value.
8477
+ *
8478
+ * **Example** (Duration schema)
8479
+ *
8480
+ * ```ts
8481
+ * import { Schema } from "effect"
8482
+ * import { Duration } from "effect"
8483
+ *
8484
+ * Schema.decodeUnknownSync(Schema.Duration)(Duration.seconds(5))
8485
+ * // => Duration(5s)
8486
+ * ```
6894
8487
  *
6895
- * - encodes `Duration` as a `string`
8488
+ * @category Duration
6896
8489
  *
6897
8490
  * @since 4.0.0
6898
8491
  */
@@ -6956,6 +8549,9 @@ export const Duration: Duration = declare(
6956
8549
  )
6957
8550
 
6958
8551
  /**
8552
+ * Schema type for {@link DurationFromNanos}.
8553
+ *
8554
+ * @category Duration
6959
8555
  * @since 4.0.0
6960
8556
  */
6961
8557
  export interface DurationFromNanos extends decodeTo<Duration, BigInt> {}
@@ -6978,6 +8574,9 @@ export const DurationFromNanos: DurationFromNanos = BigInt.check(isGreaterThanOr
6978
8574
  )
6979
8575
 
6980
8576
  /**
8577
+ * Schema type for {@link DurationFromMillis}.
8578
+ *
8579
+ * @category Duration
6981
8580
  * @since 4.0.0
6982
8581
  */
6983
8582
  export interface DurationFromMillis extends decodeTo<Duration, Number> {}
@@ -7003,6 +8602,9 @@ export const DurationFromMillis: DurationFromMillis = Number.check(isGreaterThan
7003
8602
  )
7004
8603
 
7005
8604
  /**
8605
+ * Schema type for {@link BigDecimal}.
8606
+ *
8607
+ * @category Schemas
7006
8608
  * @since 4.0.0
7007
8609
  */
7008
8610
  export interface BigDecimal extends declare<BigDecimal_.BigDecimal> {}
@@ -7042,6 +8644,9 @@ export const BigDecimal: BigDecimal = declare(
7042
8644
  )
7043
8645
 
7044
8646
  /**
8647
+ * Schema type for {@link UnknownFromJsonString}.
8648
+ *
8649
+ * @category JSON
7045
8650
  * @since 4.0.0
7046
8651
  */
7047
8652
  export interface UnknownFromJsonString extends fromJsonString<Unknown> {}
@@ -7071,6 +8676,9 @@ export interface UnknownFromJsonString extends fromJsonString<Unknown> {}
7071
8676
  export const UnknownFromJsonString = fromJsonString(Unknown)
7072
8677
 
7073
8678
  /**
8679
+ * Schema type for {@link fromJsonString}.
8680
+ *
8681
+ * @category JSON
7074
8682
  * @since 4.0.0
7075
8683
  */
7076
8684
  export interface fromJsonString<S extends Top> extends decodeTo<S, String> {}
@@ -7147,11 +8755,20 @@ export function fromJsonString<S extends Top>(schema: S): fromJsonString<S> {
7147
8755
  }
7148
8756
 
7149
8757
  /**
8758
+ * Schema type for {@link File}.
8759
+ *
8760
+ * @category Schemas
7150
8761
  * @since 4.0.0
7151
8762
  */
7152
8763
  export interface File extends instanceOf<globalThis.File> {}
7153
8764
 
7154
8765
  /**
8766
+ * Schema for JavaScript `File` objects.
8767
+ *
8768
+ * The default JSON serializer encodes a `File` as `{ data, type, name, lastModified }`
8769
+ * where `data` is base64-encoded.
8770
+ *
8771
+ * @category Schemas
7155
8772
  * @since 4.0.0
7156
8773
  */
7157
8774
  export const File: File = instanceOf(globalThis.File, {
@@ -7208,11 +8825,20 @@ export const File: File = instanceOf(globalThis.File, {
7208
8825
  })
7209
8826
 
7210
8827
  /**
8828
+ * Schema type for {@link FormData}.
8829
+ *
8830
+ * @category Schemas
7211
8831
  * @since 4.0.0
7212
8832
  */
7213
8833
  export interface FormData extends instanceOf<globalThis.FormData> {}
7214
8834
 
7215
8835
  /**
8836
+ * Schema for JavaScript `FormData` objects.
8837
+ *
8838
+ * The default JSON serializer encodes a `FormData` as an array of `[key, entry]`
8839
+ * pairs where each entry is tagged as `"String"` or `"File"`.
8840
+ *
8841
+ * @category Schemas
7216
8842
  * @since 4.0.0
7217
8843
  */
7218
8844
  export const FormData: FormData = instanceOf(globalThis.FormData, {
@@ -7259,6 +8885,9 @@ export const FormData: FormData = instanceOf(globalThis.FormData, {
7259
8885
  })
7260
8886
 
7261
8887
  /**
8888
+ * Schema type for {@link fromFormData}.
8889
+ *
8890
+ * @category Schemas
7262
8891
  * @since 4.0.0
7263
8892
  */
7264
8893
  export interface fromFormData<S extends Top> extends decodeTo<S, FormData> {}
@@ -7351,11 +8980,19 @@ export function fromFormData<S extends Top>(schema: S): fromFormData<S> {
7351
8980
  }
7352
8981
 
7353
8982
  /**
8983
+ * Schema type for {@link URLSearchParams}.
8984
+ *
8985
+ * @category Schemas
7354
8986
  * @since 4.0.0
7355
8987
  */
7356
8988
  export interface URLSearchParams extends instanceOf<globalThis.URLSearchParams> {}
7357
8989
 
7358
8990
  /**
8991
+ * Schema for JavaScript `URLSearchParams` objects.
8992
+ *
8993
+ * The default JSON serializer encodes a `URLSearchParams` as a query string.
8994
+ *
8995
+ * @category Schemas
7359
8996
  * @since 4.0.0
7360
8997
  */
7361
8998
  export const URLSearchParams: URLSearchParams = instanceOf(globalThis.URLSearchParams, {
@@ -7378,6 +9015,9 @@ export const URLSearchParams: URLSearchParams = instanceOf(globalThis.URLSearchP
7378
9015
  })
7379
9016
 
7380
9017
  /**
9018
+ * Schema type for {@link fromURLSearchParams}.
9019
+ *
9020
+ * @category Schemas
7381
9021
  * @since 4.0.0
7382
9022
  */
7383
9023
  export interface fromURLSearchParams<S extends Top> extends decodeTo<S, URLSearchParams> {}
@@ -7461,6 +9101,9 @@ export function fromURLSearchParams<S extends Top>(schema: S): fromURLSearchPara
7461
9101
  }
7462
9102
 
7463
9103
  /**
9104
+ * Schema type for {@link Finite}.
9105
+ *
9106
+ * @category Schemas
7464
9107
  * @since 4.0.0
7465
9108
  */
7466
9109
  export interface Finite extends Number {}
@@ -7473,6 +9116,9 @@ export interface Finite extends Number {}
7473
9116
  export const Finite: Finite = Number.check(isFinite())
7474
9117
 
7475
9118
  /**
9119
+ * Schema type for {@link Int}.
9120
+ *
9121
+ * @category Schemas
7476
9122
  * @since 4.0.0
7477
9123
  */
7478
9124
  export interface Int extends Number {}
@@ -7485,6 +9131,9 @@ export interface Int extends Number {}
7485
9131
  export const Int: Int = Number.check(isInt())
7486
9132
 
7487
9133
  /**
9134
+ * Schema type for {@link NumberFromString}.
9135
+ *
9136
+ * @category Schemas
7488
9137
  * @since 4.0.0
7489
9138
  */
7490
9139
  export interface NumberFromString extends decodeTo<Finite, String> {}
@@ -7505,6 +9154,9 @@ export const NumberFromString: NumberFromString = String.annotate({
7505
9154
  }).pipe(decodeTo(Number, Transformation.numberFromString))
7506
9155
 
7507
9156
  /**
9157
+ * Schema type for {@link FiniteFromString}.
9158
+ *
9159
+ * @category Schemas
7508
9160
  * @since 4.0.0
7509
9161
  */
7510
9162
  export interface FiniteFromString extends decodeTo<Finite, String> {}
@@ -7526,6 +9178,9 @@ export const FiniteFromString: FiniteFromString = String.annotate({
7526
9178
  }).pipe(decodeTo(Finite, Transformation.numberFromString))
7527
9179
 
7528
9180
  /**
9181
+ * Schema type for {@link Trimmed}.
9182
+ *
9183
+ * @category Schemas
7529
9184
  * @since 4.0.0
7530
9185
  */
7531
9186
  export interface Trimmed extends String {}
@@ -7538,6 +9193,9 @@ export interface Trimmed extends String {}
7538
9193
  export const Trimmed: Trimmed = String.check(isTrimmed())
7539
9194
 
7540
9195
  /**
9196
+ * Schema type for {@link Trim}.
9197
+ *
9198
+ * @category Schemas
7541
9199
  * @since 4.0.0
7542
9200
  */
7543
9201
  export interface Trim extends decodeTo<Trimmed, String> {}
@@ -7558,6 +9216,9 @@ export const Trim: Trim = String.annotate({
7558
9216
  }).pipe(decodeTo(Trimmed, Transformation.trim()))
7559
9217
 
7560
9218
  /**
9219
+ * A union schema for JavaScript property keys: `number | symbol | string`.
9220
+ *
9221
+ * @category Schemas
7561
9222
  * @since 4.0.0
7562
9223
  */
7563
9224
  export const PropertyKey = Union([Finite, Symbol, String])
@@ -7573,6 +9234,9 @@ export const StandardSchemaV1FailureResult = Struct({
7573
9234
  })
7574
9235
 
7575
9236
  /**
9237
+ * Schema type for {@link BooleanFromBit}.
9238
+ *
9239
+ * @category Schemas
7576
9240
  * @since 4.0.0
7577
9241
  */
7578
9242
  export interface BooleanFromBit extends decodeTo<Boolean, Literals<readonly [0, 1]>> {}
@@ -7594,6 +9258,9 @@ export const BooleanFromBit: BooleanFromBit = Literals([0, 1]).pipe(
7594
9258
  )
7595
9259
 
7596
9260
  /**
9261
+ * Schema type for {@link Uint8Array}.
9262
+ *
9263
+ * @category Schemas
7597
9264
  * @since 4.0.0
7598
9265
  */
7599
9266
  export interface Uint8Array extends instanceOf<globalThis.Uint8Array<ArrayBufferLike>> {}
@@ -7632,6 +9299,9 @@ export const Uint8Array: Uint8Array = instanceOf(globalThis.Uint8Array<ArrayBuff
7632
9299
  })
7633
9300
 
7634
9301
  /**
9302
+ * Schema type for {@link Uint8ArrayFromBase64}.
9303
+ *
9304
+ * @category Schemas
7635
9305
  * @since 4.0.0
7636
9306
  */
7637
9307
  export interface Uint8ArrayFromBase64 extends decodeTo<Uint8Array, String> {}
@@ -7654,6 +9324,9 @@ export const Uint8ArrayFromBase64: Uint8ArrayFromBase64 = Base64String.pipe(
7654
9324
  )
7655
9325
 
7656
9326
  /**
9327
+ * Schema type for {@link Uint8ArrayFromBase64Url}.
9328
+ *
9329
+ * @category Schemas
7657
9330
  * @since 4.0.0
7658
9331
  */
7659
9332
  export interface Uint8ArrayFromBase64Url extends decodeTo<Uint8Array, String> {}
@@ -7681,6 +9354,9 @@ export const Uint8ArrayFromBase64Url: Uint8ArrayFromBase64Url = String.annotate(
7681
9354
  )
7682
9355
 
7683
9356
  /**
9357
+ * Schema type for {@link Uint8ArrayFromHex}.
9358
+ *
9359
+ * @category Schemas
7684
9360
  * @since 4.0.0
7685
9361
  */
7686
9362
  export interface Uint8ArrayFromHex extends decodeTo<Uint8Array, String> {}
@@ -7708,6 +9384,9 @@ export const Uint8ArrayFromHex: Uint8ArrayFromHex = String.annotate({
7708
9384
  )
7709
9385
 
7710
9386
  /**
9387
+ * Schema type for {@link DateTimeUtc}.
9388
+ *
9389
+ * @category DateTime
7711
9390
  * @since 4.0.0
7712
9391
  */
7713
9392
  export interface DateTimeUtc extends declare<DateTime.Utc> {}
@@ -7747,6 +9426,9 @@ export const DateTimeUtc: DateTimeUtc = declare(
7747
9426
  )
7748
9427
 
7749
9428
  /**
9429
+ * Schema type for {@link DateTimeUtcFromDate}.
9430
+ *
9431
+ * @category DateTime
7750
9432
  * @since 4.0.0
7751
9433
  */
7752
9434
  export interface DateTimeUtcFromDate extends decodeTo<DateTimeUtc, Date> {}
@@ -7771,6 +9453,9 @@ export const DateTimeUtcFromDate: DateTimeUtcFromDate = DateValid.pipe(
7771
9453
  )
7772
9454
 
7773
9455
  /**
9456
+ * Schema type for {@link DateTimeUtcFromString}.
9457
+ *
9458
+ * @category DateTime
7774
9459
  * @since 4.0.0
7775
9460
  */
7776
9461
  export interface DateTimeUtcFromString extends decodeTo<DateTimeUtc, String> {}
@@ -7799,6 +9484,9 @@ export const DateTimeUtcFromString: DateTimeUtcFromString = String.annotate({
7799
9484
  )
7800
9485
 
7801
9486
  /**
9487
+ * Schema type for {@link DateTimeUtcFromMillis}.
9488
+ *
9489
+ * @category DateTime
7802
9490
  * @since 4.0.0
7803
9491
  */
7804
9492
  export interface DateTimeUtcFromMillis extends decodeTo<instanceOf<DateTime.Utc>, Number> {}
@@ -7823,6 +9511,9 @@ export const DateTimeUtcFromMillis: DateTimeUtcFromMillis = Number.pipe(
7823
9511
  )
7824
9512
 
7825
9513
  /**
9514
+ * Schema type for {@link TimeZoneOffset}.
9515
+ *
9516
+ * @category DateTime
7826
9517
  * @since 4.0.0
7827
9518
  */
7828
9519
  export interface TimeZoneOffset extends declare<DateTime.TimeZone.Offset> {}
@@ -7862,6 +9553,9 @@ export const TimeZoneOffset: TimeZoneOffset = declare(
7862
9553
  )
7863
9554
 
7864
9555
  /**
9556
+ * Schema type for {@link TimeZoneNamed}.
9557
+ *
9558
+ * @category DateTime
7865
9559
  * @since 4.0.0
7866
9560
  */
7867
9561
  export interface TimeZoneNamed extends declare<DateTime.TimeZone.Named> {}
@@ -7905,6 +9599,9 @@ export const TimeZoneNamed: TimeZoneNamed = declare(
7905
9599
  )
7906
9600
 
7907
9601
  /**
9602
+ * Schema type for {@link TimeZone}.
9603
+ *
9604
+ * @category DateTime
7908
9605
  * @since 4.0.0
7909
9606
  */
7910
9607
  export interface TimeZone extends declare<DateTime.TimeZone> {}
@@ -7952,6 +9649,9 @@ export const TimeZone: TimeZone = declare(
7952
9649
  )
7953
9650
 
7954
9651
  /**
9652
+ * Schema type for {@link DateTimeZoned}.
9653
+ *
9654
+ * @category DateTime
7955
9655
  * @since 4.0.0
7956
9656
  */
7957
9657
  export interface DateTimeZoned extends declare<DateTime.Zoned> {}
@@ -8004,6 +9704,14 @@ export const DateTimeZoned: DateTimeZoned = declare(
8004
9704
  // -----------------------------------------------------------------------------
8005
9705
 
8006
9706
  /**
9707
+ * Interface for schema-backed classes created with {@link Class}.
9708
+ *
9709
+ * A `Class` is a TypeScript class whose constructor validates its input
9710
+ * against a {@link Struct} schema. Instances are always structurally valid.
9711
+ *
9712
+ * The interface exposes the schema's `fields`, an `identifier` string, and
9713
+ * helpers such as `mapFields`, `annotate`, `check`, and `extend`.
9714
+ *
8007
9715
  * @since 4.0.0
8008
9716
  */
8009
9717
  export interface Class<Self, S extends Top & { readonly fields: Struct.Fields }, Inherited> extends
@@ -8057,6 +9765,10 @@ export interface Class<Self, S extends Top & { readonly fields: Struct.Fields },
8057
9765
  type AddStaticMembers<C, Static> = C & Pick<Static, Exclude<keyof Static, keyof C>>
8058
9766
 
8059
9767
  /**
9768
+ * A {@link Class} that additionally exposes an `extend` method, allowing
9769
+ * subclasses to be derived with extra fields while inheriting all parent
9770
+ * fields and validation.
9771
+ *
8060
9772
  * @since 4.0.0
8061
9773
  */
8062
9774
  export interface ExtendableClass<Self, S extends Top & { readonly fields: Struct.Fields }, Inherited>
@@ -8237,16 +9949,136 @@ function isStruct(schema: Struct.Fields | Struct<Struct.Fields>): schema is Stru
8237
9949
  }
8238
9950
 
8239
9951
  /**
9952
+ * Creates a schema-backed class whose constructor validates input against a
9953
+ * {@link Struct} schema. Construction throws a {@link SchemaError} on invalid
9954
+ * input (unless `disableValidation` is set in the options).
9955
+ *
9956
+ * Pass the desired class type as the first type parameter. The second optional
9957
+ * type parameter can be used to add nominal brands.
9958
+ *
9959
+ * **Example** (Basic class)
9960
+ *
9961
+ * ```ts
9962
+ * import { Schema } from "effect"
9963
+ *
9964
+ * class Person extends Schema.Class<Person>("Person")({
9965
+ * name: Schema.String,
9966
+ * age: Schema.Number
9967
+ * }) {}
9968
+ *
9969
+ * const alice = new Person({ name: "Alice", age: 30 })
9970
+ * console.log(alice.name) // "Alice"
9971
+ * console.log(`${alice}`) // "Person({ name: Alice, age: 30 })"
9972
+ * ```
9973
+ *
9974
+ * **Example** (Extending a class)
9975
+ *
9976
+ * ```ts
9977
+ * import { Schema } from "effect"
9978
+ *
9979
+ * class Animal extends Schema.Class<Animal>("Animal")({
9980
+ * name: Schema.String
9981
+ * }) {}
9982
+ *
9983
+ * class Dog extends Animal.extend<Dog>("Dog")({
9984
+ * breed: Schema.String
9985
+ * }) {}
9986
+ *
9987
+ * const dog = new Dog({ name: "Rex", breed: "Labrador" })
9988
+ * console.log(dog.name) // "Rex"
9989
+ * console.log(dog.breed) // "Labrador"
9990
+ * ```
9991
+ *
8240
9992
  * @category Constructors
8241
9993
  * @since 4.0.0
8242
9994
  */
8243
9995
  export const Class: {
8244
9996
  /**
9997
+ * Creates a schema-backed class whose constructor validates input against a
9998
+ * {@link Struct} schema. Construction throws a {@link SchemaError} on invalid
9999
+ * input (unless `disableValidation` is set in the options).
10000
+ *
10001
+ * Pass the desired class type as the first type parameter. The second optional
10002
+ * type parameter can be used to add nominal brands.
10003
+ *
10004
+ * **Example** (Basic class)
10005
+ *
10006
+ * ```ts
10007
+ * import { Schema } from "effect"
10008
+ *
10009
+ * class Person extends Schema.Class<Person>("Person")({
10010
+ * name: Schema.String,
10011
+ * age: Schema.Number
10012
+ * }) {}
10013
+ *
10014
+ * const alice = new Person({ name: "Alice", age: 30 })
10015
+ * console.log(alice.name) // "Alice"
10016
+ * console.log(`${alice}`) // "Person({ name: Alice, age: 30 })"
10017
+ * ```
10018
+ *
10019
+ * **Example** (Extending a class)
10020
+ *
10021
+ * ```ts
10022
+ * import { Schema } from "effect"
10023
+ *
10024
+ * class Animal extends Schema.Class<Animal>("Animal")({
10025
+ * name: Schema.String
10026
+ * }) {}
10027
+ *
10028
+ * class Dog extends Animal.extend<Dog>("Dog")({
10029
+ * breed: Schema.String
10030
+ * }) {}
10031
+ *
10032
+ * const dog = new Dog({ name: "Rex", breed: "Labrador" })
10033
+ * console.log(dog.name) // "Rex"
10034
+ * console.log(dog.breed) // "Labrador"
10035
+ * ```
10036
+ *
8245
10037
  * @category Constructors
8246
10038
  * @since 4.0.0
8247
10039
  */
8248
10040
  <Self, Brand = {}>(identifier: string): {
8249
10041
  /**
10042
+ * Creates a schema-backed class whose constructor validates input against a
10043
+ * {@link Struct} schema. Construction throws a {@link SchemaError} on invalid
10044
+ * input (unless `disableValidation` is set in the options).
10045
+ *
10046
+ * Pass the desired class type as the first type parameter. The second optional
10047
+ * type parameter can be used to add nominal brands.
10048
+ *
10049
+ * **Example** (Basic class)
10050
+ *
10051
+ * ```ts
10052
+ * import { Schema } from "effect"
10053
+ *
10054
+ * class Person extends Schema.Class<Person>("Person")({
10055
+ * name: Schema.String,
10056
+ * age: Schema.Number
10057
+ * }) {}
10058
+ *
10059
+ * const alice = new Person({ name: "Alice", age: 30 })
10060
+ * console.log(alice.name) // "Alice"
10061
+ * console.log(`${alice}`) // "Person({ name: Alice, age: 30 })"
10062
+ * ```
10063
+ *
10064
+ * **Example** (Extending a class)
10065
+ *
10066
+ * ```ts
10067
+ * import { Schema } from "effect"
10068
+ *
10069
+ * class Animal extends Schema.Class<Animal>("Animal")({
10070
+ * name: Schema.String
10071
+ * }) {}
10072
+ *
10073
+ * class Dog extends Animal.extend<Dog>("Dog")({
10074
+ * breed: Schema.String
10075
+ * }) {}
10076
+ *
10077
+ * const dog = new Dog({ name: "Rex", breed: "Labrador" })
10078
+ * console.log(dog.name) // "Rex"
10079
+ * console.log(dog.breed) // "Labrador"
10080
+ * ```
10081
+ *
8250
10082
  * @category Constructors
8251
10083
  * @since 4.0.0
8252
10084
  */
@@ -8255,6 +10087,46 @@ export const Class: {
8255
10087
  annotations?: Annotations.Declaration<Self, readonly [Struct<Fields>]>
8256
10088
  ): ExtendableClass<Self, Struct<Fields>, Brand>
8257
10089
  /**
10090
+ * Creates a schema-backed class whose constructor validates input against a
10091
+ * {@link Struct} schema. Construction throws a {@link SchemaError} on invalid
10092
+ * input (unless `disableValidation` is set in the options).
10093
+ *
10094
+ * Pass the desired class type as the first type parameter. The second optional
10095
+ * type parameter can be used to add nominal brands.
10096
+ *
10097
+ * **Example** (Basic class)
10098
+ *
10099
+ * ```ts
10100
+ * import { Schema } from "effect"
10101
+ *
10102
+ * class Person extends Schema.Class<Person>("Person")({
10103
+ * name: Schema.String,
10104
+ * age: Schema.Number
10105
+ * }) {}
10106
+ *
10107
+ * const alice = new Person({ name: "Alice", age: 30 })
10108
+ * console.log(alice.name) // "Alice"
10109
+ * console.log(`${alice}`) // "Person({ name: Alice, age: 30 })"
10110
+ * ```
10111
+ *
10112
+ * **Example** (Extending a class)
10113
+ *
10114
+ * ```ts
10115
+ * import { Schema } from "effect"
10116
+ *
10117
+ * class Animal extends Schema.Class<Animal>("Animal")({
10118
+ * name: Schema.String
10119
+ * }) {}
10120
+ *
10121
+ * class Dog extends Animal.extend<Dog>("Dog")({
10122
+ * breed: Schema.String
10123
+ * }) {}
10124
+ *
10125
+ * const dog = new Dog({ name: "Rex", breed: "Labrador" })
10126
+ * console.log(dog.name) // "Rex"
10127
+ * console.log(dog.breed) // "Labrador"
10128
+ * ```
10129
+ *
8258
10130
  * @category Constructors
8259
10131
  * @since 4.0.0
8260
10132
  */
@@ -8270,16 +10142,79 @@ export const Class: {
8270
10142
  }
8271
10143
 
8272
10144
  /**
10145
+ * Like {@link Class} but automatically adds a `_tag` literal field set to the
10146
+ * given `tag` value. This makes instances compatible with tagged union
10147
+ * discrimination patterns.
10148
+ *
10149
+ * The optional `identifier` parameter overrides the schema identifier;
10150
+ * it defaults to the `tag` value.
10151
+ *
10152
+ * **Example** (Tagged class)
10153
+ *
10154
+ * ```ts
10155
+ * import { Schema } from "effect"
10156
+ *
10157
+ * class Circle extends Schema.TaggedClass<Circle>()("Circle", {
10158
+ * radius: Schema.Number
10159
+ * }) {}
10160
+ *
10161
+ * const c = new Circle({ radius: 5 })
10162
+ * console.log(c._tag) // "Circle"
10163
+ * console.log(c.radius) // 5
10164
+ * ```
10165
+ *
8273
10166
  * @category Constructors
8274
10167
  * @since 4.0.0
8275
10168
  */
8276
10169
  export const TaggedClass: {
8277
10170
  /**
10171
+ * Like {@link Class} but automatically adds a `_tag` literal field set to the
10172
+ * given `tag` value. This makes instances compatible with tagged union
10173
+ * discrimination patterns.
10174
+ *
10175
+ * The optional `identifier` parameter overrides the schema identifier;
10176
+ * it defaults to the `tag` value.
10177
+ *
10178
+ * **Example** (Tagged class)
10179
+ *
10180
+ * ```ts
10181
+ * import { Schema } from "effect"
10182
+ *
10183
+ * class Circle extends Schema.TaggedClass<Circle>()("Circle", {
10184
+ * radius: Schema.Number
10185
+ * }) {}
10186
+ *
10187
+ * const c = new Circle({ radius: 5 })
10188
+ * console.log(c._tag) // "Circle"
10189
+ * console.log(c.radius) // 5
10190
+ * ```
10191
+ *
8278
10192
  * @category Constructors
8279
10193
  * @since 4.0.0
8280
10194
  */
8281
10195
  <Self, Brand = {}>(identifier?: string): {
8282
10196
  /**
10197
+ * Like {@link Class} but automatically adds a `_tag` literal field set to the
10198
+ * given `tag` value. This makes instances compatible with tagged union
10199
+ * discrimination patterns.
10200
+ *
10201
+ * The optional `identifier` parameter overrides the schema identifier;
10202
+ * it defaults to the `tag` value.
10203
+ *
10204
+ * **Example** (Tagged class)
10205
+ *
10206
+ * ```ts
10207
+ * import { Schema } from "effect"
10208
+ *
10209
+ * class Circle extends Schema.TaggedClass<Circle>()("Circle", {
10210
+ * radius: Schema.Number
10211
+ * }) {}
10212
+ *
10213
+ * const c = new Circle({ radius: 5 })
10214
+ * console.log(c._tag) // "Circle"
10215
+ * console.log(c.radius) // 5
10216
+ * ```
10217
+ *
8283
10218
  * @category Constructors
8284
10219
  * @since 4.0.0
8285
10220
  */
@@ -8289,6 +10224,27 @@ export const TaggedClass: {
8289
10224
  annotations?: Annotations.Declaration<Self, readonly [TaggedStruct<Tag, Fields>]>
8290
10225
  ): ExtendableClass<Self, TaggedStruct<Tag, Fields>, Brand>
8291
10226
  /**
10227
+ * Like {@link Class} but automatically adds a `_tag` literal field set to the
10228
+ * given `tag` value. This makes instances compatible with tagged union
10229
+ * discrimination patterns.
10230
+ *
10231
+ * The optional `identifier` parameter overrides the schema identifier;
10232
+ * it defaults to the `tag` value.
10233
+ *
10234
+ * **Example** (Tagged class)
10235
+ *
10236
+ * ```ts
10237
+ * import { Schema } from "effect"
10238
+ *
10239
+ * class Circle extends Schema.TaggedClass<Circle>()("Circle", {
10240
+ * radius: Schema.Number
10241
+ * }) {}
10242
+ *
10243
+ * const c = new Circle({ radius: 5 })
10244
+ * console.log(c._tag) // "Circle"
10245
+ * console.log(c.radius) // 5
10246
+ * ```
10247
+ *
8292
10248
  * @category Constructors
8293
10249
  * @since 4.0.0
8294
10250
  */
@@ -8319,6 +10275,10 @@ export const TaggedClass: {
8319
10275
  }
8320
10276
 
8321
10277
  /**
10278
+ * Interface for schema-backed error classes created with {@link ErrorClass}.
10279
+ * Extends {@link ExtendableClass} and is also a `YieldableError`, so instances
10280
+ * can be yielded inside `Effect.gen` as failures.
10281
+ *
8322
10282
  * @since 4.0.0
8323
10283
  */
8324
10284
  export interface ErrorClass<Self, S extends Top & { readonly fields: Struct.Fields }, Inherited>
@@ -8326,16 +10286,73 @@ export interface ErrorClass<Self, S extends Top & { readonly fields: Struct.Fiel
8326
10286
  {}
8327
10287
 
8328
10288
  /**
10289
+ * Creates a schema-backed error class that can be used as a typed,
10290
+ * yieldable error in Effect programs. Combines {@link Class} validation with
10291
+ * the `YieldableError` interface so instances can be yielded directly inside
10292
+ * `Effect.gen`.
10293
+ *
10294
+ * **Example** (Schema-backed error)
10295
+ *
10296
+ * ```ts
10297
+ * import { Effect, Schema } from "effect"
10298
+ *
10299
+ * class NotFound extends Schema.ErrorClass<NotFound>("NotFound")({
10300
+ * id: Schema.Number
10301
+ * }) {}
10302
+ *
10303
+ * const program = Effect.gen(function*() {
10304
+ * yield* new NotFound({ id: 1 })
10305
+ * })
10306
+ * ```
10307
+ *
8329
10308
  * @category Constructors
8330
10309
  * @since 4.0.0
8331
10310
  */
8332
10311
  export const ErrorClass: {
8333
10312
  /**
10313
+ * Creates a schema-backed error class that can be used as a typed,
10314
+ * yieldable error in Effect programs. Combines {@link Class} validation with
10315
+ * the `YieldableError` interface so instances can be yielded directly inside
10316
+ * `Effect.gen`.
10317
+ *
10318
+ * **Example** (Schema-backed error)
10319
+ *
10320
+ * ```ts
10321
+ * import { Effect, Schema } from "effect"
10322
+ *
10323
+ * class NotFound extends Schema.ErrorClass<NotFound>("NotFound")({
10324
+ * id: Schema.Number
10325
+ * }) {}
10326
+ *
10327
+ * const program = Effect.gen(function*() {
10328
+ * yield* new NotFound({ id: 1 })
10329
+ * })
10330
+ * ```
10331
+ *
8334
10332
  * @category Constructors
8335
10333
  * @since 4.0.0
8336
10334
  */
8337
10335
  <Self, Brand = {}>(identifier: string): {
8338
10336
  /**
10337
+ * Creates a schema-backed error class that can be used as a typed,
10338
+ * yieldable error in Effect programs. Combines {@link Class} validation with
10339
+ * the `YieldableError` interface so instances can be yielded directly inside
10340
+ * `Effect.gen`.
10341
+ *
10342
+ * **Example** (Schema-backed error)
10343
+ *
10344
+ * ```ts
10345
+ * import { Effect, Schema } from "effect"
10346
+ *
10347
+ * class NotFound extends Schema.ErrorClass<NotFound>("NotFound")({
10348
+ * id: Schema.Number
10349
+ * }) {}
10350
+ *
10351
+ * const program = Effect.gen(function*() {
10352
+ * yield* new NotFound({ id: 1 })
10353
+ * })
10354
+ * ```
10355
+ *
8339
10356
  * @category Constructors
8340
10357
  * @since 4.0.0
8341
10358
  */
@@ -8344,6 +10361,25 @@ export const ErrorClass: {
8344
10361
  annotations?: Annotations.Declaration<Self, readonly [Struct<Fields>]>
8345
10362
  ): ErrorClass<Self, Struct<Fields>, Cause_.YieldableError & Brand>
8346
10363
  /**
10364
+ * Creates a schema-backed error class that can be used as a typed,
10365
+ * yieldable error in Effect programs. Combines {@link Class} validation with
10366
+ * the `YieldableError` interface so instances can be yielded directly inside
10367
+ * `Effect.gen`.
10368
+ *
10369
+ * **Example** (Schema-backed error)
10370
+ *
10371
+ * ```ts
10372
+ * import { Effect, Schema } from "effect"
10373
+ *
10374
+ * class NotFound extends Schema.ErrorClass<NotFound>("NotFound")({
10375
+ * id: Schema.Number
10376
+ * }) {}
10377
+ *
10378
+ * const program = Effect.gen(function*() {
10379
+ * yield* new NotFound({ id: 1 })
10380
+ * })
10381
+ * ```
10382
+ *
8347
10383
  * @category Constructors
8348
10384
  * @since 4.0.0
8349
10385
  */
@@ -8361,16 +10397,70 @@ export const ErrorClass: {
8361
10397
  }
8362
10398
 
8363
10399
  /**
10400
+ * Like {@link ErrorClass} but automatically adds a `_tag` literal field. The
10401
+ * resulting class is both a schema-validated, yieldable error and a tagged
10402
+ * union member.
10403
+ *
10404
+ * **Example** (Tagged error class)
10405
+ *
10406
+ * ```ts
10407
+ * import { Effect, Schema } from "effect"
10408
+ *
10409
+ * class NotFound extends Schema.TaggedErrorClass<NotFound>()("NotFound", {
10410
+ * id: Schema.Number
10411
+ * }) {}
10412
+ *
10413
+ * const program = Effect.gen(function*() {
10414
+ * yield* new NotFound({ id: 42 })
10415
+ * })
10416
+ * ```
10417
+ *
8364
10418
  * @category Constructors
8365
10419
  * @since 4.0.0
8366
10420
  */
8367
10421
  export const TaggedErrorClass: {
8368
10422
  /**
10423
+ * Like {@link ErrorClass} but automatically adds a `_tag` literal field. The
10424
+ * resulting class is both a schema-validated, yieldable error and a tagged
10425
+ * union member.
10426
+ *
10427
+ * **Example** (Tagged error class)
10428
+ *
10429
+ * ```ts
10430
+ * import { Effect, Schema } from "effect"
10431
+ *
10432
+ * class NotFound extends Schema.TaggedErrorClass<NotFound>()("NotFound", {
10433
+ * id: Schema.Number
10434
+ * }) {}
10435
+ *
10436
+ * const program = Effect.gen(function*() {
10437
+ * yield* new NotFound({ id: 42 })
10438
+ * })
10439
+ * ```
10440
+ *
8369
10441
  * @category Constructors
8370
10442
  * @since 4.0.0
8371
10443
  */
8372
10444
  <Self, Brand = {}>(identifier?: string): {
8373
10445
  /**
10446
+ * Like {@link ErrorClass} but automatically adds a `_tag` literal field. The
10447
+ * resulting class is both a schema-validated, yieldable error and a tagged
10448
+ * union member.
10449
+ *
10450
+ * **Example** (Tagged error class)
10451
+ *
10452
+ * ```ts
10453
+ * import { Effect, Schema } from "effect"
10454
+ *
10455
+ * class NotFound extends Schema.TaggedErrorClass<NotFound>()("NotFound", {
10456
+ * id: Schema.Number
10457
+ * }) {}
10458
+ *
10459
+ * const program = Effect.gen(function*() {
10460
+ * yield* new NotFound({ id: 42 })
10461
+ * })
10462
+ * ```
10463
+ *
8374
10464
  * @category Constructors
8375
10465
  * @since 4.0.0
8376
10466
  */
@@ -8380,6 +10470,24 @@ export const TaggedErrorClass: {
8380
10470
  annotations?: Annotations.Declaration<Self, readonly [TaggedStruct<Tag, Fields>]>
8381
10471
  ): ErrorClass<Self, TaggedStruct<Tag, Fields>, Cause_.YieldableError & Brand>
8382
10472
  /**
10473
+ * Like {@link ErrorClass} but automatically adds a `_tag` literal field. The
10474
+ * resulting class is both a schema-validated, yieldable error and a tagged
10475
+ * union member.
10476
+ *
10477
+ * **Example** (Tagged error class)
10478
+ *
10479
+ * ```ts
10480
+ * import { Effect, Schema } from "effect"
10481
+ *
10482
+ * class NotFound extends Schema.TaggedErrorClass<NotFound>()("NotFound", {
10483
+ * id: Schema.Number
10484
+ * }) {}
10485
+ *
10486
+ * const program = Effect.gen(function*() {
10487
+ * yield* new NotFound({ id: 42 })
10488
+ * })
10489
+ * ```
10490
+ *
8383
10491
  * @category Constructors
8384
10492
  * @since 4.0.0
8385
10493
  */
@@ -8414,12 +10522,21 @@ export const TaggedErrorClass: {
8414
10522
  // -----------------------------------------------------------------------------
8415
10523
 
8416
10524
  /**
10525
+ * A thunk that, given the `fast-check` module, returns an `Arbitrary<T>`.
10526
+ * Use this type when you need to defer instantiation of the arbitrary, for
10527
+ * example to support recursive schemas.
10528
+ *
8417
10529
  * @category Arbitrary
8418
10530
  * @since 4.0.0
8419
10531
  */
8420
10532
  export type LazyArbitrary<T> = (fc: typeof FastCheck) => FastCheck.Arbitrary<T>
8421
10533
 
8422
10534
  /**
10535
+ * Derives a {@link LazyArbitrary} from a schema. The result is memoized so
10536
+ * repeated calls with the same schema are cheap.
10537
+ *
10538
+ * Prefer {@link toArbitrary} when you just need the arbitrary directly.
10539
+ *
8423
10540
  * @category Arbitrary
8424
10541
  * @since 4.0.0
8425
10542
  */
@@ -8429,6 +10546,24 @@ export function toArbitraryLazy<S extends Top>(schema: S): LazyArbitrary<S["Type
8429
10546
  }
8430
10547
 
8431
10548
  /**
10549
+ * Derives a `fast-check` `Arbitrary` from a schema for property-based
10550
+ * testing. The derived arbitrary generates values that satisfy the schema.
10551
+ *
10552
+ * **Example** (Generating arbitrary values)
10553
+ *
10554
+ * ```ts
10555
+ * import { Schema } from "effect"
10556
+ * import * as FastCheck from "fast-check"
10557
+ *
10558
+ * const PersonArb = Schema.toArbitrary(
10559
+ * Schema.Struct({ name: Schema.String, age: Schema.Number })
10560
+ * )
10561
+ *
10562
+ * // Sample a random value
10563
+ * const sample = FastCheck.sample(PersonArb, 1)[0]
10564
+ * console.log(typeof sample.name) // "string"
10565
+ * ```
10566
+ *
8432
10567
  * @category Arbitrary
8433
10568
  * @since 4.0.0
8434
10569
  */
@@ -8456,6 +10591,13 @@ export function overrideToFormatter<S extends Top>(toFormatter: () => Formatter<
8456
10591
  }
8457
10592
 
8458
10593
  /**
10594
+ * Derives a string formatter function from a schema. The formatter converts
10595
+ * a value to its human-readable string representation, recursing into structs,
10596
+ * arrays, and unions.
10597
+ *
10598
+ * The optional `onBefore` hook lets you intercept specific AST nodes before
10599
+ * the default formatting logic runs.
10600
+ *
8459
10601
  * @category Formatter
8460
10602
  * @since 4.0.0
8461
10603
  */
@@ -8600,10 +10742,9 @@ export function toFormatter<T>(schema: Schema<T>, options?: {
8600
10742
  // -----------------------------------------------------------------------------
8601
10743
 
8602
10744
  /**
8603
- * **Technical Note**
8604
- *
8605
- * This annotation cannot be added to `Annotations.Bottom` because it would make
8606
- * the schema invariant.
10745
+ * Overrides the equivalence derivation for a schema by supplying a custom
10746
+ * `Equivalence`. Use this when the default structural equivalence derived by
10747
+ * {@link toEquivalence} is not appropriate for a type.
8607
10748
  *
8608
10749
  * @category Equivalence
8609
10750
  * @since 4.0.0
@@ -8613,6 +10754,21 @@ export function overrideToEquivalence<S extends Top>(toEquivalence: () => Equiva
8613
10754
  }
8614
10755
 
8615
10756
  /**
10757
+ * Derives an `Equivalence` from a schema. Two values are considered equal when
10758
+ * every field (and nested field) compares equal according to the schema
10759
+ * structure.
10760
+ *
10761
+ * **Example** (Struct equivalence)
10762
+ *
10763
+ * ```ts
10764
+ * import { Schema } from "effect"
10765
+ *
10766
+ * const eq = Schema.toEquivalence(Schema.Struct({ id: Schema.Number, name: Schema.String }))
10767
+ *
10768
+ * console.log(eq({ id: 1, name: "Alice" }, { id: 1, name: "Alice" })) // true
10769
+ * console.log(eq({ id: 1, name: "Alice" }, { id: 2, name: "Alice" })) // false
10770
+ * ```
10771
+ *
8616
10772
  * @category Equivalence
8617
10773
  * @since 4.0.0
8618
10774
  */
@@ -8625,6 +10781,10 @@ export function toEquivalence<T>(schema: Schema<T>): Equivalence.Equivalence<T>
8625
10781
  // -----------------------------------------------------------------------------
8626
10782
 
8627
10783
  /**
10784
+ * Derives an intermediate `SchemaRepresentation.Document` from a schema. This
10785
+ * document is used internally by {@link toJsonSchemaDocument} and related
10786
+ * functions to produce JSON Schema output.
10787
+ *
8628
10788
  * @category Representation
8629
10789
  * @since 4.0.0
8630
10790
  */
@@ -8637,6 +10797,8 @@ export function toRepresentation(schema: Top): SchemaRepresentation.Document {
8637
10797
  // -----------------------------------------------------------------------------
8638
10798
 
8639
10799
  /**
10800
+ * Options for {@link toJsonSchemaDocument}.
10801
+ *
8640
10802
  * @since 4.0.0
8641
10803
  */
8642
10804
  export interface ToJsonSchemaOptions {
@@ -8680,14 +10842,20 @@ export function toJsonSchemaDocument(schema: Top, options?: ToJsonSchemaOptions)
8680
10842
  // -----------------------------------------------------------------------------
8681
10843
 
8682
10844
  /**
10845
+ * Derives a canonical JSON codec from a schema. The encoded form is `unknown`
10846
+ * (any JSON-compatible value), decoded to the schema's `Type`.
10847
+ *
8683
10848
  * @category Canonical Codecs
8684
10849
  * @since 4.0.0
8685
10850
  */
8686
- export function toCodecJson<T, E, RD, RE>(schema: Codec<T, E, RD, RE>): Codec<T, unknown, RD, RE> {
10851
+ export function toCodecJson<T, E, RD, RE>(schema: Codec<T, E, RD, RE>): Codec<T, Json, RD, RE> {
8687
10852
  return make(InternalToCodec.toCodecJson(schema.ast))
8688
10853
  }
8689
10854
 
8690
10855
  /**
10856
+ * Derives an isomorphism codec from a schema. The encoded form is the
10857
+ * schema's `Iso` type — the intermediate representation used for round-tripping.
10858
+ *
8691
10859
  * @category Canonical Codecs
8692
10860
  * @since 4.0.0
8693
10861
  */
@@ -8696,6 +10864,9 @@ export function toCodecIso<S extends Top>(schema: S): Codec<S["Type"], S["Iso"]>
8696
10864
  }
8697
10865
 
8698
10866
  /**
10867
+ * A {@link Tree} of `string | undefined` nodes. Leaf values are either a
10868
+ * string representation or `undefined` for opaque/declaration types.
10869
+ *
8699
10870
  * @category Canonical Codecs
8700
10871
  * @since 4.0.0
8701
10872
  */
@@ -8749,6 +10920,10 @@ type XmlEncoderOptions = {
8749
10920
  }
8750
10921
 
8751
10922
  /**
10923
+ * Derives an XML encoder from a codec. Encodes a value to an XML string by
10924
+ * first converting it through {@link toCodecStringTree}, then serializing the
10925
+ * resulting tree to XML.
10926
+ *
8752
10927
  * @category Canonical Codecs
8753
10928
  * @since 4.0.0
8754
10929
  */
@@ -9009,6 +11184,9 @@ function onSerializerEnsureArray(ast: AST.AST): AST.AST {
9009
11184
  // -----------------------------------------------------------------------------
9010
11185
 
9011
11186
  /**
11187
+ * Derives an `Iso` optic from a schema that isomorphically converts between
11188
+ * the schema's `Type` and its `Iso` (intermediate / serialized form).
11189
+ *
9012
11190
  * @category Optic
9013
11191
  * @since 4.0.0
9014
11192
  */
@@ -9018,6 +11196,8 @@ export function toIso<S extends Top>(schema: S): Optic_.Iso<S["Type"], S["Iso"]>
9018
11196
  }
9019
11197
 
9020
11198
  /**
11199
+ * Returns an identity `Iso` over the schema's source (`Type`) side.
11200
+ *
9021
11201
  * @category Optic
9022
11202
  * @since 4.0.0
9023
11203
  */
@@ -9026,6 +11206,8 @@ export function toIsoSource<S extends Top>(_: S): Optic_.Iso<S["Type"], S["Type"
9026
11206
  }
9027
11207
 
9028
11208
  /**
11209
+ * Returns an identity `Iso` over the schema's focus (`Iso`) side.
11210
+ *
9029
11211
  * @category Optic
9030
11212
  * @since 4.0.0
9031
11213
  */
@@ -9034,6 +11216,9 @@ export function toIsoFocus<S extends Top>(_: S): Optic_.Iso<S["Iso"], S["Iso"]>
9034
11216
  }
9035
11217
 
9036
11218
  /**
11219
+ * The schema type returned by {@link overrideToCodecIso}. Carries a custom
11220
+ * `Iso` type parameter and exposes the original `schema`.
11221
+ *
9037
11222
  * @category Optic
9038
11223
  * @since 4.0.0
9039
11224
  */
@@ -9061,10 +11246,11 @@ export interface overrideToCodecIso<S extends Top, Iso> extends
9061
11246
  }
9062
11247
 
9063
11248
  /**
9064
- * **Technical Note**
9065
- *
9066
- * This annotation cannot be added to `Annotations.Bottom` because it changes
9067
- * the schema type.
11249
+ * Overrides the ISO codec derivation for a schema by providing a target codec
11250
+ * and explicit `decode`/`encode` getters. The resulting schema carries a
11251
+ * custom `Iso` type, which changes the schema's type parameter — use
11252
+ * {@link overrideToCodecIso} when the default ISO transformation is not
11253
+ * appropriate.
9068
11254
  *
9069
11255
  * @category Optic
9070
11256
  * @since 4.0.0
@@ -9091,11 +11277,15 @@ export function overrideToCodecIso<S extends Top, Iso>(
9091
11277
  // -----------------------------------------------------------------------------
9092
11278
 
9093
11279
  /**
11280
+ * Derives a JSON Patch differ from a codec. Serializes values to JSON (via
11281
+ * {@link toCodecJson}), computes RFC 6902 JSON Patch operations between old
11282
+ * and new values, and can apply patches back to the typed value.
11283
+ *
9094
11284
  * @category JsonPatch
9095
11285
  * @since 4.0.0
9096
11286
  */
9097
11287
  export function toDifferJsonPatch<T, E>(schema: Codec<T, E>): Differ<T, JsonPatch.JsonPatch> {
9098
- const serializer = toCodecJson(schema) as Codec<T, Json, never, never> // TODO: remove this cast
11288
+ const serializer = toCodecJson(schema)
9099
11289
  const get = Parser.encodeSync(serializer)
9100
11290
  const set = Parser.decodeSync(serializer)
9101
11291
  return {
@@ -9117,6 +11307,9 @@ export function toDifferJsonPatch<T, E>(schema: Codec<T, E>): Differ<T, JsonPatc
9117
11307
  export type Tree<Node> = Node | TreeRecord<Node> | ReadonlyArray<Tree<Node>>
9118
11308
 
9119
11309
  /**
11310
+ * A record node in a {@link Tree}: an object mapping string keys to child
11311
+ * `Tree` nodes.
11312
+ *
9120
11313
  * @category Tree
9121
11314
  * @since 4.0.0
9122
11315
  */
@@ -9125,6 +11318,10 @@ export interface TreeRecord<A> {
9125
11318
  }
9126
11319
 
9127
11320
  /**
11321
+ * Creates a recursive schema for a {@link Tree} of values described by `node`.
11322
+ * The resulting schema accepts a single node value, an array of trees, or an
11323
+ * object whose values are trees.
11324
+ *
9128
11325
  * @category Tree
9129
11326
  * @since 4.0.0
9130
11327
  */
@@ -9144,18 +11341,27 @@ export function Tree<S extends Top>(node: S) {
9144
11341
  }
9145
11342
 
9146
11343
  /**
11344
+ * Recursive TypeScript type for any valid immutable JSON value: `null`,
11345
+ * `number`, `boolean`, `string`, a readonly array of `Json` values, or a
11346
+ * readonly record of `string → Json`. For the corresponding schema, see the
11347
+ * {@link Json} const.
11348
+ *
9147
11349
  * @category JSON
9148
11350
  * @since 4.0.0
9149
11351
  */
9150
11352
  export type Json = null | number | boolean | string | JsonArray | JsonObject
9151
11353
 
9152
11354
  /**
11355
+ * A readonly array of {@link Json} values.
11356
+ *
9153
11357
  * @category JSON
9154
11358
  * @since 4.0.0
9155
11359
  */
9156
11360
  export interface JsonArray extends ReadonlyArray<Json> {}
9157
11361
 
9158
11362
  /**
11363
+ * A readonly record whose values are {@link Json} values.
11364
+ *
9159
11365
  * @category JSON
9160
11366
  * @since 4.0.0
9161
11367
  */
@@ -9164,6 +11370,17 @@ export interface JsonObject {
9164
11370
  }
9165
11371
 
9166
11372
  /**
11373
+ * Schema that accepts and validates any immutable JSON-compatible value.
11374
+ *
11375
+ * **Example** (Validating a JSON value)
11376
+ *
11377
+ * ```ts
11378
+ * import { Schema } from "effect"
11379
+ *
11380
+ * const result = Schema.decodeUnknownOption(Schema.Json)({ key: [1, true, null] })
11381
+ * console.log(result._tag) // "Some"
11382
+ * ```
11383
+ *
9167
11384
  * @category JSON
9168
11385
  * @since 4.0.0
9169
11386
  */
@@ -9176,12 +11393,16 @@ export const Json: Codec<Json> = make(AST.Json)
9176
11393
  export type MutableJson = null | number | boolean | string | MutableJsonArray | MutableJsonObject
9177
11394
 
9178
11395
  /**
11396
+ * A mutable array of {@link MutableJson} values.
11397
+ *
9179
11398
  * @category JSON
9180
11399
  * @since 4.0.0
9181
11400
  */
9182
11401
  export interface MutableJsonArray extends Array<MutableJson> {}
9183
11402
 
9184
11403
  /**
11404
+ * A mutable record whose values are {@link MutableJson} values.
11405
+ *
9185
11406
  * @category JSON
9186
11407
  * @since 4.0.0
9187
11408
  */
@@ -9190,6 +11411,9 @@ export interface MutableJsonObject {
9190
11411
  }
9191
11412
 
9192
11413
  /**
11414
+ * Schema that accepts any mutable JSON-compatible value. See {@link Json} for
11415
+ * the immutable variant.
11416
+ *
9193
11417
  * @category JSON
9194
11418
  * @since 4.0.0
9195
11419
  */
@@ -9210,6 +11434,13 @@ export function resolveInto<S extends Top>(schema: S): S["~annotate.in"] | undef
9210
11434
  }
9211
11435
 
9212
11436
  /**
11437
+ * The `Annotations` namespace groups all annotation interfaces used to attach
11438
+ * metadata to schemas. Annotations control documentation, validation messages,
11439
+ * JSON Schema generation, equivalence, arbitrary generation, and more.
11440
+ *
11441
+ * Use {@link resolveInto} to read the annotations attached to a schema at
11442
+ * runtime.
11443
+ *
9213
11444
  * @since 4.0.0
9214
11445
  */
9215
11446
  export declare namespace Annotations {
@@ -9259,6 +11490,9 @@ export declare namespace Annotations {
9259
11490
  }
9260
11491
 
9261
11492
  /**
11493
+ * Annotations shared by all schema nodes. These map to common JSON Schema /
11494
+ * OpenAPI fields: `title`, `description`, `format`, etc.
11495
+ *
9262
11496
  * @since 4.0.0
9263
11497
  */
9264
11498
  export interface Augment extends Annotations {
@@ -9274,6 +11508,8 @@ export declare namespace Annotations {
9274
11508
  }
9275
11509
 
9276
11510
  /**
11511
+ * Extends {@link Augment} with type-parametric `default` and `examples` fields.
11512
+ *
9277
11513
  * @since 4.0.0
9278
11514
  */
9279
11515
  export interface Documentation<T> extends Augment {
@@ -9282,6 +11518,10 @@ export declare namespace Annotations {
9282
11518
  }
9283
11519
 
9284
11520
  /**
11521
+ * Annotations for struct property schemas. Extends {@link Documentation}
11522
+ * with an optional `messageMissingKey` to override the error message when
11523
+ * the property key is absent during decoding.
11524
+ *
9285
11525
  * @category Model
9286
11526
  * @since 4.0.0
9287
11527
  */
@@ -9293,6 +11533,11 @@ export declare namespace Annotations {
9293
11533
  }
9294
11534
 
9295
11535
  /**
11536
+ * Base annotations shared by all composite schema nodes. Extends
11537
+ * {@link Documentation} with error messages, branding, parse options, and
11538
+ * arbitrary generation hooks. {@link Declaration} and other annotation
11539
+ * interfaces build on top of this.
11540
+ *
9296
11541
  * @category Model
9297
11542
  * @since 4.0.0
9298
11543
  */
@@ -9339,6 +11584,12 @@ export declare namespace Annotations {
9339
11584
  }
9340
11585
 
9341
11586
  /**
11587
+ * Full annotation set for `Declaration` schema nodes — used when defining
11588
+ * custom, opaque schema types via `Schema.declare`. Extends {@link Bottom}
11589
+ * with optional codec, arbitrary, equivalence, and formatter hooks so that
11590
+ * derived capabilities (JSON encoding, property testing, etc.) can be
11591
+ * provided for the custom type.
11592
+ *
9342
11593
  * @category Model
9343
11594
  * @since 4.0.0
9344
11595
  */
@@ -9375,10 +11626,9 @@ export declare namespace Annotations {
9375
11626
  }
9376
11627
 
9377
11628
  /**
9378
- * **Technical Note**
9379
- *
9380
- * This annotation group is not parametric since it would make the filters
9381
- * invariant
11629
+ * Annotations for filter schema nodes (created via `Schema.filter`). Extends
11630
+ * {@link Augment} with an optional error message, identifier, and metadata.
11631
+ * Filters are intentionally non-parametric to keep them covariant.
9382
11632
  *
9383
11633
  * @category Model
9384
11634
  * @since 4.0.0