effect 4.0.0-beta.6 → 4.0.0-beta.8

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 (283) hide show
  1. package/dist/Cache.d.ts +2 -2
  2. package/dist/Cache.d.ts.map +1 -1
  3. package/dist/Cache.js +1 -1
  4. package/dist/Cache.js.map +1 -1
  5. package/dist/Combiner.d.ts +280 -13
  6. package/dist/Combiner.d.ts.map +1 -1
  7. package/dist/Combiner.js +198 -7
  8. package/dist/Combiner.js.map +1 -1
  9. package/dist/Config.d.ts +2 -2
  10. package/dist/Config.js +3 -3
  11. package/dist/Config.js.map +1 -1
  12. package/dist/DateTime.d.ts +23 -161
  13. package/dist/DateTime.d.ts.map +1 -1
  14. package/dist/DateTime.js +6 -51
  15. package/dist/DateTime.js.map +1 -1
  16. package/dist/Duration.d.ts +12 -12
  17. package/dist/Duration.d.ts.map +1 -1
  18. package/dist/Duration.js +12 -12
  19. package/dist/Duration.js.map +1 -1
  20. package/dist/Effect.d.ts +13 -13
  21. package/dist/Effect.d.ts.map +1 -1
  22. package/dist/Effect.js +1 -1
  23. package/dist/Effect.js.map +1 -1
  24. package/dist/Formatter.d.ts +131 -47
  25. package/dist/Formatter.d.ts.map +1 -1
  26. package/dist/Formatter.js +228 -50
  27. package/dist/Formatter.js.map +1 -1
  28. package/dist/JsonSchema.d.ts +299 -10
  29. package/dist/JsonSchema.d.ts.map +1 -1
  30. package/dist/JsonSchema.js +323 -4
  31. package/dist/JsonSchema.js.map +1 -1
  32. package/dist/LayerMap.d.ts +4 -4
  33. package/dist/LayerMap.d.ts.map +1 -1
  34. package/dist/LogLevel.d.ts +27 -0
  35. package/dist/LogLevel.d.ts.map +1 -1
  36. package/dist/LogLevel.js +28 -100
  37. package/dist/LogLevel.js.map +1 -1
  38. package/dist/Logger.d.ts +4 -4
  39. package/dist/Logger.d.ts.map +1 -1
  40. package/dist/Metric.d.ts +2 -2
  41. package/dist/Metric.d.ts.map +1 -1
  42. package/dist/Metric.js +1 -1
  43. package/dist/Metric.js.map +1 -1
  44. package/dist/Pool.d.ts +1 -1
  45. package/dist/Pool.d.ts.map +1 -1
  46. package/dist/Pool.js +1 -1
  47. package/dist/Pool.js.map +1 -1
  48. package/dist/Random.d.ts +1 -1
  49. package/dist/Random.d.ts.map +1 -1
  50. package/dist/Random.js +3 -12
  51. package/dist/Random.js.map +1 -1
  52. package/dist/RcMap.d.ts +2 -2
  53. package/dist/RcMap.d.ts.map +1 -1
  54. package/dist/RcMap.js +1 -1
  55. package/dist/RcMap.js.map +1 -1
  56. package/dist/RcRef.d.ts +1 -1
  57. package/dist/RcRef.d.ts.map +1 -1
  58. package/dist/Reducer.d.ts +166 -7
  59. package/dist/Reducer.d.ts.map +1 -1
  60. package/dist/Reducer.js +135 -1
  61. package/dist/Reducer.js.map +1 -1
  62. package/dist/RequestResolver.d.ts +6 -6
  63. package/dist/RequestResolver.d.ts.map +1 -1
  64. package/dist/RequestResolver.js.map +1 -1
  65. package/dist/Schedule.d.ts +20 -11
  66. package/dist/Schedule.d.ts.map +1 -1
  67. package/dist/Schedule.js +23 -9
  68. package/dist/Schedule.js.map +1 -1
  69. package/dist/Schema.d.ts +4 -4
  70. package/dist/Schema.d.ts.map +1 -1
  71. package/dist/ScopedCache.d.ts +2 -2
  72. package/dist/ScopedCache.d.ts.map +1 -1
  73. package/dist/ScopedCache.js +1 -1
  74. package/dist/ScopedCache.js.map +1 -1
  75. package/dist/Stream.d.ts +19 -19
  76. package/dist/Stream.d.ts.map +1 -1
  77. package/dist/Stream.js +3 -3
  78. package/dist/Stream.js.map +1 -1
  79. package/dist/index.d.ts +258 -0
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +258 -0
  82. package/dist/index.js.map +1 -1
  83. package/dist/internal/dateTime.js +3 -11
  84. package/dist/internal/dateTime.js.map +1 -1
  85. package/dist/internal/effect.js +2 -2
  86. package/dist/internal/effect.js.map +1 -1
  87. package/dist/internal/random.d.ts +2 -0
  88. package/dist/internal/random.d.ts.map +1 -0
  89. package/dist/internal/random.js +13 -0
  90. package/dist/internal/random.js.map +1 -0
  91. package/dist/internal/rcRef.js +1 -1
  92. package/dist/internal/rcRef.js.map +1 -1
  93. package/dist/testing/TestClock.d.ts +4 -4
  94. package/dist/testing/TestClock.d.ts.map +1 -1
  95. package/dist/testing/TestClock.js +1 -1
  96. package/dist/testing/TestClock.js.map +1 -1
  97. package/dist/testing/TestSchema.d.ts +6 -6
  98. package/dist/testing/TestSchema.d.ts.map +1 -1
  99. package/dist/unstable/ai/AiError.d.ts +10 -10
  100. package/dist/unstable/ai/AiError.d.ts.map +1 -1
  101. package/dist/unstable/ai/Chat.d.ts +3 -3
  102. package/dist/unstable/ai/Chat.d.ts.map +1 -1
  103. package/dist/unstable/ai/Chat.js +2 -2
  104. package/dist/unstable/ai/Chat.js.map +1 -1
  105. package/dist/unstable/ai/LanguageModel.d.ts +2 -2
  106. package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
  107. package/dist/unstable/ai/McpServer.d.ts +1 -1
  108. package/dist/unstable/ai/McpServer.d.ts.map +1 -1
  109. package/dist/unstable/ai/McpServer.js.map +1 -1
  110. package/dist/unstable/ai/Prompt.d.ts +17 -17
  111. package/dist/unstable/ai/Prompt.d.ts.map +1 -1
  112. package/dist/unstable/ai/Response.d.ts +23 -23
  113. package/dist/unstable/ai/Response.d.ts.map +1 -1
  114. package/dist/unstable/ai/Response.js +1 -1
  115. package/dist/unstable/ai/Response.js.map +1 -1
  116. package/dist/unstable/cluster/ClusterCron.d.ts +1 -1
  117. package/dist/unstable/cluster/ClusterCron.d.ts.map +1 -1
  118. package/dist/unstable/cluster/ClusterCron.js +1 -1
  119. package/dist/unstable/cluster/ClusterCron.js.map +1 -1
  120. package/dist/unstable/cluster/Entity.d.ts +3 -3
  121. package/dist/unstable/cluster/Entity.d.ts.map +1 -1
  122. package/dist/unstable/cluster/EntityResource.d.ts +2 -2
  123. package/dist/unstable/cluster/EntityResource.d.ts.map +1 -1
  124. package/dist/unstable/cluster/K8sHttpClient.js +1 -1
  125. package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
  126. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  127. package/dist/unstable/cluster/Sharding.d.ts +2 -2
  128. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  129. package/dist/unstable/cluster/Sharding.js +1 -1
  130. package/dist/unstable/cluster/Sharding.js.map +1 -1
  131. package/dist/unstable/cluster/ShardingConfig.d.ts +21 -21
  132. package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
  133. package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
  134. package/dist/unstable/cluster/SqlRunnerStorage.js +1 -1
  135. package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
  136. package/dist/unstable/cluster/internal/entityManager.js +1 -1
  137. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  138. package/dist/unstable/encoding/Sse.d.ts +2 -2
  139. package/dist/unstable/encoding/Sse.d.ts.map +1 -1
  140. package/dist/unstable/encoding/Sse.js.map +1 -1
  141. package/dist/unstable/http/Cookies.d.ts +1 -1
  142. package/dist/unstable/http/Cookies.d.ts.map +1 -1
  143. package/dist/unstable/http/Cookies.js +2 -2
  144. package/dist/unstable/http/Cookies.js.map +1 -1
  145. package/dist/unstable/http/HttpClient.d.ts +4 -4
  146. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  147. package/dist/unstable/http/HttpClientRequest.d.ts +11 -11
  148. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  149. package/dist/unstable/http/HttpClientRequest.js +8 -1
  150. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  151. package/dist/unstable/http/HttpMethod.d.ts +4 -4
  152. package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
  153. package/dist/unstable/http/HttpMethod.js +3 -3
  154. package/dist/unstable/http/HttpMethod.js.map +1 -1
  155. package/dist/unstable/observability/Otlp.d.ts +12 -12
  156. package/dist/unstable/observability/Otlp.d.ts.map +1 -1
  157. package/dist/unstable/observability/OtlpExporter.d.ts +2 -2
  158. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  159. package/dist/unstable/observability/OtlpExporter.js +1 -1
  160. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  161. package/dist/unstable/observability/OtlpLogger.d.ts +4 -4
  162. package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
  163. package/dist/unstable/observability/OtlpMetrics.d.ts +4 -4
  164. package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
  165. package/dist/unstable/observability/OtlpTracer.d.ts +4 -4
  166. package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
  167. package/dist/unstable/persistence/Persistable.d.ts +2 -2
  168. package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
  169. package/dist/unstable/persistence/PersistedQueue.d.ts +12 -12
  170. package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
  171. package/dist/unstable/persistence/PersistedQueue.js +6 -6
  172. package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
  173. package/dist/unstable/persistence/Persistence.d.ts +1 -1
  174. package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
  175. package/dist/unstable/persistence/Persistence.js +2 -2
  176. package/dist/unstable/persistence/Persistence.js.map +1 -1
  177. package/dist/unstable/persistence/RateLimiter.d.ts +3 -3
  178. package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
  179. package/dist/unstable/persistence/RateLimiter.js +1 -1
  180. package/dist/unstable/persistence/RateLimiter.js.map +1 -1
  181. package/dist/unstable/process/ChildProcess.d.ts +2 -2
  182. package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
  183. package/dist/unstable/reactivity/Atom.d.ts +6 -6
  184. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  185. package/dist/unstable/reactivity/Atom.js +3 -3
  186. package/dist/unstable/reactivity/Atom.js.map +1 -1
  187. package/dist/unstable/reactivity/AtomHttpApi.d.ts +1 -1
  188. package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
  189. package/dist/unstable/reactivity/AtomHttpApi.js +1 -1
  190. package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
  191. package/dist/unstable/reactivity/AtomRpc.d.ts +1 -1
  192. package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
  193. package/dist/unstable/reactivity/AtomRpc.js +1 -1
  194. package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
  195. package/dist/unstable/rpc/Rpc.d.ts +2 -2
  196. package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
  197. package/dist/unstable/rpc/RpcClient.d.ts +5 -26
  198. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  199. package/dist/unstable/rpc/RpcClient.js +3 -11
  200. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  201. package/dist/unstable/socket/Socket.d.ts +4 -4
  202. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  203. package/dist/unstable/sql/SqlModel.d.ts +2 -2
  204. package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
  205. package/dist/unstable/sql/SqlModel.js +3 -3
  206. package/dist/unstable/sql/SqlModel.js.map +1 -1
  207. package/dist/unstable/sql/SqlSchema.d.ts +16 -5
  208. package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
  209. package/dist/unstable/sql/SqlSchema.js +17 -7
  210. package/dist/unstable/sql/SqlSchema.js.map +1 -1
  211. package/dist/unstable/workflow/DurableClock.d.ts +3 -3
  212. package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
  213. package/dist/unstable/workflow/DurableClock.js +3 -3
  214. package/dist/unstable/workflow/DurableClock.js.map +1 -1
  215. package/package.json +1 -1
  216. package/src/Cache.ts +3 -3
  217. package/src/Combiner.ts +280 -13
  218. package/src/Config.ts +3 -3
  219. package/src/DateTime.ts +24 -164
  220. package/src/Duration.ts +15 -15
  221. package/src/Effect.ts +15 -15
  222. package/src/Formatter.ts +252 -50
  223. package/src/JsonSchema.ts +383 -10
  224. package/src/LayerMap.ts +5 -5
  225. package/src/LogLevel.ts +31 -0
  226. package/src/Logger.ts +5 -5
  227. package/src/Metric.ts +4 -4
  228. package/src/Pool.ts +4 -4
  229. package/src/Random.ts +5 -14
  230. package/src/RcMap.ts +5 -5
  231. package/src/RcRef.ts +1 -1
  232. package/src/Reducer.ts +166 -7
  233. package/src/RequestResolver.ts +9 -9
  234. package/src/Schedule.ts +44 -25
  235. package/src/Schema.ts +4 -4
  236. package/src/ScopedCache.ts +3 -3
  237. package/src/Stream.ts +34 -34
  238. package/src/index.ts +258 -0
  239. package/src/internal/dateTime.ts +9 -30
  240. package/src/internal/effect.ts +21 -21
  241. package/src/internal/random.ts +20 -0
  242. package/src/internal/rcRef.ts +2 -2
  243. package/src/testing/TestClock.ts +5 -5
  244. package/src/testing/TestSchema.ts +8 -8
  245. package/src/unstable/ai/AiError.ts +1 -1
  246. package/src/unstable/ai/Chat.ts +10 -10
  247. package/src/unstable/ai/LanguageModel.ts +3 -3
  248. package/src/unstable/ai/McpServer.ts +2 -2
  249. package/src/unstable/ai/Prompt.ts +17 -17
  250. package/src/unstable/ai/Response.ts +23 -23
  251. package/src/unstable/cluster/ClusterCron.ts +2 -2
  252. package/src/unstable/cluster/Entity.ts +5 -5
  253. package/src/unstable/cluster/EntityResource.ts +4 -4
  254. package/src/unstable/cluster/K8sHttpClient.ts +1 -1
  255. package/src/unstable/cluster/MessageStorage.ts +1 -4
  256. package/src/unstable/cluster/Sharding.ts +3 -3
  257. package/src/unstable/cluster/ShardingConfig.ts +10 -11
  258. package/src/unstable/cluster/SqlRunnerStorage.ts +1 -1
  259. package/src/unstable/cluster/internal/entityManager.ts +3 -3
  260. package/src/unstable/encoding/Sse.ts +2 -4
  261. package/src/unstable/http/Cookies.ts +3 -3
  262. package/src/unstable/http/HttpClient.ts +4 -4
  263. package/src/unstable/http/HttpClientRequest.ts +15 -11
  264. package/src/unstable/http/HttpMethod.ts +16 -4
  265. package/src/unstable/observability/Otlp.ts +12 -12
  266. package/src/unstable/observability/OtlpExporter.ts +3 -3
  267. package/src/unstable/observability/OtlpLogger.ts +4 -4
  268. package/src/unstable/observability/OtlpMetrics.ts +4 -4
  269. package/src/unstable/observability/OtlpTracer.ts +4 -4
  270. package/src/unstable/persistence/Persistable.ts +2 -2
  271. package/src/unstable/persistence/PersistedQueue.ts +18 -18
  272. package/src/unstable/persistence/Persistence.ts +3 -3
  273. package/src/unstable/persistence/RateLimiter.ts +4 -4
  274. package/src/unstable/process/ChildProcess.ts +2 -2
  275. package/src/unstable/reactivity/Atom.ts +13 -13
  276. package/src/unstable/reactivity/AtomHttpApi.ts +3 -3
  277. package/src/unstable/reactivity/AtomRpc.ts +3 -3
  278. package/src/unstable/rpc/Rpc.ts +3 -3
  279. package/src/unstable/rpc/RpcClient.ts +8 -51
  280. package/src/unstable/socket/Socket.ts +4 -4
  281. package/src/unstable/sql/SqlModel.ts +5 -5
  282. package/src/unstable/sql/SqlSchema.ts +41 -25
  283. package/src/unstable/workflow/DurableClock.ts +8 -8
package/src/Combiner.ts CHANGED
@@ -1,16 +1,92 @@
1
1
  /**
2
+ * A module for combining two values of the same type into one.
3
+ *
4
+ * A `Combiner<A>` wraps a single binary function `(self: A, that: A) => A`.
5
+ * It describes *how* two values merge but carries no initial/empty value
6
+ * (for that, see {@link Reducer} which extends `Combiner` with an
7
+ * `initialValue`).
8
+ *
9
+ * ## Mental model
10
+ *
11
+ * - **Combiner** – an object with a `combine(self, that)` method that returns
12
+ * a value of the same type.
13
+ * - **Argument order** – `self` is the "left" / accumulator side, `that` is
14
+ * the "right" / incoming side.
15
+ * - **No identity element** – unlike a monoid, a `Combiner` does not require
16
+ * a neutral element. Use {@link Reducer} when you need one.
17
+ * - **Purity** – all combiners produced by this module are pure; they never
18
+ * mutate their arguments.
19
+ * - **Composability** – combiners can be lifted into `Option`, `Struct`,
20
+ * `Tuple`, and other container types via helpers in those modules.
21
+ *
22
+ * ## Common tasks
23
+ *
24
+ * - Create a combiner from any binary function → {@link make}
25
+ * - Swap argument order → {@link flip}
26
+ * - Pick the smaller / larger of two values → {@link min} / {@link max}
27
+ * - Always keep the first or last value → {@link first} / {@link last}
28
+ * - Ignore both values and return a fixed result → {@link constant}
29
+ * - Insert a separator between combined values → {@link intercalate}
30
+ *
31
+ * ## Gotchas
32
+ *
33
+ * - `min` and `max` require an `Order<A>`, not a raw comparator. Import from
34
+ * e.g. `Number.Order` or `String.Order`.
35
+ * - `intercalate` is curried: call it with the separator first, then pass the
36
+ * base combiner.
37
+ * - A `Reducer` (which adds `initialValue`) is also a valid `Combiner` — you
38
+ * can pass a `Reducer` anywhere a `Combiner` is expected.
39
+ *
40
+ * ## Quickstart
41
+ *
42
+ * **Example** (combining strings with a separator)
43
+ *
44
+ * ```ts
45
+ * import { Combiner, String } from "effect"
46
+ *
47
+ * const csv = Combiner.intercalate(",")(String.ReducerConcat)
48
+ *
49
+ * console.log(csv.combine("a", "b"))
50
+ * // Output: "a,b"
51
+ *
52
+ * console.log(csv.combine(csv.combine("a", "b"), "c"))
53
+ * // Output: "a,b,c"
54
+ * ```
55
+ *
56
+ * ## See also
57
+ *
58
+ * - {@link make} – the primary constructor
59
+ * - {@link Combiner} – the core interface
60
+ *
2
61
  * @since 4.0.0
3
62
  */
4
63
  import type * as Order from "./Order.ts"
5
64
 
6
65
  /**
7
- * A `Combiner` represents any type of value that can be combined
8
- * with another value of the same type to produce a new value.
66
+ * Represents a strategy for combining two values of the same type `A`.
67
+ *
68
+ * A `Combiner` contains a single `combine` method that takes two values and
69
+ * returns a merged result. It does not include an identity/empty value; use
70
+ * `Reducer` when you need one.
71
+ *
72
+ * When to use:
73
+ * - You need to describe how two values of the same type merge.
74
+ * - You want to pass a reusable combining strategy to library functions like
75
+ * `Struct.makeCombiner` or `Option.makeCombinerFailFast`.
76
+ * - You are building a `Reducer` and need to define the combining step first.
77
+ *
78
+ * **Example** (number addition combiner)
79
+ *
80
+ * ```ts
81
+ * import { Combiner } from "effect"
82
+ *
83
+ * const Sum = Combiner.make<number>((self, that) => self + that)
9
84
  *
10
- * Examples:
11
- * - numbers with addition
12
- * - strings with concatenation
13
- * - arrays with merging
85
+ * console.log(Sum.combine(3, 4))
86
+ * // Output: 7
87
+ * ```
88
+ *
89
+ * @see {@link make} – create a `Combiner` from a function
14
90
  *
15
91
  * @category model
16
92
  * @since 4.0.0
@@ -23,7 +99,29 @@ export interface Combiner<A> {
23
99
  }
24
100
 
25
101
  /**
26
- * Creates a `Combiner` from a `combine` function.
102
+ * Creates a `Combiner` from a binary function.
103
+ *
104
+ * When to use:
105
+ * - You have a custom combining operation that is not covered by the built-in
106
+ * constructors (`min`, `max`, `first`, `last`, `constant`).
107
+ *
108
+ * Behavior:
109
+ * - Returns a new `Combiner` whose `combine` method delegates to the provided
110
+ * function.
111
+ * - Pure – the returned combiner does not mutate its arguments.
112
+ *
113
+ * **Example** (multiplying numbers)
114
+ *
115
+ * ```ts
116
+ * import { Combiner } from "effect"
117
+ *
118
+ * const Product = Combiner.make<number>((self, that) => self * that)
119
+ *
120
+ * console.log(Product.combine(3, 5))
121
+ * // Output: 15
122
+ * ```
123
+ *
124
+ * @see {@link Combiner} – the interface this creates
27
125
  *
28
126
  * @since 4.0.0
29
127
  */
@@ -32,6 +130,31 @@ export function make<A>(combine: (self: A, that: A) => A): Combiner<A> {
32
130
  }
33
131
 
34
132
  /**
133
+ * Reverses the argument order of a combiner's `combine` method.
134
+ *
135
+ * When to use:
136
+ * - You need the "right" value to act as the accumulator side.
137
+ * - You want to reverse the natural direction of a non-commutative combiner
138
+ * (e.g. string concatenation).
139
+ *
140
+ * Behavior:
141
+ * - Returns a new `Combiner` where `combine(self, that)` calls the original
142
+ * combiner as `combine(that, self)`.
143
+ * - Does not mutate the input combiner.
144
+ *
145
+ * **Example** (reversing string concatenation)
146
+ *
147
+ * ```ts
148
+ * import { Combiner, String } from "effect"
149
+ *
150
+ * const Prepend = Combiner.flip(String.ReducerConcat)
151
+ *
152
+ * console.log(Prepend.combine("a", "b"))
153
+ * // Output: "ba"
154
+ * ```
155
+ *
156
+ * @see {@link make}
157
+ *
35
158
  * @since 4.0.0
36
159
  */
37
160
  export function flip<A>(combiner: Combiner<A>): Combiner<A> {
@@ -39,7 +162,33 @@ export function flip<A>(combiner: Combiner<A>): Combiner<A> {
39
162
  }
40
163
 
41
164
  /**
42
- * Creates a `Combiner` that returns the smaller of two values.
165
+ * Creates a `Combiner` that returns the smaller of two values according to
166
+ * the provided `Order`.
167
+ *
168
+ * When to use:
169
+ * - You want to accumulate the minimum value across a collection.
170
+ * - You are building a `Reducer` that tracks the running minimum.
171
+ *
172
+ * Behavior:
173
+ * - Compares using the given `Order`. When values are equal, returns `that`
174
+ * (the second argument).
175
+ * - Pure – does not mutate either argument.
176
+ *
177
+ * **Example** (minimum of two numbers)
178
+ *
179
+ * ```ts
180
+ * import { Combiner, Number } from "effect"
181
+ *
182
+ * const Min = Combiner.min(Number.Order)
183
+ *
184
+ * console.log(Min.combine(3, 1))
185
+ * // Output: 1
186
+ *
187
+ * console.log(Min.combine(1, 3))
188
+ * // Output: 1
189
+ * ```
190
+ *
191
+ * @see {@link max}
43
192
  *
44
193
  * @since 4.0.0
45
194
  */
@@ -48,7 +197,33 @@ export function min<A>(order: Order.Order<A>): Combiner<A> {
48
197
  }
49
198
 
50
199
  /**
51
- * Creates a `Combiner` that returns the larger of two values.
200
+ * Creates a `Combiner` that returns the larger of two values according to
201
+ * the provided `Order`.
202
+ *
203
+ * When to use:
204
+ * - You want to accumulate the maximum value across a collection.
205
+ * - You are building a `Reducer` that tracks the running maximum.
206
+ *
207
+ * Behavior:
208
+ * - Compares using the given `Order`. When values are equal, returns `that`
209
+ * (the second argument).
210
+ * - Pure – does not mutate either argument.
211
+ *
212
+ * **Example** (maximum of two numbers)
213
+ *
214
+ * ```ts
215
+ * import { Combiner, Number } from "effect"
216
+ *
217
+ * const Max = Combiner.max(Number.Order)
218
+ *
219
+ * console.log(Max.combine(3, 1))
220
+ * // Output: 3
221
+ *
222
+ * console.log(Max.combine(1, 3))
223
+ * // Output: 3
224
+ * ```
225
+ *
226
+ * @see {@link min}
52
227
  *
53
228
  * @since 4.0.0
54
229
  */
@@ -57,7 +232,29 @@ export function max<A>(order: Order.Order<A>): Combiner<A> {
57
232
  }
58
233
 
59
234
  /**
60
- * Creates a `Combiner` that returns the first value.
235
+ * Creates a `Combiner` that always returns the first (left) argument.
236
+ *
237
+ * When to use:
238
+ * - You want "first write wins" semantics when merging values.
239
+ * - You need a combiner but the combining logic should be a no-op that keeps
240
+ * the existing value.
241
+ *
242
+ * Behavior:
243
+ * - `combine(self, that)` returns `self`, ignoring `that`.
244
+ * - Pure – the second argument is discarded, not mutated.
245
+ *
246
+ * **Example** (keeping the first value)
247
+ *
248
+ * ```ts
249
+ * import { Combiner } from "effect"
250
+ *
251
+ * const First = Combiner.first<number>()
252
+ *
253
+ * console.log(First.combine(1, 2))
254
+ * // Output: 1
255
+ * ```
256
+ *
257
+ * @see {@link last}
61
258
  *
62
259
  * @since 4.0.0
63
260
  */
@@ -66,7 +263,28 @@ export function first<A>(): Combiner<A> {
66
263
  }
67
264
 
68
265
  /**
69
- * Creates a `Combiner` that returns the last value.
266
+ * Creates a `Combiner` that always returns the last (right) argument.
267
+ *
268
+ * When to use:
269
+ * - You want "last write wins" semantics when merging values.
270
+ * - You need a combiner that replaces the accumulator with each new value.
271
+ *
272
+ * Behavior:
273
+ * - `combine(self, that)` returns `that`, ignoring `self`.
274
+ * - Pure – the first argument is discarded, not mutated.
275
+ *
276
+ * **Example** (keeping the last value)
277
+ *
278
+ * ```ts
279
+ * import { Combiner } from "effect"
280
+ *
281
+ * const Last = Combiner.last<number>()
282
+ *
283
+ * console.log(Last.combine(1, 2))
284
+ * // Output: 2
285
+ * ```
286
+ *
287
+ * @see {@link first}
70
288
  *
71
289
  * @since 4.0.0
72
290
  */
@@ -75,7 +293,31 @@ export function last<A>(): Combiner<A> {
75
293
  }
76
294
 
77
295
  /**
78
- * Creates a `Combiner` that returns a constant value.
296
+ * Creates a `Combiner` that ignores both arguments and always returns the
297
+ * given constant value.
298
+ *
299
+ * When to use:
300
+ * - You need a combiner that produces a fixed result regardless of input.
301
+ * - You are providing a combiner to a generic API but the combined value is
302
+ * predetermined.
303
+ *
304
+ * Behavior:
305
+ * - `combine(self, that)` returns the constant `a`, ignoring both arguments.
306
+ * - Pure – no mutation occurs.
307
+ *
308
+ * **Example** (always returning zero)
309
+ *
310
+ * ```ts
311
+ * import { Combiner } from "effect"
312
+ *
313
+ * const Zero = Combiner.constant(0)
314
+ *
315
+ * console.log(Zero.combine(42, 99))
316
+ * // Output: 0
317
+ * ```
318
+ *
319
+ * @see {@link first}
320
+ * @see {@link last}
79
321
  *
80
322
  * @since 4.0.0
81
323
  */
@@ -84,7 +326,32 @@ export function constant<A>(a: A): Combiner<A> {
84
326
  }
85
327
 
86
328
  /**
87
- * Between each pair of elements insert `middle`.
329
+ * Wraps a `Combiner` so that a separator value is inserted between every
330
+ * pair of combined elements.
331
+ *
332
+ * When to use:
333
+ * - You are building delimited strings (CSV, paths, etc.) by repeated
334
+ * combination.
335
+ * - You need to inject a fixed separator between accumulated values.
336
+ *
337
+ * Behavior:
338
+ * - `intercalate(middle)(combiner).combine(self, that)` is equivalent to
339
+ * `combiner.combine(self, combiner.combine(middle, that))`.
340
+ * - Curried: first provide the separator, then the base combiner.
341
+ * - Does not mutate the input combiner; returns a new one.
342
+ *
343
+ * **Example** (joining strings with a separator)
344
+ *
345
+ * ```ts
346
+ * import { Combiner, String } from "effect"
347
+ *
348
+ * const commaSep = Combiner.intercalate(",")(String.ReducerConcat)
349
+ *
350
+ * console.log(commaSep.combine("a", "b"))
351
+ * // Output: "a,b"
352
+ * ```
353
+ *
354
+ * @see {@link make}
88
355
  *
89
356
  * @since 4.0.0
90
357
  */
package/src/Config.ts CHANGED
@@ -938,7 +938,7 @@ export const Boolean = Schema.Literals([...TrueValues.literals, ...FalseValues.l
938
938
  * - Pass to {@link schema} for custom paths, or use the {@link duration}
939
939
  * convenience constructor.
940
940
  *
941
- * Accepts any string that `Duration.fromDurationInput` can parse (e.g.
941
+ * Accepts any string that `Duration.fromInput` can parse (e.g.
942
942
  * `"10 seconds"`, `"500 millis"`).
943
943
  *
944
944
  * @see {@link duration} – convenience constructor
@@ -948,7 +948,7 @@ export const Boolean = Schema.Literals([...TrueValues.literals, ...FalseValues.l
948
948
  */
949
949
  export const Duration = Schema.String.pipe(Schema.decodeTo(Schema.Duration, {
950
950
  decode: Getter.transformOrFail((s) => {
951
- const d = Duration_.fromDurationInput(s as any)
951
+ const d = Duration_.fromInput(s as any)
952
952
  return d ? Effect.succeed(d) : Effect.fail(new Issue.InvalidValue(Option.some(s)))
953
953
  }),
954
954
  encode: Getter.forbidden(() => "Encoding Duration is not supported")
@@ -1235,7 +1235,7 @@ export function boolean(name?: string) {
1235
1235
  *
1236
1236
  * Shortcut for `Config.schema(Config.Duration, name)`.
1237
1237
  *
1238
- * Accepts any string that `Duration.fromDurationInput` can parse (e.g.
1238
+ * Accepts any string that `Duration.fromInput` can parse (e.g.
1239
1239
  * `"10 seconds"`, `"500 millis"`, `"2 minutes"`).
1240
1240
  *
1241
1241
  * **Example** (Reading a duration)
package/src/DateTime.ts CHANGED
@@ -12,7 +12,6 @@ import { provideService } from "./internal/effect.ts"
12
12
  import * as Layer from "./Layer.ts"
13
13
  import type * as order from "./Order.ts"
14
14
  import type { Pipeable } from "./Pipeable.ts"
15
- import type * as Result from "./Result.ts"
16
15
  import * as ServiceMap from "./ServiceMap.ts"
17
16
 
18
17
  const TypeId = Internal.TypeId
@@ -1174,10 +1173,12 @@ export const setZoneNamedUnsafe: {
1174
1173
  // =============================================================================
1175
1174
 
1176
1175
  /**
1177
- * Calulate the difference between two `DateTime` values, returning the number
1178
- * of milliseconds the `other` DateTime is from `self`.
1176
+ * Calulate the difference between two `DateTime` values, returning a
1177
+ * `Duration` representing the amount of time between them.
1179
1178
  *
1180
- * If `other` is *after* `self`, the result will be a positive number.
1179
+ * If `other` is *after* `self`, the result will be a positive `Duration`. If
1180
+ * `other` is *before* `self`, the result will be a negative `Duration`. If they
1181
+ * are equal, the result will be a `Duration` of zero.
1181
1182
  *
1182
1183
  * @since 3.6.0
1183
1184
  * @category comparisons
@@ -1189,7 +1190,7 @@ export const setZoneNamedUnsafe: {
1189
1190
  * const now = yield* DateTime.now
1190
1191
  * const other = DateTime.add(now, { minutes: 1 })
1191
1192
  *
1192
- * // returns 60000
1193
+ * // returns Duration.minutes(1)
1193
1194
  * DateTime.distance(now, other)
1194
1195
  * })
1195
1196
  * ```
@@ -1200,10 +1201,12 @@ export const distance: {
1200
1201
  // =============================================================================
1201
1202
 
1202
1203
  /**
1203
- * Calulate the difference between two `DateTime` values, returning the number
1204
- * of milliseconds the `other` DateTime is from `self`.
1204
+ * Calulate the difference between two `DateTime` values, returning a
1205
+ * `Duration` representing the amount of time between them.
1205
1206
  *
1206
- * If `other` is *after* `self`, the result will be a positive number.
1207
+ * If `other` is *after* `self`, the result will be a positive `Duration`. If
1208
+ * `other` is *before* `self`, the result will be a negative `Duration`. If they
1209
+ * are equal, the result will be a `Duration` of zero.
1207
1210
  *
1208
1211
  * @since 3.6.0
1209
1212
  * @category comparisons
@@ -1215,147 +1218,23 @@ export const distance: {
1215
1218
  * const now = yield* DateTime.now
1216
1219
  * const other = DateTime.add(now, { minutes: 1 })
1217
1220
  *
1218
- * // returns 60000
1221
+ * // returns Duration.minutes(1)
1219
1222
  * DateTime.distance(now, other)
1220
1223
  * })
1221
1224
  * ```
1222
1225
  */
1223
- (other: DateTime): (self: DateTime) => number
1226
+ (other: DateTime): (self: DateTime) => Duration.Duration
1224
1227
  // =============================================================================
1225
1228
  // comparisons
1226
1229
  // =============================================================================
1227
1230
 
1228
1231
  /**
1229
- * Calulate the difference between two `DateTime` values, returning the number
1230
- * of milliseconds the `other` DateTime is from `self`.
1231
- *
1232
- * If `other` is *after* `self`, the result will be a positive number.
1233
- *
1234
- * @since 3.6.0
1235
- * @category comparisons
1236
- * @example
1237
- * ```ts
1238
- * import { DateTime, Effect } from "effect"
1239
- *
1240
- * Effect.gen(function*() {
1241
- * const now = yield* DateTime.now
1242
- * const other = DateTime.add(now, { minutes: 1 })
1243
- *
1244
- * // returns 60000
1245
- * DateTime.distance(now, other)
1246
- * })
1247
- * ```
1248
- */
1249
- (self: DateTime, other: DateTime): number
1250
- } = Internal.distance
1251
-
1252
- /**
1253
- * Calulate the difference between two `DateTime` values.
1254
- *
1255
- * If the `other` DateTime is before `self`, the result will be a negative
1256
- * `Duration`, returned as a `Failure`.
1257
- *
1258
- * If the `other` DateTime is after `self`, the result will be a positive
1259
- * `Duration`, returned as a `Success`.
1260
- *
1261
- * @since 3.6.0
1262
- * @category comparisons
1263
- * @example
1264
- * ```ts
1265
- * import { DateTime, Effect } from "effect"
1266
- *
1267
- * Effect.gen(function*() {
1268
- * const now = yield* DateTime.now
1269
- * const other = DateTime.add(now, { minutes: 1 })
1270
- *
1271
- * // returns Result.succeed(Duration.minutes(1))
1272
- * DateTime.distanceDurationResult(now, other)
1273
- *
1274
- * // returns Result.fail(Duration.minutes(1))
1275
- * DateTime.distanceDurationResult(other, now)
1276
- * })
1277
- * ```
1278
- */
1279
- export const distanceDurationResult: {
1280
- /**
1281
- * Calulate the difference between two `DateTime` values.
1282
- *
1283
- * If the `other` DateTime is before `self`, the result will be a negative
1284
- * `Duration`, returned as a `Failure`.
1232
+ * Calulate the difference between two `DateTime` values, returning a
1233
+ * `Duration` representing the amount of time between them.
1285
1234
  *
1286
- * If the `other` DateTime is after `self`, the result will be a positive
1287
- * `Duration`, returned as a `Success`.
1288
- *
1289
- * @since 3.6.0
1290
- * @category comparisons
1291
- * @example
1292
- * ```ts
1293
- * import { DateTime, Effect } from "effect"
1294
- *
1295
- * Effect.gen(function*() {
1296
- * const now = yield* DateTime.now
1297
- * const other = DateTime.add(now, { minutes: 1 })
1298
- *
1299
- * // returns Result.succeed(Duration.minutes(1))
1300
- * DateTime.distanceDurationResult(now, other)
1301
- *
1302
- * // returns Result.fail(Duration.minutes(1))
1303
- * DateTime.distanceDurationResult(other, now)
1304
- * })
1305
- * ```
1306
- */
1307
- (other: DateTime): (self: DateTime) => Result.Result<Duration.Duration, Duration.Duration>
1308
- /**
1309
- * Calulate the difference between two `DateTime` values.
1310
- *
1311
- * If the `other` DateTime is before `self`, the result will be a negative
1312
- * `Duration`, returned as a `Failure`.
1313
- *
1314
- * If the `other` DateTime is after `self`, the result will be a positive
1315
- * `Duration`, returned as a `Success`.
1316
- *
1317
- * @since 3.6.0
1318
- * @category comparisons
1319
- * @example
1320
- * ```ts
1321
- * import { DateTime, Effect } from "effect"
1322
- *
1323
- * Effect.gen(function*() {
1324
- * const now = yield* DateTime.now
1325
- * const other = DateTime.add(now, { minutes: 1 })
1326
- *
1327
- * // returns Result.succeed(Duration.minutes(1))
1328
- * DateTime.distanceDurationResult(now, other)
1329
- *
1330
- * // returns Result.fail(Duration.minutes(1))
1331
- * DateTime.distanceDurationResult(other, now)
1332
- * })
1333
- * ```
1334
- */
1335
- (self: DateTime, other: DateTime): Result.Result<Duration.Duration, Duration.Duration>
1336
- } = Internal.distanceDurationResult
1337
-
1338
- /**
1339
- * Calulate the distance between two `DateTime` values.
1340
- *
1341
- * @since 3.6.0
1342
- * @category comparisons
1343
- * @example
1344
- * ```ts
1345
- * import { DateTime, Effect } from "effect"
1346
- *
1347
- * Effect.gen(function*() {
1348
- * const now = yield* DateTime.now
1349
- * const other = DateTime.add(now, { minutes: 1 })
1350
- *
1351
- * // returns Duration.minutes(1)
1352
- * DateTime.distanceDuration(now, other)
1353
- * })
1354
- * ```
1355
- */
1356
- export const distanceDuration: {
1357
- /**
1358
- * Calulate the distance between two `DateTime` values.
1235
+ * If `other` is *after* `self`, the result will be a positive `Duration`. If
1236
+ * `other` is *before* `self`, the result will be a negative `Duration`. If they
1237
+ * are equal, the result will be a `Duration` of zero.
1359
1238
  *
1360
1239
  * @since 3.6.0
1361
1240
  * @category comparisons
@@ -1368,31 +1247,12 @@ export const distanceDuration: {
1368
1247
  * const other = DateTime.add(now, { minutes: 1 })
1369
1248
  *
1370
1249
  * // returns Duration.minutes(1)
1371
- * DateTime.distanceDuration(now, other)
1372
- * })
1373
- * ```
1374
- */
1375
- (other: DateTime): (self: DateTime) => Duration.Duration
1376
- /**
1377
- * Calulate the distance between two `DateTime` values.
1378
- *
1379
- * @since 3.6.0
1380
- * @category comparisons
1381
- * @example
1382
- * ```ts
1383
- * import { DateTime, Effect } from "effect"
1384
- *
1385
- * Effect.gen(function*() {
1386
- * const now = yield* DateTime.now
1387
- * const other = DateTime.add(now, { minutes: 1 })
1388
- *
1389
- * // returns Duration.minutes(1)
1390
- * DateTime.distanceDuration(now, other)
1250
+ * DateTime.distance(now, other)
1391
1251
  * })
1392
1252
  * ```
1393
1253
  */
1394
1254
  (self: DateTime, other: DateTime): Duration.Duration
1395
- } = Internal.distanceDuration
1255
+ } = Internal.distance
1396
1256
 
1397
1257
  /**
1398
1258
  * Returns the earlier of two `DateTime` values.
@@ -3054,7 +2914,7 @@ export const addDuration: {
3054
2914
  * )
3055
2915
  * ```
3056
2916
  */
3057
- (duration: Duration.DurationInput): <A extends DateTime>(self: A) => A
2917
+ (duration: Duration.Input): <A extends DateTime>(self: A) => A
3058
2918
  // =============================================================================
3059
2919
  // math
3060
2920
  // =============================================================================
@@ -3074,7 +2934,7 @@ export const addDuration: {
3074
2934
  * )
3075
2935
  * ```
3076
2936
  */
3077
- <A extends DateTime>(self: A, duration: Duration.DurationInput): A
2937
+ <A extends DateTime>(self: A, duration: Duration.Input): A
3078
2938
  } = Internal.addDuration
3079
2939
 
3080
2940
  /**
@@ -3108,7 +2968,7 @@ export const subtractDuration: {
3108
2968
  * )
3109
2969
  * ```
3110
2970
  */
3111
- (duration: Duration.DurationInput): <A extends DateTime>(self: A) => A
2971
+ (duration: Duration.Input): <A extends DateTime>(self: A) => A
3112
2972
  /**
3113
2973
  * Subtract the given `Duration` from a `DateTime`.
3114
2974
  *
@@ -3124,7 +2984,7 @@ export const subtractDuration: {
3124
2984
  * )
3125
2985
  * ```
3126
2986
  */
3127
- <A extends DateTime>(self: A, duration: Duration.DurationInput): A
2987
+ <A extends DateTime>(self: A, duration: Duration.Input): A
3128
2988
  } = Internal.subtractDuration
3129
2989
 
3130
2990
  /**