effect 3.1.1 → 3.1.3

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
@@ -7,6 +7,7 @@ exports.zipWith = exports.zipRight = exports.zipLeft = exports.void = exports.to
7
7
  var Equal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./Equal.js"));
8
8
  var Equivalence = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./Equivalence.js"));
9
9
  var _Function = /*#__PURE__*/require("./Function.js");
10
+ var doNotation = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./internal/doNotation.js"));
10
11
  var either = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./internal/either.js"));
11
12
  var option = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./internal/option.js"));
12
13
  var order = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./Order.js"));
@@ -64,11 +65,11 @@ const some = exports.some = option.some;
64
65
  * @param input - The value to check.
65
66
  *
66
67
  * @example
67
- * import { some, none, isOption } from 'effect/Option'
68
+ * import { Option } from "effect"
68
69
  *
69
- * assert.deepStrictEqual(isOption(some(1)), true)
70
- * assert.deepStrictEqual(isOption(none()), true)
71
- * assert.deepStrictEqual(isOption({}), false)
70
+ * assert.deepStrictEqual(Option.isOption(Option.some(1)), true)
71
+ * assert.deepStrictEqual(Option.isOption(Option.none()), true)
72
+ * assert.deepStrictEqual(Option.isOption({}), false)
72
73
  *
73
74
  * @category guards
74
75
  * @since 2.0.0
@@ -80,10 +81,10 @@ const isOption = exports.isOption = option.isOption;
80
81
  * @param self - The `Option` to check.
81
82
  *
82
83
  * @example
83
- * import { some, none, isNone } from 'effect/Option'
84
+ * import { Option } from "effect"
84
85
  *
85
- * assert.deepStrictEqual(isNone(some(1)), false)
86
- * assert.deepStrictEqual(isNone(none()), true)
86
+ * assert.deepStrictEqual(Option.isNone(Option.some(1)), false)
87
+ * assert.deepStrictEqual(Option.isNone(Option.none()), true)
87
88
  *
88
89
  * @category guards
89
90
  * @since 2.0.0
@@ -95,10 +96,10 @@ const isNone = exports.isNone = option.isNone;
95
96
  * @param self - The `Option` to check.
96
97
  *
97
98
  * @example
98
- * import { some, none, isSome } from 'effect/Option'
99
+ * import { Option } from "effect"
99
100
  *
100
- * assert.deepStrictEqual(isSome(some(1)), true)
101
- * assert.deepStrictEqual(isSome(none()), false)
101
+ * assert.deepStrictEqual(Option.isSome(Option.some(1)), true)
102
+ * assert.deepStrictEqual(Option.isSome(Option.none()), false)
102
103
  *
103
104
  * @category guards
104
105
  * @since 2.0.0
@@ -113,16 +114,15 @@ const isSome = exports.isSome = option.isSome;
113
114
  * @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
114
115
  *
115
116
  * @example
116
- * import { some, none, match } from 'effect/Option'
117
- * import { pipe } from "effect/Function"
117
+ * import { pipe, Option } from "effect"
118
118
  *
119
119
  * assert.deepStrictEqual(
120
- * pipe(some(1), match({ onNone: () => 'a none', onSome: (a) => `a some containing ${a}` })),
120
+ * pipe(Option.some(1), Option.match({ onNone: () => 'a none', onSome: (a) => `a some containing ${a}` })),
121
121
  * 'a some containing 1'
122
122
  * )
123
123
  *
124
124
  * assert.deepStrictEqual(
125
- * pipe(none(), match({ onNone: () => 'a none', onSome: (a) => `a some containing ${a}` })),
125
+ * pipe(Option.none(), Option.match({ onNone: () => 'a none', onSome: (a) => `a some containing ${a}` })),
126
126
  * 'a none'
127
127
  * )
128
128
  *
@@ -138,12 +138,12 @@ const match = exports.match = /*#__PURE__*/(0, _Function.dual)(2, (self, {
138
138
  * This function ensures that a type guard definition is type-safe.
139
139
  *
140
140
  * @example
141
- * import * as O from "effect/Option"
141
+ * import { Option } from "effect"
142
142
  *
143
- * const parsePositive = (n: number): O.Option<number> =>
144
- * n > 0 ? O.some(n) : O.none()
143
+ * const parsePositive = (n: number): Option.Option<number> =>
144
+ * n > 0 ? Option.some(n) : Option.none()
145
145
  *
146
- * const isPositive = O.toRefinement(parsePositive)
146
+ * const isPositive = Option.toRefinement(parsePositive)
147
147
  *
148
148
  * assert.deepStrictEqual(isPositive(1), true)
149
149
  * assert.deepStrictEqual(isPositive(-1), false)
@@ -159,10 +159,10 @@ const toRefinement = f => a => isSome(f(a));
159
159
  * @param collection - The `Iterable` to be converted to an `Option`.
160
160
  *
161
161
  * @example
162
- * import { fromIterable, some, none } from 'effect/Option'
162
+ * import { Option } from "effect"
163
163
  *
164
- * assert.deepStrictEqual(fromIterable([1, 2, 3]), some(1))
165
- * assert.deepStrictEqual(fromIterable([]), none())
164
+ * assert.deepStrictEqual(Option.fromIterable([1, 2, 3]), Option.some(1))
165
+ * assert.deepStrictEqual(Option.fromIterable([]), Option.none())
166
166
  *
167
167
  * @category constructors
168
168
  * @since 2.0.0
@@ -180,11 +180,10 @@ const fromIterable = collection => {
180
180
  * Alias of {@link fromEither}.
181
181
  *
182
182
  * @example
183
- * import * as O from "effect/Option"
184
- * import * as E from "effect/Either"
183
+ * import { Option, Either } from "effect"
185
184
  *
186
- * assert.deepStrictEqual(O.getRight(E.right('ok')), O.some('ok'))
187
- * assert.deepStrictEqual(O.getRight(E.left('err')), O.none())
185
+ * assert.deepStrictEqual(Option.getRight(Either.right('ok')), Option.some('ok'))
186
+ * assert.deepStrictEqual(Option.getRight(Either.left('err')), Option.none())
188
187
  *
189
188
  * @category conversions
190
189
  * @since 2.0.0
@@ -195,11 +194,10 @@ const getRight = exports.getRight = either.getRight;
195
194
  * Converts a `Either` to an `Option` discarding the value.
196
195
  *
197
196
  * @example
198
- * import * as O from "effect/Option"
199
- * import * as E from "effect/Either"
197
+ * import { Option, Either } from "effect"
200
198
  *
201
- * assert.deepStrictEqual(O.getLeft(E.right("ok")), O.none())
202
- * assert.deepStrictEqual(O.getLeft(E.left("a")), O.some("a"))
199
+ * assert.deepStrictEqual(Option.getLeft(Either.right("ok")), Option.none())
200
+ * assert.deepStrictEqual(Option.getLeft(Either.left("a")), Option.some("a"))
203
201
  *
204
202
  * @category conversions
205
203
  * @since 2.0.0
@@ -212,11 +210,10 @@ const getLeft = exports.getLeft = either.getLeft;
212
210
  * @param onNone - Function that returns the default value to return if the `Option` is `None`.
213
211
  *
214
212
  * @example
215
- * import { some, none, getOrElse } from 'effect/Option'
216
- * import { pipe } from "effect/Function"
213
+ * import { pipe, Option } from "effect"
217
214
  *
218
- * assert.deepStrictEqual(pipe(some(1), getOrElse(() => 0)), 1)
219
- * assert.deepStrictEqual(pipe(none(), getOrElse(() => 0)), 0)
215
+ * assert.deepStrictEqual(pipe(Option.some(1), Option.getOrElse(() => 0)), 1)
216
+ * assert.deepStrictEqual(pipe(Option.none(), Option.getOrElse(() => 0)), 0)
220
217
  *
221
218
  * @category getters
222
219
  * @since 2.0.0
@@ -229,36 +226,35 @@ const getOrElse = exports.getOrElse = /*#__PURE__*/(0, _Function.dual)(2, (self,
229
226
  * @param that - The `Option` to return if `self` is `None`.
230
227
  *
231
228
  * @example
232
- * import * as O from "effect/Option"
233
- * import { pipe } from "effect/Function"
229
+ * import { pipe, Option } from "effect"
234
230
  *
235
231
  * assert.deepStrictEqual(
236
232
  * pipe(
237
- * O.none(),
238
- * O.orElse(() => O.none())
233
+ * Option.none(),
234
+ * Option.orElse(() => Option.none())
239
235
  * ),
240
- * O.none()
236
+ * Option.none()
241
237
  * )
242
238
  * assert.deepStrictEqual(
243
239
  * pipe(
244
- * O.some('a'),
245
- * O.orElse(() => O.none())
240
+ * Option.some('a'),
241
+ * Option.orElse(() => Option.none())
246
242
  * ),
247
- * O.some('a')
243
+ * Option.some('a')
248
244
  * )
249
245
  * assert.deepStrictEqual(
250
246
  * pipe(
251
- * O.none(),
252
- * O.orElse(() => O.some('b'))
247
+ * Option.none(),
248
+ * Option.orElse(() => Option.some('b'))
253
249
  * ),
254
- * O.some('b')
250
+ * Option.some('b')
255
251
  * )
256
252
  * assert.deepStrictEqual(
257
253
  * pipe(
258
- * O.some('a'),
259
- * O.orElse(() => O.some('b'))
254
+ * Option.some('a'),
255
+ * Option.orElse(() => Option.some('b'))
260
256
  * ),
261
- * O.some('a')
257
+ * Option.some('a')
262
258
  * )
263
259
  *
264
260
  * @category error handling
@@ -272,22 +268,21 @@ const orElse = exports.orElse = /*#__PURE__*/(0, _Function.dual)(2, (self, that)
272
268
  * @param onNone - Function that returns the default value to return if the `Option` is `None`.
273
269
  *
274
270
  * @example
275
- * import * as O from "effect/Option"
276
- * import { pipe } from "effect/Function"
271
+ * import { pipe, Option } from "effect"
277
272
  *
278
273
  * assert.deepStrictEqual(
279
274
  * pipe(
280
- * O.none(),
281
- * O.orElseSome(() => 'b')
275
+ * Option.none(),
276
+ * Option.orElseSome(() => 'b')
282
277
  * ),
283
- * O.some('b')
278
+ * Option.some('b')
284
279
  * )
285
280
  * assert.deepStrictEqual(
286
281
  * pipe(
287
- * O.some('a'),
288
- * O.orElseSome(() => 'b')
282
+ * Option.some('a'),
283
+ * Option.orElseSome(() => 'b')
289
284
  * ),
290
- * O.some('a')
285
+ * Option.some('a')
291
286
  * )
292
287
  *
293
288
  * @category error handling
@@ -313,9 +308,9 @@ const orElseEither = exports.orElseEither = /*#__PURE__*/(0, _Function.dual)(2,
313
308
  * @param collection - An iterable collection of `Option` to be searched.
314
309
  *
315
310
  * @example
316
- * import * as O from "effect/Option"
311
+ * import { Option } from "effect"
317
312
  *
318
- * assert.deepStrictEqual(O.firstSomeOf([O.none(), O.some(1), O.some(2)]), O.some(1))
313
+ * assert.deepStrictEqual(Option.firstSomeOf([Option.none(), Option.some(1), Option.some(2)]), Option.some(1))
319
314
  *
320
315
  * @category error handling
321
316
  * @since 2.0.0
@@ -336,11 +331,11 @@ const firstSomeOf = collection => {
336
331
  * @param nullableValue - The nullable value to be converted to an `Option`.
337
332
  *
338
333
  * @example
339
- * import * as O from "effect/Option"
334
+ * import { Option } from "effect"
340
335
  *
341
- * assert.deepStrictEqual(O.fromNullable(undefined), O.none())
342
- * assert.deepStrictEqual(O.fromNullable(null), O.none())
343
- * assert.deepStrictEqual(O.fromNullable(1), O.some(1))
336
+ * assert.deepStrictEqual(Option.fromNullable(undefined), Option.none())
337
+ * assert.deepStrictEqual(Option.fromNullable(null), Option.none())
338
+ * assert.deepStrictEqual(Option.fromNullable(1), Option.some(1))
344
339
  *
345
340
  * @category conversions
346
341
  * @since 2.0.0
@@ -351,17 +346,17 @@ const fromNullable = nullableValue => nullableValue == null ? none() : some(null
351
346
  * This API is useful for lifting a function that returns `null` or `undefined` into the `Option` context.
352
347
  *
353
348
  * @example
354
- * import * as O from "effect/Option"
349
+ * import { Option } from "effect"
355
350
  *
356
351
  * const parse = (s: string): number | undefined => {
357
352
  * const n = parseFloat(s)
358
353
  * return isNaN(n) ? undefined : n
359
354
  * }
360
355
  *
361
- * const parseOption = O.liftNullable(parse)
356
+ * const parseOption = Option.liftNullable(parse)
362
357
  *
363
- * assert.deepStrictEqual(parseOption('1'), O.some(1))
364
- * assert.deepStrictEqual(parseOption('not a number'), O.none())
358
+ * assert.deepStrictEqual(parseOption('1'), Option.some(1))
359
+ * assert.deepStrictEqual(parseOption('not a number'), Option.none())
365
360
  *
366
361
  * @category conversions
367
362
  * @since 2.0.0
@@ -374,10 +369,10 @@ const liftNullable = f => (...a) => fromNullable(f(...a));
374
369
  * @param self - The `Option` to extract the value from.
375
370
  *
376
371
  * @example
377
- * import * as O from "effect/Option"
372
+ * import { Option } from "effect"
378
373
  *
379
- * assert.deepStrictEqual(O.getOrNull(O.some(1)), 1)
380
- * assert.deepStrictEqual(O.getOrNull(O.none()), null)
374
+ * assert.deepStrictEqual(Option.getOrNull(Option.some(1)), 1)
375
+ * assert.deepStrictEqual(Option.getOrNull(Option.none()), null)
381
376
  *
382
377
  * @category getters
383
378
  * @since 2.0.0
@@ -390,10 +385,10 @@ const getOrNull = exports.getOrNull = /*#__PURE__*/getOrElse(_Function.constNull
390
385
  * @param self - The `Option` to extract the value from.
391
386
  *
392
387
  * @example
393
- * import * as O from "effect/Option"
388
+ * import { Option } from "effect"
394
389
  *
395
- * assert.deepStrictEqual(O.getOrUndefined(O.some(1)), 1)
396
- * assert.deepStrictEqual(O.getOrUndefined(O.none()), undefined)
390
+ * assert.deepStrictEqual(Option.getOrUndefined(Option.some(1)), 1)
391
+ * assert.deepStrictEqual(Option.getOrUndefined(Option.none()), undefined)
397
392
  *
398
393
  * @category getters
399
394
  * @since 2.0.0
@@ -408,12 +403,12 @@ const getOrUndefined = exports.getOrUndefined = /*#__PURE__*/getOrElse(_Function
408
403
  * @param f - the function that can throw exceptions.
409
404
  *
410
405
  * @example
411
- * import * as O from "effect/Option"
406
+ * import { Option } from "effect"
412
407
  *
413
- * const parse = O.liftThrowable(JSON.parse)
408
+ * const parse = Option.liftThrowable(JSON.parse)
414
409
  *
415
- * assert.deepStrictEqual(parse("1"), O.some(1))
416
- * assert.deepStrictEqual(parse(""), O.none())
410
+ * assert.deepStrictEqual(parse("1"), Option.some(1))
411
+ * assert.deepStrictEqual(parse(""), Option.none())
417
412
  *
418
413
  * @category conversions
419
414
  * @since 2.0.0
@@ -434,13 +429,13 @@ const liftThrowable = f => (...a) => {
434
429
  * @param onNone - A function that will be called if the `Option` is `None`. It returns the error to be thrown.
435
430
  *
436
431
  * @example
437
- * import * as O from "effect/Option"
432
+ * import { Option } from "effect"
438
433
  *
439
434
  * assert.deepStrictEqual(
440
- * O.getOrThrowWith(O.some(1), () => new Error('Unexpected None')),
435
+ * Option.getOrThrowWith(Option.some(1), () => new Error('Unexpected None')),
441
436
  * 1
442
437
  * )
443
- * assert.throws(() => O.getOrThrowWith(O.none(), () => new Error('Unexpected None')))
438
+ * assert.throws(() => Option.getOrThrowWith(Option.none(), () => new Error('Unexpected None')))
444
439
  *
445
440
  * @category conversions
446
441
  * @since 2.0.0
@@ -461,10 +456,10 @@ const getOrThrowWith = exports.getOrThrowWith = /*#__PURE__*/(0, _Function.dual)
461
456
  * @throws `Error("getOrThrow called on a None")`
462
457
  *
463
458
  * @example
464
- * import * as O from "effect/Option"
459
+ * import { Option } from "effect"
465
460
  *
466
- * assert.deepStrictEqual(O.getOrThrow(O.some(1)), 1)
467
- * assert.throws(() => O.getOrThrow(O.none()))
461
+ * assert.deepStrictEqual(Option.getOrThrow(Option.some(1)), 1)
462
+ * assert.throws(() => Option.getOrThrow(Option.none()))
468
463
  *
469
464
  * @category conversions
470
465
  * @since 2.0.0
@@ -518,8 +513,7 @@ const andThen = exports.andThen = /*#__PURE__*/(0, _Function.dual)(2, (self, f)
518
513
  * This is `flatMap` + `fromNullable`, useful when working with optional values.
519
514
  *
520
515
  * @example
521
- * import { some, none, flatMapNullable } from 'effect/Option'
522
- * import { pipe } from "effect/Function"
516
+ * import { pipe, Option } from "effect"
523
517
  *
524
518
  * interface Employee {
525
519
  * company?: {
@@ -535,20 +529,20 @@ const andThen = exports.andThen = /*#__PURE__*/(0, _Function.dual)(2, (self, f)
535
529
  *
536
530
  * assert.deepStrictEqual(
537
531
  * pipe(
538
- * some(employee1),
539
- * flatMapNullable(employee => employee.company?.address?.street?.name),
532
+ * Option.some(employee1),
533
+ * Option.flatMapNullable(employee => employee.company?.address?.street?.name),
540
534
  * ),
541
- * some('high street')
535
+ * Option.some('high street')
542
536
  * )
543
537
  *
544
538
  * const employee2: Employee = { company: { address: { street: {} } } }
545
539
  *
546
540
  * assert.deepStrictEqual(
547
541
  * pipe(
548
- * some(employee2),
549
- * flatMapNullable(employee => employee.company?.address?.street?.name),
542
+ * Option.some(employee2),
543
+ * Option.flatMapNullable(employee => employee.company?.address?.street?.name),
550
544
  * ),
551
- * none()
545
+ * Option.none()
552
546
  * )
553
547
  *
554
548
  * @category sequencing
@@ -592,13 +586,13 @@ const zipLeft = exports.zipLeft = /*#__PURE__*/(0, _Function.dual)(2, (self, tha
592
586
  * @param self - The `Option` to apply the function to
593
587
  *
594
588
  * @example
595
- * import * as O from "effect/Option"
589
+ * import { Option } from "effect"
596
590
  *
597
- * const getInteger = (n: number) => Number.isInteger(n) ? O.some(n) : O.none()
591
+ * const getInteger = (n: number) => Number.isInteger(n) ? Option.some(n) : Option.none()
598
592
  *
599
- * assert.deepStrictEqual(O.tap(O.none(), getInteger), O.none())
600
- * assert.deepStrictEqual(O.tap(O.some(1), getInteger), O.some(1))
601
- * assert.deepStrictEqual(O.tap(O.some(1.14), getInteger), O.none())
593
+ * assert.deepStrictEqual(Option.tap(Option.none(), getInteger), Option.none())
594
+ * assert.deepStrictEqual(Option.tap(Option.some(1), getInteger), Option.some(1))
595
+ * assert.deepStrictEqual(Option.tap(Option.some(1.14), getInteger), Option.none())
602
596
  *
603
597
  * @category sequencing
604
598
  * @since 2.0.0
@@ -637,11 +631,11 @@ const productMany = (self, collection) => {
637
631
  * @param fields - the struct of `Option`s to be sequenced.
638
632
  *
639
633
  * @example
640
- * import * as O from "effect/Option"
634
+ * import { Option } from "effect"
641
635
  *
642
- * assert.deepStrictEqual(O.all([O.some(1), O.some(2)]), O.some([1, 2]))
643
- * assert.deepStrictEqual(O.all({ a: O.some(1), b: O.some("hello") }), O.some({ a: 1, b: "hello" }))
644
- * assert.deepStrictEqual(O.all({ a: O.some(1), b: O.none() }), O.none())
636
+ * assert.deepStrictEqual(Option.all([Option.some(1), Option.some(2)]), Option.some([1, 2]))
637
+ * assert.deepStrictEqual(Option.all({ a: Option.some(1), b: Option.some("hello") }), Option.some({ a: 1, b: "hello" }))
638
+ * assert.deepStrictEqual(Option.all({ a: Option.some(1), b: Option.none() }), Option.none())
645
639
  *
646
640
  * @category combining
647
641
  * @since 2.0.0
@@ -677,18 +671,18 @@ const all = input => {
677
671
  * @param f - The function used to combine the values of the two `Option`s
678
672
  *
679
673
  * @example
680
- * import * as O from "effect/Option"
674
+ * import { Option } from "effect"
681
675
  *
682
676
  * type Complex = [real: number, imaginary: number]
683
677
  *
684
678
  * const complex = (real: number, imaginary: number): Complex => [real, imaginary]
685
679
  *
686
- * assert.deepStrictEqual(O.zipWith(O.none(), O.none(), complex), O.none())
687
- * assert.deepStrictEqual(O.zipWith(O.some(1), O.none(), complex), O.none())
688
- * assert.deepStrictEqual(O.zipWith(O.none(), O.some(1), complex), O.none())
689
- * assert.deepStrictEqual(O.zipWith(O.some(1), O.some(2), complex), O.some([1, 2]))
680
+ * assert.deepStrictEqual(Option.zipWith(Option.none(), Option.none(), complex), Option.none())
681
+ * assert.deepStrictEqual(Option.zipWith(Option.some(1), Option.none(), complex), Option.none())
682
+ * assert.deepStrictEqual(Option.zipWith(Option.none(), Option.some(1), complex), Option.none())
683
+ * assert.deepStrictEqual(Option.zipWith(Option.some(1), Option.some(2), complex), Option.some([1, 2]))
690
684
  *
691
- * assert.deepStrictEqual(O.zipWith(O.some(1), complex)(O.some(2)), O.some([2, 1]))
685
+ * assert.deepStrictEqual(Option.zipWith(Option.some(1), complex)(Option.some(2)), Option.some([2, 1]))
692
686
  *
693
687
  * @category zipping
694
688
  * @since 2.0.0
@@ -708,11 +702,10 @@ const ap = exports.ap = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => zipW
708
702
  * @param f - The reducing function that takes the current accumulator value and the unwrapped value of an `Option<A>`.
709
703
  *
710
704
  * @example
711
- * import { some, none, reduceCompact } from 'effect/Option'
712
- * import { pipe } from "effect/Function"
705
+ * import { pipe, Option } from "effect"
713
706
  *
714
- * const iterable = [some(1), none(), some(2), none()]
715
- * assert.deepStrictEqual(pipe(iterable, reduceCompact(0, (b, a) => b + a)), 3)
707
+ * const iterable = [Option.some(1), Option.none(), Option.some(2), Option.none()]
708
+ * assert.deepStrictEqual(pipe(iterable, Option.reduceCompact(0, (b, a) => b + a)), 3)
716
709
  *
717
710
  * @category folding
718
711
  * @since 2.0.0
@@ -734,10 +727,10 @@ const reduceCompact = exports.reduceCompact = /*#__PURE__*/(0, _Function.dual)(3
734
727
  * @param self - The `Option` to convert to an array.
735
728
  *
736
729
  * @example
737
- * import * as O from "effect/Option"
730
+ * import { Option } from "effect"
738
731
  *
739
- * assert.deepStrictEqual(O.toArray(O.some(1)), [1])
740
- * assert.deepStrictEqual(O.toArray(O.none()), [])
732
+ * assert.deepStrictEqual(Option.toArray(Option.some(1)), [1])
733
+ * assert.deepStrictEqual(Option.toArray(Option.none()), [])
741
734
  *
742
735
  * @category conversions
743
736
  * @since 2.0.0
@@ -764,13 +757,13 @@ const partitionMap = exports.partitionMap = /*#__PURE__*/(0, _Function.dual)(2,
764
757
  * @param f - A function to apply to the value of the `Option`.
765
758
  *
766
759
  * @example
767
- * import * as O from "effect/Option"
760
+ * import { Option } from "effect"
768
761
  *
769
- * const evenNumber = (n: number) => n % 2 === 0 ? O.some(n) : O.none()
762
+ * const evenNumber = (n: number) => n % 2 === 0 ? Option.some(n) : Option.none()
770
763
  *
771
- * assert.deepStrictEqual(O.filterMap(O.none(), evenNumber), O.none())
772
- * assert.deepStrictEqual(O.filterMap(O.some(3), evenNumber), O.none())
773
- * assert.deepStrictEqual(O.filterMap(O.some(2), evenNumber), O.some(2))
764
+ * assert.deepStrictEqual(Option.filterMap(Option.none(), evenNumber), Option.none())
765
+ * assert.deepStrictEqual(Option.filterMap(Option.some(3), evenNumber), Option.none())
766
+ * assert.deepStrictEqual(Option.filterMap(Option.some(2), evenNumber), Option.some(2))
774
767
  *
775
768
  * @category filtering
776
769
  * @since 2.0.0
@@ -785,21 +778,21 @@ const filterMap = exports.filterMap = /*#__PURE__*/(0, _Function.dual)(2, (self,
785
778
  * @param fb - The `Option` to filter.
786
779
  *
787
780
  * @example
788
- * import * as O from "effect/Option"
781
+ * import { Option } from "effect"
789
782
  *
790
783
  * // predicate
791
784
  * const isEven = (n: number) => n % 2 === 0
792
785
  *
793
- * assert.deepStrictEqual(O.filter(O.none(), isEven), O.none())
794
- * assert.deepStrictEqual(O.filter(O.some(3), isEven), O.none())
795
- * assert.deepStrictEqual(O.filter(O.some(2), isEven), O.some(2))
786
+ * assert.deepStrictEqual(Option.filter(Option.none(), isEven), Option.none())
787
+ * assert.deepStrictEqual(Option.filter(Option.some(3), isEven), Option.none())
788
+ * assert.deepStrictEqual(Option.filter(Option.some(2), isEven), Option.some(2))
796
789
  *
797
790
  * // refinement
798
791
  * const isNumber = (v: unknown): v is number => typeof v === "number"
799
792
  *
800
- * assert.deepStrictEqual(O.filter(O.none(), isNumber), O.none())
801
- * assert.deepStrictEqual(O.filter(O.some('hello'), isNumber), O.none())
802
- * assert.deepStrictEqual(O.filter(O.some(2), isNumber), O.some(2))
793
+ * assert.deepStrictEqual(Option.filter(Option.none(), isNumber), Option.none())
794
+ * assert.deepStrictEqual(Option.filter(Option.some('hello'), isNumber), Option.none())
795
+ * assert.deepStrictEqual(Option.filter(Option.some(2), isNumber), Option.some(2))
803
796
  *
804
797
  * @category filtering
805
798
  * @since 2.0.0
@@ -807,15 +800,14 @@ const filterMap = exports.filterMap = /*#__PURE__*/(0, _Function.dual)(2, (self,
807
800
  const filter = exports.filter = /*#__PURE__*/(0, _Function.dual)(2, (self, predicate) => filterMap(self, b => predicate(b) ? option.some(b) : option.none));
808
801
  /**
809
802
  * @example
810
- * import { none, some, getEquivalence } from 'effect/Option'
811
- * import * as N from 'effect/Number'
803
+ * import { Option, Number } from "effect"
812
804
  *
813
- * const isEquivalent = getEquivalence(N.Equivalence)
814
- * assert.deepStrictEqual(isEquivalent(none(), none()), true)
815
- * assert.deepStrictEqual(isEquivalent(none(), some(1)), false)
816
- * assert.deepStrictEqual(isEquivalent(some(1), none()), false)
817
- * assert.deepStrictEqual(isEquivalent(some(1), some(2)), false)
818
- * assert.deepStrictEqual(isEquivalent(some(1), some(1)), true)
805
+ * const isEquivalent = Option.getEquivalence(Number.Equivalence)
806
+ * assert.deepStrictEqual(isEquivalent(Option.none(), Option.none()), true)
807
+ * assert.deepStrictEqual(isEquivalent(Option.none(), Option.some(1)), false)
808
+ * assert.deepStrictEqual(isEquivalent(Option.some(1), Option.none()), false)
809
+ * assert.deepStrictEqual(isEquivalent(Option.some(1), Option.some(2)), false)
810
+ * assert.deepStrictEqual(isEquivalent(Option.some(1), Option.some(1)), true)
819
811
  *
820
812
  * @category equivalence
821
813
  * @since 2.0.0
@@ -829,16 +821,14 @@ const getEquivalence = isEquivalent => Equivalence.make((x, y) => x === y || (is
829
821
  * `None` is considered to be less than any `Some` value.
830
822
  *
831
823
  * @example
832
- * import { none, some, getOrder } from 'effect/Option'
833
- * import * as N from 'effect/Number'
834
- * import { pipe } from "effect/Function"
824
+ * import { pipe, Option, Number } from "effect"
835
825
  *
836
- * const O = getOrder(N.Order)
837
- * assert.deepStrictEqual(O(none(), none()), 0)
838
- * assert.deepStrictEqual(O(none(), some(1)), -1)
839
- * assert.deepStrictEqual(O(some(1), none()), 1)
840
- * assert.deepStrictEqual(O(some(1), some(2)), -1)
841
- * assert.deepStrictEqual(O(some(1), some(1)), 0)
826
+ * const O = Option.getOrder(Number.Order)
827
+ * assert.deepStrictEqual(O(Option.none(), Option.none()), 0)
828
+ * assert.deepStrictEqual(O(Option.none(), Option.some(1)), -1)
829
+ * assert.deepStrictEqual(O(Option.some(1), Option.none()), 1)
830
+ * assert.deepStrictEqual(O(Option.some(1), Option.some(2)), -1)
831
+ * assert.deepStrictEqual(O(Option.some(1), Option.some(1)), 0)
842
832
  *
843
833
  * @category sorting
844
834
  * @since 2.0.0
@@ -862,12 +852,12 @@ const lift2 = f => (0, _Function.dual)(2, (self, that) => zipWith(self, that, f)
862
852
  * @param predicate - A `Predicate` function that takes in a value of type `A` and returns a boolean.
863
853
  *
864
854
  * @example
865
- * import * as O from "effect/Option"
855
+ * import { Option } from "effect"
866
856
  *
867
- * const getOption = O.liftPredicate((n: number) => n >= 0)
857
+ * const getOption = Option.liftPredicate((n: number) => n >= 0)
868
858
  *
869
- * assert.deepStrictEqual(getOption(-1), O.none())
870
- * assert.deepStrictEqual(getOption(1), O.some(1))
859
+ * assert.deepStrictEqual(getOption(-1), Option.none())
860
+ * assert.deepStrictEqual(getOption(1), Option.some(1))
871
861
  *
872
862
  * @category lifting
873
863
  * @since 2.0.0
@@ -882,13 +872,11 @@ const liftPredicate = predicate => b => predicate(b) ? some(b) : none();
882
872
  * @param a - The value to compare against the `Option`.
883
873
  *
884
874
  * @example
885
- * import { some, none, containsWith } from 'effect/Option'
886
- * import { Equivalence } from 'effect/Number'
887
- * import { pipe } from "effect/Function"
875
+ * import { pipe, Option, Number } from "effect"
888
876
  *
889
- * assert.deepStrictEqual(pipe(some(2), containsWith(Equivalence)(2)), true)
890
- * assert.deepStrictEqual(pipe(some(1), containsWith(Equivalence)(2)), false)
891
- * assert.deepStrictEqual(pipe(none(), containsWith(Equivalence)(2)), false)
877
+ * assert.deepStrictEqual(pipe(Option.some(2), Option.containsWith(Number.Equivalence)(2)), true)
878
+ * assert.deepStrictEqual(pipe(Option.some(1), Option.containsWith(Number.Equivalence)(2)), false)
879
+ * assert.deepStrictEqual(pipe(Option.none(), Option.containsWith(Number.Equivalence)(2)), false)
892
880
  *
893
881
  * @category elements
894
882
  * @since 2.0.0
@@ -911,14 +899,13 @@ const contains = exports.contains = /*#__PURE__*/containsWith(_equivalence);
911
899
  * @param predicate - The condition to check.
912
900
  *
913
901
  * @example
914
- * import { some, none, exists } from 'effect/Option'
915
- * import { pipe } from "effect/Function"
902
+ * import { pipe, Option } from "effect"
916
903
  *
917
904
  * const isEven = (n: number) => n % 2 === 0
918
905
  *
919
- * assert.deepStrictEqual(pipe(some(2), exists(isEven)), true)
920
- * assert.deepStrictEqual(pipe(some(1), exists(isEven)), false)
921
- * assert.deepStrictEqual(pipe(none(), exists(isEven)), false)
906
+ * assert.deepStrictEqual(pipe(Option.some(2), Option.exists(isEven)), true)
907
+ * assert.deepStrictEqual(pipe(Option.some(1), Option.exists(isEven)), false)
908
+ * assert.deepStrictEqual(pipe(Option.none(), Option.exists(isEven)), false)
922
909
  *
923
910
  * @since 2.0.0
924
911
  */
@@ -927,23 +914,95 @@ const exists = exports.exists = /*#__PURE__*/(0, _Function.dual)(2, (self, refin
927
914
  // do notation
928
915
  // -------------------------------------------------------------------------------------
929
916
  /**
917
+ * 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`.
918
+ *
919
+ * Here's how the do simulation works:
920
+ *
921
+ * 1. Start the do simulation using the `Do` value
922
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Option` values
923
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
924
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
925
+ * 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
926
+ *
927
+ * @see {@link Do}
928
+ * @see {@link bind}
929
+ * @see {@link let_ let}
930
+ *
931
+ * @example
932
+ * import { Option, pipe } from "effect"
933
+ *
934
+ * const result = pipe(
935
+ * Option.Do,
936
+ * Option.bind("x", () => Option.some(2)),
937
+ * Option.bind("y", () => Option.some(3)),
938
+ * Option.let("sum", ({ x, y }) => x + y),
939
+ * Option.filter(({ x, y }) => x * y > 5)
940
+ * )
941
+ * assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
942
+ *
930
943
  * @category do notation
931
944
  * @since 2.0.0
932
945
  */
933
- const bindTo = exports.bindTo = /*#__PURE__*/(0, _Function.dual)(2, (self, name) => map(self, a => ({
934
- [name]: a
935
- })));
936
- const let_ = exports.let = /*#__PURE__*/(0, _Function.dual)(3, (self, name, f) => map(self, a => Object.assign({}, a, {
937
- [name]: f(a)
938
- })));
946
+ const bindTo = exports.bindTo = /*#__PURE__*/doNotation.bindTo(map);
947
+ const let_ = exports.let = /*#__PURE__*/doNotation.let_(map);
939
948
  /**
949
+ * 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`.
950
+ *
951
+ * Here's how the do simulation works:
952
+ *
953
+ * 1. Start the do simulation using the `Do` value
954
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Option` values
955
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
956
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
957
+ * 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
958
+ *
959
+ * @see {@link Do}
960
+ * @see {@link bindTo}
961
+ * @see {@link let_ let}
962
+ *
963
+ * @example
964
+ * import { Option, pipe } from "effect"
965
+ *
966
+ * const result = pipe(
967
+ * Option.Do,
968
+ * Option.bind("x", () => Option.some(2)),
969
+ * Option.bind("y", () => Option.some(3)),
970
+ * Option.let("sum", ({ x, y }) => x + y),
971
+ * Option.filter(({ x, y }) => x * y > 5)
972
+ * )
973
+ * assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
974
+ *
940
975
  * @category do notation
941
976
  * @since 2.0.0
942
977
  */
943
- const bind = exports.bind = /*#__PURE__*/(0, _Function.dual)(3, (self, name, f) => flatMap(self, a => map(f(a), b => Object.assign({}, a, {
944
- [name]: b
945
- }))));
978
+ const bind = exports.bind = /*#__PURE__*/doNotation.bind(map, flatMap);
946
979
  /**
980
+ * 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`.
981
+ *
982
+ * Here's how the do simulation works:
983
+ *
984
+ * 1. Start the do simulation using the `Do` value
985
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Option` values
986
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
987
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
988
+ * 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
989
+ *
990
+ * @see {@link bindTo}
991
+ * @see {@link bind}
992
+ * @see {@link let_ let}
993
+ *
994
+ * @example
995
+ * import { Option, pipe } from "effect"
996
+ *
997
+ * const result = pipe(
998
+ * Option.Do,
999
+ * Option.bind("x", () => Option.some(2)),
1000
+ * Option.bind("y", () => Option.some(3)),
1001
+ * Option.let("sum", ({ x, y }) => x + y),
1002
+ * Option.filter(({ x, y }) => x * y > 5)
1003
+ * )
1004
+ * assert.deepStrictEqual(result, Option.some({ x: 2, y: 3, sum: 5 }))
1005
+ *
947
1006
  * @category do notation
948
1007
  * @since 2.0.0
949
1008
  */