effect 3.1.1 → 3.1.2

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 (257) hide show
  1. package/dist/cjs/Array.js +10 -13
  2. package/dist/cjs/Array.js.map +1 -1
  3. package/dist/cjs/BigDecimal.js +14 -17
  4. package/dist/cjs/BigDecimal.js.map +1 -1
  5. package/dist/cjs/BigInt.js +41 -46
  6. package/dist/cjs/BigInt.js.map +1 -1
  7. package/dist/cjs/Boolean.js +13 -13
  8. package/dist/cjs/Brand.js +2 -2
  9. package/dist/cjs/Chunk.js +3 -3
  10. package/dist/cjs/Context.js +15 -20
  11. package/dist/cjs/Context.js.map +1 -1
  12. package/dist/cjs/Cron.js +3 -6
  13. package/dist/cjs/Cron.js.map +1 -1
  14. package/dist/cjs/Data.js +8 -13
  15. package/dist/cjs/Data.js.map +1 -1
  16. package/dist/cjs/Duration.js +1 -1
  17. package/dist/cjs/Effect.js +77 -9
  18. package/dist/cjs/Effect.js.map +1 -1
  19. package/dist/cjs/Either.js +117 -59
  20. package/dist/cjs/Either.js.map +1 -1
  21. package/dist/cjs/FiberHandle.js.map +1 -1
  22. package/dist/cjs/FiberMap.js.map +1 -1
  23. package/dist/cjs/FiberSet.js.map +1 -1
  24. package/dist/cjs/Function.js +2 -2
  25. package/dist/cjs/Function.js.map +1 -1
  26. package/dist/cjs/Iterable.js +10 -13
  27. package/dist/cjs/Iterable.js.map +1 -1
  28. package/dist/cjs/List.js +2 -2
  29. package/dist/cjs/Metric.js +5 -7
  30. package/dist/cjs/Metric.js.map +1 -1
  31. package/dist/cjs/Number.js +20 -21
  32. package/dist/cjs/Number.js.map +1 -1
  33. package/dist/cjs/Option.js +223 -164
  34. package/dist/cjs/Option.js.map +1 -1
  35. package/dist/cjs/Order.js +1 -2
  36. package/dist/cjs/Order.js.map +1 -1
  37. package/dist/cjs/Ordering.js +2 -2
  38. package/dist/cjs/Predicate.js +9 -12
  39. package/dist/cjs/Predicate.js.map +1 -1
  40. package/dist/cjs/Readable.js.map +1 -1
  41. package/dist/cjs/Record.js +35 -47
  42. package/dist/cjs/Record.js.map +1 -1
  43. package/dist/cjs/RegExp.js +1 -1
  44. package/dist/cjs/Request.js +2 -2
  45. package/dist/cjs/Request.js.map +1 -1
  46. package/dist/cjs/Stream.js +82 -4
  47. package/dist/cjs/Stream.js.map +1 -1
  48. package/dist/cjs/String.js +81 -111
  49. package/dist/cjs/String.js.map +1 -1
  50. package/dist/cjs/Struct.js +13 -19
  51. package/dist/cjs/Struct.js.map +1 -1
  52. package/dist/cjs/Subscribable.js.map +1 -1
  53. package/dist/cjs/Symbol.js +3 -3
  54. package/dist/cjs/TestAnnotation.js.map +1 -1
  55. package/dist/cjs/TestAnnotationMap.js.map +1 -1
  56. package/dist/cjs/TestAnnotations.js.map +1 -1
  57. package/dist/cjs/TestClock.js.map +1 -1
  58. package/dist/cjs/TestLive.js.map +1 -1
  59. package/dist/cjs/TestSized.js.map +1 -1
  60. package/dist/cjs/Trie.js +28 -44
  61. package/dist/cjs/Trie.js.map +1 -1
  62. package/dist/cjs/Utils.js.map +1 -1
  63. package/dist/cjs/internal/core-effect.js +4 -11
  64. package/dist/cjs/internal/core-effect.js.map +1 -1
  65. package/dist/cjs/internal/doNotation.js +23 -0
  66. package/dist/cjs/internal/doNotation.js.map +1 -0
  67. package/dist/cjs/internal/groupBy.js.map +1 -1
  68. package/dist/cjs/internal/stream.js +3 -7
  69. package/dist/cjs/internal/stream.js.map +1 -1
  70. package/dist/cjs/internal/version.js +1 -1
  71. package/dist/dts/Array.d.ts +10 -13
  72. package/dist/dts/Array.d.ts.map +1 -1
  73. package/dist/dts/BigDecimal.d.ts +14 -17
  74. package/dist/dts/BigDecimal.d.ts.map +1 -1
  75. package/dist/dts/BigInt.d.ts +41 -46
  76. package/dist/dts/BigInt.d.ts.map +1 -1
  77. package/dist/dts/Boolean.d.ts +13 -13
  78. package/dist/dts/Brand.d.ts +3 -3
  79. package/dist/dts/Chunk.d.ts +3 -3
  80. package/dist/dts/Context.d.ts +15 -20
  81. package/dist/dts/Context.d.ts.map +1 -1
  82. package/dist/dts/Cron.d.ts +3 -6
  83. package/dist/dts/Cron.d.ts.map +1 -1
  84. package/dist/dts/Data.d.ts +10 -16
  85. package/dist/dts/Data.d.ts.map +1 -1
  86. package/dist/dts/Duration.d.ts +1 -1
  87. package/dist/dts/Effect.d.ts +120 -26
  88. package/dist/dts/Effect.d.ts.map +1 -1
  89. package/dist/dts/Either.d.ts +155 -64
  90. package/dist/dts/Either.d.ts.map +1 -1
  91. package/dist/dts/FiberHandle.d.ts.map +1 -1
  92. package/dist/dts/FiberMap.d.ts.map +1 -1
  93. package/dist/dts/FiberSet.d.ts.map +1 -1
  94. package/dist/dts/Function.d.ts +4 -2
  95. package/dist/dts/Function.d.ts.map +1 -1
  96. package/dist/dts/HashMap.d.ts +2 -2
  97. package/dist/dts/Iterable.d.ts +10 -13
  98. package/dist/dts/Iterable.d.ts.map +1 -1
  99. package/dist/dts/List.d.ts +2 -2
  100. package/dist/dts/Metric.d.ts +5 -7
  101. package/dist/dts/Metric.d.ts.map +1 -1
  102. package/dist/dts/Number.d.ts +20 -21
  103. package/dist/dts/Number.d.ts.map +1 -1
  104. package/dist/dts/Option.d.ts +245 -155
  105. package/dist/dts/Option.d.ts.map +1 -1
  106. package/dist/dts/Order.d.ts +1 -2
  107. package/dist/dts/Order.d.ts.map +1 -1
  108. package/dist/dts/Ordering.d.ts +2 -2
  109. package/dist/dts/Predicate.d.ts +9 -12
  110. package/dist/dts/Predicate.d.ts.map +1 -1
  111. package/dist/dts/Readable.d.ts.map +1 -1
  112. package/dist/dts/Record.d.ts +35 -47
  113. package/dist/dts/Record.d.ts.map +1 -1
  114. package/dist/dts/RegExp.d.ts +1 -1
  115. package/dist/dts/Request.d.ts +2 -2
  116. package/dist/dts/Request.d.ts.map +1 -1
  117. package/dist/dts/Stream.d.ts +136 -31
  118. package/dist/dts/Stream.d.ts.map +1 -1
  119. package/dist/dts/String.d.ts +81 -111
  120. package/dist/dts/String.d.ts.map +1 -1
  121. package/dist/dts/Struct.d.ts +13 -19
  122. package/dist/dts/Struct.d.ts.map +1 -1
  123. package/dist/dts/Subscribable.d.ts.map +1 -1
  124. package/dist/dts/Symbol.d.ts +3 -3
  125. package/dist/dts/TestAnnotation.d.ts.map +1 -1
  126. package/dist/dts/TestAnnotationMap.d.ts.map +1 -1
  127. package/dist/dts/TestAnnotations.d.ts.map +1 -1
  128. package/dist/dts/TestClock.d.ts +1 -5
  129. package/dist/dts/TestClock.d.ts.map +1 -1
  130. package/dist/dts/TestLive.d.ts.map +1 -1
  131. package/dist/dts/TestSized.d.ts.map +1 -1
  132. package/dist/dts/Trie.d.ts +28 -44
  133. package/dist/dts/Trie.d.ts.map +1 -1
  134. package/dist/dts/Types.d.ts +10 -10
  135. package/dist/dts/Utils.d.ts.map +1 -1
  136. package/dist/dts/internal/doNotation.d.ts +2 -0
  137. package/dist/dts/internal/doNotation.d.ts.map +1 -0
  138. package/dist/dts/internal/stream.d.ts.map +1 -1
  139. package/dist/esm/Array.js +10 -13
  140. package/dist/esm/Array.js.map +1 -1
  141. package/dist/esm/BigDecimal.js +14 -17
  142. package/dist/esm/BigDecimal.js.map +1 -1
  143. package/dist/esm/BigInt.js +41 -46
  144. package/dist/esm/BigInt.js.map +1 -1
  145. package/dist/esm/Boolean.js +13 -13
  146. package/dist/esm/Brand.js +2 -2
  147. package/dist/esm/Chunk.js +3 -3
  148. package/dist/esm/Context.js +15 -20
  149. package/dist/esm/Context.js.map +1 -1
  150. package/dist/esm/Cron.js +3 -6
  151. package/dist/esm/Cron.js.map +1 -1
  152. package/dist/esm/Data.js +9 -15
  153. package/dist/esm/Data.js.map +1 -1
  154. package/dist/esm/Duration.js +1 -1
  155. package/dist/esm/Effect.js +101 -11
  156. package/dist/esm/Effect.js.map +1 -1
  157. package/dist/esm/Either.js +141 -61
  158. package/dist/esm/Either.js.map +1 -1
  159. package/dist/esm/FiberHandle.js.map +1 -1
  160. package/dist/esm/FiberMap.js.map +1 -1
  161. package/dist/esm/FiberSet.js.map +1 -1
  162. package/dist/esm/Function.js +2 -2
  163. package/dist/esm/Function.js.map +1 -1
  164. package/dist/esm/Iterable.js +10 -13
  165. package/dist/esm/Iterable.js.map +1 -1
  166. package/dist/esm/List.js +2 -2
  167. package/dist/esm/Metric.js +5 -7
  168. package/dist/esm/Metric.js.map +1 -1
  169. package/dist/esm/Number.js +20 -21
  170. package/dist/esm/Number.js.map +1 -1
  171. package/dist/esm/Option.js +249 -164
  172. package/dist/esm/Option.js.map +1 -1
  173. package/dist/esm/Order.js +1 -2
  174. package/dist/esm/Order.js.map +1 -1
  175. package/dist/esm/Ordering.js +2 -2
  176. package/dist/esm/Predicate.js +9 -12
  177. package/dist/esm/Predicate.js.map +1 -1
  178. package/dist/esm/Readable.js.map +1 -1
  179. package/dist/esm/Record.js +35 -47
  180. package/dist/esm/Record.js.map +1 -1
  181. package/dist/esm/RegExp.js +1 -1
  182. package/dist/esm/Request.js +2 -2
  183. package/dist/esm/Request.js.map +1 -1
  184. package/dist/esm/Stream.js +107 -6
  185. package/dist/esm/Stream.js.map +1 -1
  186. package/dist/esm/String.js +81 -111
  187. package/dist/esm/String.js.map +1 -1
  188. package/dist/esm/Struct.js +13 -19
  189. package/dist/esm/Struct.js.map +1 -1
  190. package/dist/esm/Subscribable.js.map +1 -1
  191. package/dist/esm/Symbol.js +3 -3
  192. package/dist/esm/TestAnnotation.js.map +1 -1
  193. package/dist/esm/TestAnnotationMap.js.map +1 -1
  194. package/dist/esm/TestAnnotations.js.map +1 -1
  195. package/dist/esm/TestClock.js.map +1 -1
  196. package/dist/esm/TestLive.js.map +1 -1
  197. package/dist/esm/TestSized.js.map +1 -1
  198. package/dist/esm/Trie.js +28 -44
  199. package/dist/esm/Trie.js.map +1 -1
  200. package/dist/esm/Utils.js.map +1 -1
  201. package/dist/esm/internal/core-effect.js +4 -11
  202. package/dist/esm/internal/core-effect.js.map +1 -1
  203. package/dist/esm/internal/doNotation.js +14 -0
  204. package/dist/esm/internal/doNotation.js.map +1 -0
  205. package/dist/esm/internal/groupBy.js.map +1 -1
  206. package/dist/esm/internal/stream.js +3 -7
  207. package/dist/esm/internal/stream.js.map +1 -1
  208. package/dist/esm/internal/version.js +1 -1
  209. package/package.json +1 -1
  210. package/src/Array.ts +10 -13
  211. package/src/BigDecimal.ts +14 -17
  212. package/src/BigInt.ts +41 -46
  213. package/src/Boolean.ts +13 -13
  214. package/src/Brand.ts +3 -3
  215. package/src/Chunk.ts +3 -3
  216. package/src/Context.ts +15 -20
  217. package/src/Cron.ts +3 -6
  218. package/src/Data.ts +10 -16
  219. package/src/Duration.ts +1 -1
  220. package/src/Effect.ts +122 -32
  221. package/src/Either.ts +161 -94
  222. package/src/FiberHandle.ts +1 -1
  223. package/src/FiberMap.ts +1 -1
  224. package/src/FiberSet.ts +1 -1
  225. package/src/Function.ts +4 -2
  226. package/src/HashMap.ts +2 -2
  227. package/src/Iterable.ts +10 -13
  228. package/src/List.ts +2 -2
  229. package/src/Metric.ts +5 -7
  230. package/src/Number.ts +20 -21
  231. package/src/Option.ts +250 -172
  232. package/src/Order.ts +1 -2
  233. package/src/Ordering.ts +2 -2
  234. package/src/Predicate.ts +9 -12
  235. package/src/Readable.ts +1 -1
  236. package/src/Record.ts +35 -47
  237. package/src/RegExp.ts +1 -1
  238. package/src/Request.ts +3 -3
  239. package/src/Stream.ts +137 -36
  240. package/src/String.ts +81 -111
  241. package/src/Struct.ts +13 -19
  242. package/src/Subscribable.ts +1 -1
  243. package/src/Symbol.ts +3 -3
  244. package/src/TestAnnotation.ts +1 -1
  245. package/src/TestAnnotationMap.ts +1 -1
  246. package/src/TestAnnotations.ts +1 -1
  247. package/src/TestClock.ts +1 -5
  248. package/src/TestLive.ts +1 -1
  249. package/src/TestSized.ts +1 -1
  250. package/src/Trie.ts +28 -44
  251. package/src/Types.ts +10 -10
  252. package/src/Utils.ts +2 -2
  253. package/src/internal/core-effect.ts +29 -45
  254. package/src/internal/doNotation.ts +77 -0
  255. package/src/internal/groupBy.ts +16 -16
  256. package/src/internal/stream.ts +34 -58
  257. package/src/internal/version.ts +1 -1
@@ -1,6 +1,7 @@
1
1
  import * as Equal from "./Equal.js";
2
2
  import * as Equivalence from "./Equivalence.js";
3
3
  import { constNull, constUndefined, dual, identity, isFunction } from "./Function.js";
4
+ import * as doNotation from "./internal/doNotation.js";
4
5
  import * as either from "./internal/either.js";
5
6
  import * as option from "./internal/option.js";
6
7
  import * as order from "./Order.js";
@@ -32,11 +33,11 @@ export const some = option.some;
32
33
  * @param input - The value to check.
33
34
  *
34
35
  * @example
35
- * import { some, none, isOption } from 'effect/Option'
36
+ * import { Option } from "effect"
36
37
  *
37
- * assert.deepStrictEqual(isOption(some(1)), true)
38
- * assert.deepStrictEqual(isOption(none()), true)
39
- * assert.deepStrictEqual(isOption({}), false)
38
+ * assert.deepStrictEqual(Option.isOption(Option.some(1)), true)
39
+ * assert.deepStrictEqual(Option.isOption(Option.none()), true)
40
+ * assert.deepStrictEqual(Option.isOption({}), false)
40
41
  *
41
42
  * @category guards
42
43
  * @since 2.0.0
@@ -48,10 +49,10 @@ export const isOption = option.isOption;
48
49
  * @param self - The `Option` to check.
49
50
  *
50
51
  * @example
51
- * import { some, none, isNone } from 'effect/Option'
52
+ * import { Option } from "effect"
52
53
  *
53
- * assert.deepStrictEqual(isNone(some(1)), false)
54
- * assert.deepStrictEqual(isNone(none()), true)
54
+ * assert.deepStrictEqual(Option.isNone(Option.some(1)), false)
55
+ * assert.deepStrictEqual(Option.isNone(Option.none()), true)
55
56
  *
56
57
  * @category guards
57
58
  * @since 2.0.0
@@ -63,10 +64,10 @@ export const isNone = option.isNone;
63
64
  * @param self - The `Option` to check.
64
65
  *
65
66
  * @example
66
- * import { some, none, isSome } from 'effect/Option'
67
+ * import { Option } from "effect"
67
68
  *
68
- * assert.deepStrictEqual(isSome(some(1)), true)
69
- * assert.deepStrictEqual(isSome(none()), false)
69
+ * assert.deepStrictEqual(Option.isSome(Option.some(1)), true)
70
+ * assert.deepStrictEqual(Option.isSome(Option.none()), false)
70
71
  *
71
72
  * @category guards
72
73
  * @since 2.0.0
@@ -81,16 +82,15 @@ export const isSome = option.isSome;
81
82
  * @param onSome - The function to be called if the `Option` is `Some`, it will be passed the `Option`'s value and its result will be returned
82
83
  *
83
84
  * @example
84
- * import { some, none, match } from 'effect/Option'
85
- * import { pipe } from "effect/Function"
85
+ * import { pipe, Option } from "effect"
86
86
  *
87
87
  * assert.deepStrictEqual(
88
- * pipe(some(1), match({ onNone: () => 'a none', onSome: (a) => `a some containing ${a}` })),
88
+ * pipe(Option.some(1), Option.match({ onNone: () => 'a none', onSome: (a) => `a some containing ${a}` })),
89
89
  * 'a some containing 1'
90
90
  * )
91
91
  *
92
92
  * assert.deepStrictEqual(
93
- * pipe(none(), match({ onNone: () => 'a none', onSome: (a) => `a some containing ${a}` })),
93
+ * pipe(Option.none(), Option.match({ onNone: () => 'a none', onSome: (a) => `a some containing ${a}` })),
94
94
  * 'a none'
95
95
  * )
96
96
  *
@@ -106,12 +106,12 @@ export const match = /*#__PURE__*/dual(2, (self, {
106
106
  * This function ensures that a type guard definition is type-safe.
107
107
  *
108
108
  * @example
109
- * import * as O from "effect/Option"
109
+ * import { Option } from "effect"
110
110
  *
111
- * const parsePositive = (n: number): O.Option<number> =>
112
- * n > 0 ? O.some(n) : O.none()
111
+ * const parsePositive = (n: number): Option.Option<number> =>
112
+ * n > 0 ? Option.some(n) : Option.none()
113
113
  *
114
- * const isPositive = O.toRefinement(parsePositive)
114
+ * const isPositive = Option.toRefinement(parsePositive)
115
115
  *
116
116
  * assert.deepStrictEqual(isPositive(1), true)
117
117
  * assert.deepStrictEqual(isPositive(-1), false)
@@ -127,10 +127,10 @@ export const toRefinement = f => a => isSome(f(a));
127
127
  * @param collection - The `Iterable` to be converted to an `Option`.
128
128
  *
129
129
  * @example
130
- * import { fromIterable, some, none } from 'effect/Option'
130
+ * import { Option } from "effect"
131
131
  *
132
- * assert.deepStrictEqual(fromIterable([1, 2, 3]), some(1))
133
- * assert.deepStrictEqual(fromIterable([]), none())
132
+ * assert.deepStrictEqual(Option.fromIterable([1, 2, 3]), Option.some(1))
133
+ * assert.deepStrictEqual(Option.fromIterable([]), Option.none())
134
134
  *
135
135
  * @category constructors
136
136
  * @since 2.0.0
@@ -147,11 +147,10 @@ export const fromIterable = collection => {
147
147
  * Alias of {@link fromEither}.
148
148
  *
149
149
  * @example
150
- * import * as O from "effect/Option"
151
- * import * as E from "effect/Either"
150
+ * import { Option, Either } from "effect"
152
151
  *
153
- * assert.deepStrictEqual(O.getRight(E.right('ok')), O.some('ok'))
154
- * assert.deepStrictEqual(O.getRight(E.left('err')), O.none())
152
+ * assert.deepStrictEqual(Option.getRight(Either.right('ok')), Option.some('ok'))
153
+ * assert.deepStrictEqual(Option.getRight(Either.left('err')), Option.none())
155
154
  *
156
155
  * @category conversions
157
156
  * @since 2.0.0
@@ -161,11 +160,10 @@ export const getRight = either.getRight;
161
160
  * Converts a `Either` to an `Option` discarding the value.
162
161
  *
163
162
  * @example
164
- * import * as O from "effect/Option"
165
- * import * as E from "effect/Either"
163
+ * import { Option, Either } from "effect"
166
164
  *
167
- * assert.deepStrictEqual(O.getLeft(E.right("ok")), O.none())
168
- * assert.deepStrictEqual(O.getLeft(E.left("a")), O.some("a"))
165
+ * assert.deepStrictEqual(Option.getLeft(Either.right("ok")), Option.none())
166
+ * assert.deepStrictEqual(Option.getLeft(Either.left("a")), Option.some("a"))
169
167
  *
170
168
  * @category conversions
171
169
  * @since 2.0.0
@@ -178,11 +176,10 @@ export const getLeft = either.getLeft;
178
176
  * @param onNone - Function that returns the default value to return if the `Option` is `None`.
179
177
  *
180
178
  * @example
181
- * import { some, none, getOrElse } from 'effect/Option'
182
- * import { pipe } from "effect/Function"
179
+ * import { pipe, Option } from "effect"
183
180
  *
184
- * assert.deepStrictEqual(pipe(some(1), getOrElse(() => 0)), 1)
185
- * assert.deepStrictEqual(pipe(none(), getOrElse(() => 0)), 0)
181
+ * assert.deepStrictEqual(pipe(Option.some(1), Option.getOrElse(() => 0)), 1)
182
+ * assert.deepStrictEqual(pipe(Option.none(), Option.getOrElse(() => 0)), 0)
186
183
  *
187
184
  * @category getters
188
185
  * @since 2.0.0
@@ -195,36 +192,35 @@ export const getOrElse = /*#__PURE__*/dual(2, (self, onNone) => isNone(self) ? o
195
192
  * @param that - The `Option` to return if `self` is `None`.
196
193
  *
197
194
  * @example
198
- * import * as O from "effect/Option"
199
- * import { pipe } from "effect/Function"
195
+ * import { pipe, Option } from "effect"
200
196
  *
201
197
  * assert.deepStrictEqual(
202
198
  * pipe(
203
- * O.none(),
204
- * O.orElse(() => O.none())
199
+ * Option.none(),
200
+ * Option.orElse(() => Option.none())
205
201
  * ),
206
- * O.none()
202
+ * Option.none()
207
203
  * )
208
204
  * assert.deepStrictEqual(
209
205
  * pipe(
210
- * O.some('a'),
211
- * O.orElse(() => O.none())
206
+ * Option.some('a'),
207
+ * Option.orElse(() => Option.none())
212
208
  * ),
213
- * O.some('a')
209
+ * Option.some('a')
214
210
  * )
215
211
  * assert.deepStrictEqual(
216
212
  * pipe(
217
- * O.none(),
218
- * O.orElse(() => O.some('b'))
213
+ * Option.none(),
214
+ * Option.orElse(() => Option.some('b'))
219
215
  * ),
220
- * O.some('b')
216
+ * Option.some('b')
221
217
  * )
222
218
  * assert.deepStrictEqual(
223
219
  * pipe(
224
- * O.some('a'),
225
- * O.orElse(() => O.some('b'))
220
+ * Option.some('a'),
221
+ * Option.orElse(() => Option.some('b'))
226
222
  * ),
227
- * O.some('a')
223
+ * Option.some('a')
228
224
  * )
229
225
  *
230
226
  * @category error handling
@@ -238,22 +234,21 @@ export const orElse = /*#__PURE__*/dual(2, (self, that) => isNone(self) ? that()
238
234
  * @param onNone - Function that returns the default value to return if the `Option` is `None`.
239
235
  *
240
236
  * @example
241
- * import * as O from "effect/Option"
242
- * import { pipe } from "effect/Function"
237
+ * import { pipe, Option } from "effect"
243
238
  *
244
239
  * assert.deepStrictEqual(
245
240
  * pipe(
246
- * O.none(),
247
- * O.orElseSome(() => 'b')
241
+ * Option.none(),
242
+ * Option.orElseSome(() => 'b')
248
243
  * ),
249
- * O.some('b')
244
+ * Option.some('b')
250
245
  * )
251
246
  * assert.deepStrictEqual(
252
247
  * pipe(
253
- * O.some('a'),
254
- * O.orElseSome(() => 'b')
248
+ * Option.some('a'),
249
+ * Option.orElseSome(() => 'b')
255
250
  * ),
256
- * O.some('a')
251
+ * Option.some('a')
257
252
  * )
258
253
  *
259
254
  * @category error handling
@@ -279,9 +274,9 @@ export const orElseEither = /*#__PURE__*/dual(2, (self, that) => isNone(self) ?
279
274
  * @param collection - An iterable collection of `Option` to be searched.
280
275
  *
281
276
  * @example
282
- * import * as O from "effect/Option"
277
+ * import { Option } from "effect"
283
278
  *
284
- * assert.deepStrictEqual(O.firstSomeOf([O.none(), O.some(1), O.some(2)]), O.some(1))
279
+ * assert.deepStrictEqual(Option.firstSomeOf([Option.none(), Option.some(1), Option.some(2)]), Option.some(1))
285
280
  *
286
281
  * @category error handling
287
282
  * @since 2.0.0
@@ -302,11 +297,11 @@ export const firstSomeOf = collection => {
302
297
  * @param nullableValue - The nullable value to be converted to an `Option`.
303
298
  *
304
299
  * @example
305
- * import * as O from "effect/Option"
300
+ * import { Option } from "effect"
306
301
  *
307
- * assert.deepStrictEqual(O.fromNullable(undefined), O.none())
308
- * assert.deepStrictEqual(O.fromNullable(null), O.none())
309
- * assert.deepStrictEqual(O.fromNullable(1), O.some(1))
302
+ * assert.deepStrictEqual(Option.fromNullable(undefined), Option.none())
303
+ * assert.deepStrictEqual(Option.fromNullable(null), Option.none())
304
+ * assert.deepStrictEqual(Option.fromNullable(1), Option.some(1))
310
305
  *
311
306
  * @category conversions
312
307
  * @since 2.0.0
@@ -316,17 +311,17 @@ export const fromNullable = nullableValue => nullableValue == null ? none() : so
316
311
  * This API is useful for lifting a function that returns `null` or `undefined` into the `Option` context.
317
312
  *
318
313
  * @example
319
- * import * as O from "effect/Option"
314
+ * import { Option } from "effect"
320
315
  *
321
316
  * const parse = (s: string): number | undefined => {
322
317
  * const n = parseFloat(s)
323
318
  * return isNaN(n) ? undefined : n
324
319
  * }
325
320
  *
326
- * const parseOption = O.liftNullable(parse)
321
+ * const parseOption = Option.liftNullable(parse)
327
322
  *
328
- * assert.deepStrictEqual(parseOption('1'), O.some(1))
329
- * assert.deepStrictEqual(parseOption('not a number'), O.none())
323
+ * assert.deepStrictEqual(parseOption('1'), Option.some(1))
324
+ * assert.deepStrictEqual(parseOption('not a number'), Option.none())
330
325
  *
331
326
  * @category conversions
332
327
  * @since 2.0.0
@@ -338,10 +333,10 @@ export const liftNullable = f => (...a) => fromNullable(f(...a));
338
333
  * @param self - The `Option` to extract the value from.
339
334
  *
340
335
  * @example
341
- * import * as O from "effect/Option"
336
+ * import { Option } from "effect"
342
337
  *
343
- * assert.deepStrictEqual(O.getOrNull(O.some(1)), 1)
344
- * assert.deepStrictEqual(O.getOrNull(O.none()), null)
338
+ * assert.deepStrictEqual(Option.getOrNull(Option.some(1)), 1)
339
+ * assert.deepStrictEqual(Option.getOrNull(Option.none()), null)
345
340
  *
346
341
  * @category getters
347
342
  * @since 2.0.0
@@ -353,10 +348,10 @@ export const getOrNull = /*#__PURE__*/getOrElse(constNull);
353
348
  * @param self - The `Option` to extract the value from.
354
349
  *
355
350
  * @example
356
- * import * as O from "effect/Option"
351
+ * import { Option } from "effect"
357
352
  *
358
- * assert.deepStrictEqual(O.getOrUndefined(O.some(1)), 1)
359
- * assert.deepStrictEqual(O.getOrUndefined(O.none()), undefined)
353
+ * assert.deepStrictEqual(Option.getOrUndefined(Option.some(1)), 1)
354
+ * assert.deepStrictEqual(Option.getOrUndefined(Option.none()), undefined)
360
355
  *
361
356
  * @category getters
362
357
  * @since 2.0.0
@@ -371,12 +366,12 @@ export const getOrUndefined = /*#__PURE__*/getOrElse(constUndefined);
371
366
  * @param f - the function that can throw exceptions.
372
367
  *
373
368
  * @example
374
- * import * as O from "effect/Option"
369
+ * import { Option } from "effect"
375
370
  *
376
- * const parse = O.liftThrowable(JSON.parse)
371
+ * const parse = Option.liftThrowable(JSON.parse)
377
372
  *
378
- * assert.deepStrictEqual(parse("1"), O.some(1))
379
- * assert.deepStrictEqual(parse(""), O.none())
373
+ * assert.deepStrictEqual(parse("1"), Option.some(1))
374
+ * assert.deepStrictEqual(parse(""), Option.none())
380
375
  *
381
376
  * @category conversions
382
377
  * @since 2.0.0
@@ -397,13 +392,13 @@ export const liftThrowable = f => (...a) => {
397
392
  * @param onNone - A function that will be called if the `Option` is `None`. It returns the error to be thrown.
398
393
  *
399
394
  * @example
400
- * import * as O from "effect/Option"
395
+ * import { Option } from "effect"
401
396
  *
402
397
  * assert.deepStrictEqual(
403
- * O.getOrThrowWith(O.some(1), () => new Error('Unexpected None')),
398
+ * Option.getOrThrowWith(Option.some(1), () => new Error('Unexpected None')),
404
399
  * 1
405
400
  * )
406
- * assert.throws(() => O.getOrThrowWith(O.none(), () => new Error('Unexpected None')))
401
+ * assert.throws(() => Option.getOrThrowWith(Option.none(), () => new Error('Unexpected None')))
407
402
  *
408
403
  * @category conversions
409
404
  * @since 2.0.0
@@ -423,10 +418,10 @@ export const getOrThrowWith = /*#__PURE__*/dual(2, (self, onNone) => {
423
418
  * @throws `Error("getOrThrow called on a None")`
424
419
  *
425
420
  * @example
426
- * import * as O from "effect/Option"
421
+ * import { Option } from "effect"
427
422
  *
428
- * assert.deepStrictEqual(O.getOrThrow(O.some(1)), 1)
429
- * assert.throws(() => O.getOrThrow(O.none()))
423
+ * assert.deepStrictEqual(Option.getOrThrow(Option.some(1)), 1)
424
+ * assert.throws(() => Option.getOrThrow(Option.none()))
430
425
  *
431
426
  * @category conversions
432
427
  * @since 2.0.0
@@ -485,8 +480,7 @@ export const andThen = /*#__PURE__*/dual(2, (self, f) => flatMap(self, a => {
485
480
  * This is `flatMap` + `fromNullable`, useful when working with optional values.
486
481
  *
487
482
  * @example
488
- * import { some, none, flatMapNullable } from 'effect/Option'
489
- * import { pipe } from "effect/Function"
483
+ * import { pipe, Option } from "effect"
490
484
  *
491
485
  * interface Employee {
492
486
  * company?: {
@@ -502,20 +496,20 @@ export const andThen = /*#__PURE__*/dual(2, (self, f) => flatMap(self, a => {
502
496
  *
503
497
  * assert.deepStrictEqual(
504
498
  * pipe(
505
- * some(employee1),
506
- * flatMapNullable(employee => employee.company?.address?.street?.name),
499
+ * Option.some(employee1),
500
+ * Option.flatMapNullable(employee => employee.company?.address?.street?.name),
507
501
  * ),
508
- * some('high street')
502
+ * Option.some('high street')
509
503
  * )
510
504
  *
511
505
  * const employee2: Employee = { company: { address: { street: {} } } }
512
506
  *
513
507
  * assert.deepStrictEqual(
514
508
  * pipe(
515
- * some(employee2),
516
- * flatMapNullable(employee => employee.company?.address?.street?.name),
509
+ * Option.some(employee2),
510
+ * Option.flatMapNullable(employee => employee.company?.address?.street?.name),
517
511
  * ),
518
- * none()
512
+ * Option.none()
519
513
  * )
520
514
  *
521
515
  * @category sequencing
@@ -559,13 +553,13 @@ export const zipLeft = /*#__PURE__*/dual(2, (self, that) => tap(self, () => that
559
553
  * @param self - The `Option` to apply the function to
560
554
  *
561
555
  * @example
562
- * import * as O from "effect/Option"
556
+ * import { Option } from "effect"
563
557
  *
564
- * const getInteger = (n: number) => Number.isInteger(n) ? O.some(n) : O.none()
558
+ * const getInteger = (n: number) => Number.isInteger(n) ? Option.some(n) : Option.none()
565
559
  *
566
- * assert.deepStrictEqual(O.tap(O.none(), getInteger), O.none())
567
- * assert.deepStrictEqual(O.tap(O.some(1), getInteger), O.some(1))
568
- * assert.deepStrictEqual(O.tap(O.some(1.14), getInteger), O.none())
560
+ * assert.deepStrictEqual(Option.tap(Option.none(), getInteger), Option.none())
561
+ * assert.deepStrictEqual(Option.tap(Option.some(1), getInteger), Option.some(1))
562
+ * assert.deepStrictEqual(Option.tap(Option.some(1.14), getInteger), Option.none())
569
563
  *
570
564
  * @category sequencing
571
565
  * @since 2.0.0
@@ -603,11 +597,11 @@ export const productMany = (self, collection) => {
603
597
  * @param fields - the struct of `Option`s to be sequenced.
604
598
  *
605
599
  * @example
606
- * import * as O from "effect/Option"
600
+ * import { Option } from "effect"
607
601
  *
608
- * assert.deepStrictEqual(O.all([O.some(1), O.some(2)]), O.some([1, 2]))
609
- * assert.deepStrictEqual(O.all({ a: O.some(1), b: O.some("hello") }), O.some({ a: 1, b: "hello" }))
610
- * assert.deepStrictEqual(O.all({ a: O.some(1), b: O.none() }), O.none())
602
+ * assert.deepStrictEqual(Option.all([Option.some(1), Option.some(2)]), Option.some([1, 2]))
603
+ * assert.deepStrictEqual(Option.all({ a: Option.some(1), b: Option.some("hello") }), Option.some({ a: 1, b: "hello" }))
604
+ * assert.deepStrictEqual(Option.all({ a: Option.some(1), b: Option.none() }), Option.none())
611
605
  *
612
606
  * @category combining
613
607
  * @since 2.0.0
@@ -642,18 +636,18 @@ export const all = input => {
642
636
  * @param f - The function used to combine the values of the two `Option`s
643
637
  *
644
638
  * @example
645
- * import * as O from "effect/Option"
639
+ * import { Option } from "effect"
646
640
  *
647
641
  * type Complex = [real: number, imaginary: number]
648
642
  *
649
643
  * const complex = (real: number, imaginary: number): Complex => [real, imaginary]
650
644
  *
651
- * assert.deepStrictEqual(O.zipWith(O.none(), O.none(), complex), O.none())
652
- * assert.deepStrictEqual(O.zipWith(O.some(1), O.none(), complex), O.none())
653
- * assert.deepStrictEqual(O.zipWith(O.none(), O.some(1), complex), O.none())
654
- * assert.deepStrictEqual(O.zipWith(O.some(1), O.some(2), complex), O.some([1, 2]))
645
+ * assert.deepStrictEqual(Option.zipWith(Option.none(), Option.none(), complex), Option.none())
646
+ * assert.deepStrictEqual(Option.zipWith(Option.some(1), Option.none(), complex), Option.none())
647
+ * assert.deepStrictEqual(Option.zipWith(Option.none(), Option.some(1), complex), Option.none())
648
+ * assert.deepStrictEqual(Option.zipWith(Option.some(1), Option.some(2), complex), Option.some([1, 2]))
655
649
  *
656
- * assert.deepStrictEqual(O.zipWith(O.some(1), complex)(O.some(2)), O.some([2, 1]))
650
+ * assert.deepStrictEqual(Option.zipWith(Option.some(1), complex)(Option.some(2)), Option.some([2, 1]))
657
651
  *
658
652
  * @category zipping
659
653
  * @since 2.0.0
@@ -672,11 +666,10 @@ export const ap = /*#__PURE__*/dual(2, (self, that) => zipWith(self, that, (f, a
672
666
  * @param f - The reducing function that takes the current accumulator value and the unwrapped value of an `Option<A>`.
673
667
  *
674
668
  * @example
675
- * import { some, none, reduceCompact } from 'effect/Option'
676
- * import { pipe } from "effect/Function"
669
+ * import { pipe, Option } from "effect"
677
670
  *
678
- * const iterable = [some(1), none(), some(2), none()]
679
- * assert.deepStrictEqual(pipe(iterable, reduceCompact(0, (b, a) => b + a)), 3)
671
+ * const iterable = [Option.some(1), Option.none(), Option.some(2), Option.none()]
672
+ * assert.deepStrictEqual(pipe(iterable, Option.reduceCompact(0, (b, a) => b + a)), 3)
680
673
  *
681
674
  * @category folding
682
675
  * @since 2.0.0
@@ -698,10 +691,10 @@ export const reduceCompact = /*#__PURE__*/dual(3, (self, b, f) => {
698
691
  * @param self - The `Option` to convert to an array.
699
692
  *
700
693
  * @example
701
- * import * as O from "effect/Option"
694
+ * import { Option } from "effect"
702
695
  *
703
- * assert.deepStrictEqual(O.toArray(O.some(1)), [1])
704
- * assert.deepStrictEqual(O.toArray(O.none()), [])
696
+ * assert.deepStrictEqual(Option.toArray(Option.some(1)), [1])
697
+ * assert.deepStrictEqual(Option.toArray(Option.none()), [])
705
698
  *
706
699
  * @category conversions
707
700
  * @since 2.0.0
@@ -727,13 +720,13 @@ export const partitionMap = /*#__PURE__*/dual(2, (self, f) => {
727
720
  * @param f - A function to apply to the value of the `Option`.
728
721
  *
729
722
  * @example
730
- * import * as O from "effect/Option"
723
+ * import { Option } from "effect"
731
724
  *
732
- * const evenNumber = (n: number) => n % 2 === 0 ? O.some(n) : O.none()
725
+ * const evenNumber = (n: number) => n % 2 === 0 ? Option.some(n) : Option.none()
733
726
  *
734
- * assert.deepStrictEqual(O.filterMap(O.none(), evenNumber), O.none())
735
- * assert.deepStrictEqual(O.filterMap(O.some(3), evenNumber), O.none())
736
- * assert.deepStrictEqual(O.filterMap(O.some(2), evenNumber), O.some(2))
727
+ * assert.deepStrictEqual(Option.filterMap(Option.none(), evenNumber), Option.none())
728
+ * assert.deepStrictEqual(Option.filterMap(Option.some(3), evenNumber), Option.none())
729
+ * assert.deepStrictEqual(Option.filterMap(Option.some(2), evenNumber), Option.some(2))
737
730
  *
738
731
  * @category filtering
739
732
  * @since 2.0.0
@@ -748,21 +741,21 @@ export const filterMap = /*#__PURE__*/dual(2, (self, f) => isNone(self) ? none()
748
741
  * @param fb - The `Option` to filter.
749
742
  *
750
743
  * @example
751
- * import * as O from "effect/Option"
744
+ * import { Option } from "effect"
752
745
  *
753
746
  * // predicate
754
747
  * const isEven = (n: number) => n % 2 === 0
755
748
  *
756
- * assert.deepStrictEqual(O.filter(O.none(), isEven), O.none())
757
- * assert.deepStrictEqual(O.filter(O.some(3), isEven), O.none())
758
- * assert.deepStrictEqual(O.filter(O.some(2), isEven), O.some(2))
749
+ * assert.deepStrictEqual(Option.filter(Option.none(), isEven), Option.none())
750
+ * assert.deepStrictEqual(Option.filter(Option.some(3), isEven), Option.none())
751
+ * assert.deepStrictEqual(Option.filter(Option.some(2), isEven), Option.some(2))
759
752
  *
760
753
  * // refinement
761
754
  * const isNumber = (v: unknown): v is number => typeof v === "number"
762
755
  *
763
- * assert.deepStrictEqual(O.filter(O.none(), isNumber), O.none())
764
- * assert.deepStrictEqual(O.filter(O.some('hello'), isNumber), O.none())
765
- * assert.deepStrictEqual(O.filter(O.some(2), isNumber), O.some(2))
756
+ * assert.deepStrictEqual(Option.filter(Option.none(), isNumber), Option.none())
757
+ * assert.deepStrictEqual(Option.filter(Option.some('hello'), isNumber), Option.none())
758
+ * assert.deepStrictEqual(Option.filter(Option.some(2), isNumber), Option.some(2))
766
759
  *
767
760
  * @category filtering
768
761
  * @since 2.0.0
@@ -770,15 +763,14 @@ export const filterMap = /*#__PURE__*/dual(2, (self, f) => isNone(self) ? none()
770
763
  export const filter = /*#__PURE__*/dual(2, (self, predicate) => filterMap(self, b => predicate(b) ? option.some(b) : option.none));
771
764
  /**
772
765
  * @example
773
- * import { none, some, getEquivalence } from 'effect/Option'
774
- * import * as N from 'effect/Number'
766
+ * import { Option, Number } from "effect"
775
767
  *
776
- * const isEquivalent = getEquivalence(N.Equivalence)
777
- * assert.deepStrictEqual(isEquivalent(none(), none()), true)
778
- * assert.deepStrictEqual(isEquivalent(none(), some(1)), false)
779
- * assert.deepStrictEqual(isEquivalent(some(1), none()), false)
780
- * assert.deepStrictEqual(isEquivalent(some(1), some(2)), false)
781
- * assert.deepStrictEqual(isEquivalent(some(1), some(1)), true)
768
+ * const isEquivalent = Option.getEquivalence(Number.Equivalence)
769
+ * assert.deepStrictEqual(isEquivalent(Option.none(), Option.none()), true)
770
+ * assert.deepStrictEqual(isEquivalent(Option.none(), Option.some(1)), false)
771
+ * assert.deepStrictEqual(isEquivalent(Option.some(1), Option.none()), false)
772
+ * assert.deepStrictEqual(isEquivalent(Option.some(1), Option.some(2)), false)
773
+ * assert.deepStrictEqual(isEquivalent(Option.some(1), Option.some(1)), true)
782
774
  *
783
775
  * @category equivalence
784
776
  * @since 2.0.0
@@ -792,16 +784,14 @@ export const getEquivalence = isEquivalent => Equivalence.make((x, y) => x === y
792
784
  * `None` is considered to be less than any `Some` value.
793
785
  *
794
786
  * @example
795
- * import { none, some, getOrder } from 'effect/Option'
796
- * import * as N from 'effect/Number'
797
- * import { pipe } from "effect/Function"
787
+ * import { pipe, Option, Number } from "effect"
798
788
  *
799
- * const O = getOrder(N.Order)
800
- * assert.deepStrictEqual(O(none(), none()), 0)
801
- * assert.deepStrictEqual(O(none(), some(1)), -1)
802
- * assert.deepStrictEqual(O(some(1), none()), 1)
803
- * assert.deepStrictEqual(O(some(1), some(2)), -1)
804
- * assert.deepStrictEqual(O(some(1), some(1)), 0)
789
+ * const O = Option.getOrder(Number.Order)
790
+ * assert.deepStrictEqual(O(Option.none(), Option.none()), 0)
791
+ * assert.deepStrictEqual(O(Option.none(), Option.some(1)), -1)
792
+ * assert.deepStrictEqual(O(Option.some(1), Option.none()), 1)
793
+ * assert.deepStrictEqual(O(Option.some(1), Option.some(2)), -1)
794
+ * assert.deepStrictEqual(O(Option.some(1), Option.some(1)), 0)
805
795
  *
806
796
  * @category sorting
807
797
  * @since 2.0.0
@@ -823,12 +813,12 @@ export const lift2 = f => dual(2, (self, that) => zipWith(self, that, f));
823
813
  * @param predicate - A `Predicate` function that takes in a value of type `A` and returns a boolean.
824
814
  *
825
815
  * @example
826
- * import * as O from "effect/Option"
816
+ * import { Option } from "effect"
827
817
  *
828
- * const getOption = O.liftPredicate((n: number) => n >= 0)
818
+ * const getOption = Option.liftPredicate((n: number) => n >= 0)
829
819
  *
830
- * assert.deepStrictEqual(getOption(-1), O.none())
831
- * assert.deepStrictEqual(getOption(1), O.some(1))
820
+ * assert.deepStrictEqual(getOption(-1), Option.none())
821
+ * assert.deepStrictEqual(getOption(1), Option.some(1))
832
822
  *
833
823
  * @category lifting
834
824
  * @since 2.0.0
@@ -842,13 +832,11 @@ export const liftPredicate = predicate => b => predicate(b) ? some(b) : none();
842
832
  * @param a - The value to compare against the `Option`.
843
833
  *
844
834
  * @example
845
- * import { some, none, containsWith } from 'effect/Option'
846
- * import { Equivalence } from 'effect/Number'
847
- * import { pipe } from "effect/Function"
835
+ * import { pipe, Option, Number } from "effect"
848
836
  *
849
- * assert.deepStrictEqual(pipe(some(2), containsWith(Equivalence)(2)), true)
850
- * assert.deepStrictEqual(pipe(some(1), containsWith(Equivalence)(2)), false)
851
- * assert.deepStrictEqual(pipe(none(), containsWith(Equivalence)(2)), false)
837
+ * assert.deepStrictEqual(pipe(Option.some(2), Option.containsWith(Number.Equivalence)(2)), true)
838
+ * assert.deepStrictEqual(pipe(Option.some(1), Option.containsWith(Number.Equivalence)(2)), false)
839
+ * assert.deepStrictEqual(pipe(Option.none(), Option.containsWith(Number.Equivalence)(2)), false)
852
840
  *
853
841
  * @category elements
854
842
  * @since 2.0.0
@@ -869,14 +857,13 @@ export const contains = /*#__PURE__*/containsWith(_equivalence);
869
857
  * @param predicate - The condition to check.
870
858
  *
871
859
  * @example
872
- * import { some, none, exists } from 'effect/Option'
873
- * import { pipe } from "effect/Function"
860
+ * import { pipe, Option } from "effect"
874
861
  *
875
862
  * const isEven = (n: number) => n % 2 === 0
876
863
  *
877
- * assert.deepStrictEqual(pipe(some(2), exists(isEven)), true)
878
- * assert.deepStrictEqual(pipe(some(1), exists(isEven)), false)
879
- * assert.deepStrictEqual(pipe(none(), exists(isEven)), false)
864
+ * assert.deepStrictEqual(pipe(Option.some(2), Option.exists(isEven)), true)
865
+ * assert.deepStrictEqual(pipe(Option.some(1), Option.exists(isEven)), false)
866
+ * assert.deepStrictEqual(pipe(Option.none(), Option.exists(isEven)), false)
880
867
  *
881
868
  * @since 2.0.0
882
869
  */
@@ -885,29 +872,127 @@ export const exists = /*#__PURE__*/dual(2, (self, refinement) => isNone(self) ?
885
872
  // do notation
886
873
  // -------------------------------------------------------------------------------------
887
874
  /**
875
+ * The "do simulation" in allows you to write code in a more declarative style, similar to the "do notation" in other programming languages. It provides a way to define variables and perform operations on them using functions like `bind` and `let`.
876
+ *
877
+ * Here's how the do simulation works:
878
+ *
879
+ * 1. Start the do simulation using the `Do` value
880
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Option` values
881
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
882
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
883
+ * 5. Regular `Option` functions like `map` and `filter` can still be used within the do simulation. These functions will receive the accumulated variables as arguments within the scope
884
+ *
885
+ * @see {@link Do}
886
+ * @see {@link bind}
887
+ * @see {@link let_ let}
888
+ *
889
+ * @example
890
+ * import { Option, pipe } from "effect"
891
+ *
892
+ * const result = pipe(
893
+ * Option.Do,
894
+ * Option.bind("x", () => Option.some(2)),
895
+ * Option.bind("y", () => Option.some(3)),
896
+ * Option.let("sum", ({ x, y }) => x + y),
897
+ * Option.filter(({ x, y }) => x * y > 5)
898
+ * )
899
+ * assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
900
+ *
888
901
  * @category do notation
889
902
  * @since 2.0.0
890
903
  */
891
- export const bindTo = /*#__PURE__*/dual(2, (self, name) => map(self, a => ({
892
- [name]: a
893
- })));
894
- const let_ = /*#__PURE__*/dual(3, (self, name, f) => map(self, a => Object.assign({}, a, {
895
- [name]: f(a)
896
- })));
904
+ export const bindTo = /*#__PURE__*/doNotation.bindTo(map);
905
+ const let_ = /*#__PURE__*/doNotation.let_(map);
897
906
  export {
898
907
  /**
908
+ * The "do simulation" in allows you to write code in a more declarative style, similar to the "do notation" in other programming languages. It provides a way to define variables and perform operations on them using functions like `bind` and `let`.
909
+ *
910
+ * Here's how the do simulation works:
911
+ *
912
+ * 1. Start the do simulation using the `Do` value
913
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Option` values
914
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
915
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
916
+ * 5. Regular `Option` functions like `map` and `filter` can still be used within the do simulation. These functions will receive the accumulated variables as arguments within the scope
917
+ *
918
+ * @see {@link Do}
919
+ * @see {@link bind}
920
+ * @see {@link bindTo}
921
+ *
922
+ * @example
923
+ * import { Option, pipe } from "effect"
924
+ *
925
+ * const result = pipe(
926
+ * Option.Do,
927
+ * Option.bind("x", () => Option.some(2)),
928
+ * Option.bind("y", () => Option.some(3)),
929
+ * Option.let("sum", ({ x, y }) => x + y),
930
+ * Option.filter(({ x, y }) => x * y > 5)
931
+ * )
932
+ * assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
933
+ *
899
934
  * @category do notation
900
935
  * @since 2.0.0
901
936
  */
902
937
  let_ as let };
903
938
  /**
939
+ * The "do simulation" in allows you to write code in a more declarative style, similar to the "do notation" in other programming languages. It provides a way to define variables and perform operations on them using functions like `bind` and `let`.
940
+ *
941
+ * Here's how the do simulation works:
942
+ *
943
+ * 1. Start the do simulation using the `Do` value
944
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Option` values
945
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
946
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
947
+ * 5. Regular `Option` functions like `map` and `filter` can still be used within the do simulation. These functions will receive the accumulated variables as arguments within the scope
948
+ *
949
+ * @see {@link Do}
950
+ * @see {@link bindTo}
951
+ * @see {@link let_ let}
952
+ *
953
+ * @example
954
+ * import { Option, pipe } from "effect"
955
+ *
956
+ * const result = pipe(
957
+ * Option.Do,
958
+ * Option.bind("x", () => Option.some(2)),
959
+ * Option.bind("y", () => Option.some(3)),
960
+ * Option.let("sum", ({ x, y }) => x + y),
961
+ * Option.filter(({ x, y }) => x * y > 5)
962
+ * )
963
+ * assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
964
+ *
904
965
  * @category do notation
905
966
  * @since 2.0.0
906
967
  */
907
- export const bind = /*#__PURE__*/dual(3, (self, name, f) => flatMap(self, a => map(f(a), b => Object.assign({}, a, {
908
- [name]: b
909
- }))));
968
+ export const bind = /*#__PURE__*/doNotation.bind(map, flatMap);
910
969
  /**
970
+ * The "do simulation" in allows you to write code in a more declarative style, similar to the "do notation" in other programming languages. It provides a way to define variables and perform operations on them using functions like `bind` and `let`.
971
+ *
972
+ * Here's how the do simulation works:
973
+ *
974
+ * 1. Start the do simulation using the `Do` value
975
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Option` values
976
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
977
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
978
+ * 5. Regular `Option` functions like `map` and `filter` can still be used within the do simulation. These functions will receive the accumulated variables as arguments within the scope
979
+ *
980
+ * @see {@link bindTo}
981
+ * @see {@link bind}
982
+ * @see {@link let_ let}
983
+ *
984
+ * @example
985
+ * import { Option, pipe } from "effect"
986
+ *
987
+ * const result = pipe(
988
+ * Option.Do,
989
+ * Option.bind("x", () => Option.some(2)),
990
+ * Option.bind("y", () => Option.some(3)),
991
+ * Option.let("sum", ({ x, y }) => x + y),
992
+ * Option.filter(({ x, y }) => x * y > 5)
993
+ * )
994
+ * assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
995
+ *
911
996
  * @category do notation
912
997
  * @since 2.0.0
913
998
  */