From 22ec27a4aafe5f473f2feeefd2b5990bc7554951 Mon Sep 17 00:00:00 2001 From: Maxwell Brown Date: Tue, 16 Dec 2025 15:05:52 -0500 Subject: [PATCH] Un-nest the `/collections` modules (#833) --- bundle/batching.ts | 2 +- .../effect/benchmark/schema/tagged-union.ts | 2 +- .../effect/dtslint/collections/Array.tst.ts | 2 +- packages/effect/dtslint/schema/Union.tst.ts | 2 +- packages/effect/package.json | 2 - .../effect/src/{collections => }/Array.ts | 314 +++++++-------- packages/effect/src/Brand.ts | 2 +- packages/effect/src/Cache.ts | 4 +- packages/effect/src/Channel.ts | 10 +- packages/effect/src/ChannelSchema.ts | 2 +- .../effect/src/{collections => }/Chunk.ts | 220 +++++------ packages/effect/src/Cron.ts | 2 +- packages/effect/src/DateTime.ts | 2 +- packages/effect/src/Effect.ts | 2 +- packages/effect/src/Equivalence.ts | 2 +- packages/effect/src/ExecutionPlan.ts | 2 +- packages/effect/src/FiberMap.ts | 4 +- packages/effect/src/FiberSet.ts | 2 +- packages/effect/src/Function.ts | 2 +- .../effect/src/{collections => }/Graph.ts | 142 +++---- .../effect/src/{collections => }/HashMap.ts | 100 ++--- .../effect/src/{collections => }/HashRing.ts | 12 +- .../effect/src/{collections => }/HashSet.ts | 56 +-- .../effect/src/{collections => }/Iterable.ts | 120 +++--- packages/effect/src/Layer.ts | 2 +- packages/effect/src/Logger.ts | 2 +- packages/effect/src/Metric.ts | 2 +- .../src/{collections => }/MutableHashMap.ts | 46 +-- .../src/{collections => }/MutableHashSet.ts | 30 +- .../src/{collections => }/MutableList.ts | 38 +- .../src/{collections => }/NonEmptyIterable.ts | 28 +- packages/effect/src/Pool.ts | 2 +- packages/effect/src/PubSub.ts | 4 +- packages/effect/src/Queue.ts | 4 +- packages/effect/src/RcMap.ts | 4 +- packages/effect/src/RequestResolver.ts | 8 +- packages/effect/src/ScopedCache.ts | 4 +- packages/effect/src/Sink.ts | 6 +- packages/effect/src/Stream.ts | 8 +- packages/effect/src/String.ts | 2 +- packages/effect/src/Take.ts | 2 +- packages/effect/src/{collections => }/Trie.ts | 70 ++-- packages/effect/src/collections/index.ts | 371 ------------------ packages/effect/src/collections/index.ts.tpl | 3 - packages/effect/src/index.ts | 370 ++++++++++++++++- packages/effect/src/interfaces/Equal.ts | 2 +- packages/effect/src/internal/arbitrary.ts | 2 +- packages/effect/src/internal/array.ts | 2 +- packages/effect/src/internal/effect.ts | 2 +- packages/effect/src/internal/request.ts | 2 +- packages/effect/src/internal/trie.ts | 2 +- packages/effect/src/platform/FileSystem.ts | 2 +- packages/effect/src/schema/AST.ts | 2 +- packages/effect/src/schema/FromJsonSchema.ts | 2 +- packages/effect/src/schema/Parser.ts | 2 +- packages/effect/src/schema/Schema.ts | 2 +- packages/effect/src/schema/Standard.ts | 2 +- packages/effect/src/stm/TxChunk.ts | 38 +- packages/effect/src/stm/TxHashMap.ts | 6 +- packages/effect/src/stm/TxHashSet.ts | 8 +- packages/effect/src/stm/TxQueue.ts | 4 +- packages/effect/src/testing/TestClock.ts | 2 +- packages/effect/src/testing/TestConsole.ts | 2 +- packages/effect/src/unstable/ai/McpServer.ts | 2 +- packages/effect/src/unstable/ai/Prompt.ts | 2 +- packages/effect/src/unstable/cli/Prompt.ts | 2 +- .../effect/src/unstable/cluster/Entity.ts | 2 +- .../src/unstable/cluster/MessageStorage.ts | 2 +- packages/effect/src/unstable/cluster/Reply.ts | 2 +- .../src/unstable/cluster/RunnerStorage.ts | 4 +- .../effect/src/unstable/cluster/Sharding.ts | 8 +- .../src/unstable/cluster/SqlMessageStorage.ts | 2 +- .../src/unstable/cluster/SqlRunnerStorage.ts | 2 +- .../cluster/internal/entityManager.ts | 2 +- .../unstable/cluster/internal/resourceMap.ts | 2 +- .../effect/src/unstable/encoding/Msgpack.ts | 2 +- .../effect/src/unstable/encoding/Ndjson.ts | 2 +- packages/effect/src/unstable/encoding/Sse.ts | 4 +- .../effect/src/unstable/http/HttpClient.ts | 2 +- .../effect/src/unstable/http/HttpRouter.ts | 2 +- .../src/unstable/http/HttpServerRequest.ts | 2 +- .../effect/src/unstable/http/Multipart.ts | 2 +- .../effect/src/unstable/http/UrlParams.ts | 2 +- .../effect/src/unstable/httpapi/HttpApi.ts | 2 +- .../src/unstable/httpapi/HttpApiGroup.ts | 2 +- .../src/unstable/httpapi/HttpApiSchema.ts | 2 +- .../effect/src/unstable/httpapi/OpenApi.ts | 2 +- .../src/unstable/jsonschema/Rewriter.ts | 2 +- .../src/unstable/observability/OtlpLogger.ts | 2 +- .../src/unstable/observability/OtlpMetrics.ts | 2 +- .../unstable/persistence/PersistedQueue.ts | 4 +- .../src/unstable/persistence/Persistence.ts | 2 +- packages/effect/src/unstable/rpc/RpcClient.ts | 2 +- .../effect/src/unstable/rpc/RpcMessage.ts | 2 +- packages/effect/src/unstable/rpc/RpcServer.ts | 2 +- packages/effect/src/unstable/socket/Socket.ts | 2 +- packages/effect/src/unstable/sql/Migrator.ts | 2 +- .../effect/src/unstable/sql/SqlResolver.ts | 4 +- packages/effect/src/unstable/sql/SqlSchema.ts | 2 +- .../effect/src/unstable/workflow/Activity.ts | 2 +- .../src/unstable/workflow/DurableDeferred.ts | 2 +- .../src/unstable/workflow/WorkflowProxy.ts | 2 +- .../unstable/workflow/WorkflowProxyServer.ts | 2 +- .../test/{collections => }/Array.test.ts | 3 +- packages/effect/test/Channel.test.ts | 2 +- .../test/{collections => }/Chunk.test.ts | 3 +- packages/effect/test/Equal.test.ts | 2 +- packages/effect/test/ExecutionPlan.test.ts | 3 +- packages/effect/test/FiberMap.test.ts | 3 +- packages/effect/test/FiberSet.test.ts | 3 +- .../test/{collections => }/Graph.test.ts | 3 +- packages/effect/test/HashMap.test.ts | 3 +- packages/effect/test/HashSet.test.ts | 2 +- .../test/{collections => }/Iterable.test.ts | 3 +- .../{collections => }/MutableHashMap.test.ts | 3 +- .../{collections => }/Pathfinding.test.ts | 3 +- packages/effect/test/PubSub.test.ts | 3 +- packages/effect/test/Redacted.test.ts | 3 +- packages/effect/test/Result.test.ts | 3 +- packages/effect/test/Schedule.test.ts | 3 +- packages/effect/test/Sink.test.ts | 3 +- packages/effect/test/Stream.test.ts | 4 +- packages/effect/test/SubscriptionRef.test.ts | 3 +- .../test/{collections => }/Trie.test.ts | 2 +- packages/effect/test/TxChunk.test.ts | 3 +- packages/effect/test/TxHashMap.test.ts | 3 +- packages/effect/test/TxHashSet.test.ts | 2 +- packages/effect/test/TxQueue.test.ts | 3 +- packages/effect/test/batching/Request.test.ts | 3 +- packages/effect/test/cluster/Sharding.test.ts | 3 +- .../unstable/cli/services/MockTerminal.ts | 2 +- .../test/unstable/cli/services/TestActions.ts | 3 +- .../observability/OtlpMetrics.test.ts | 3 +- .../effect/test/utils/chunkCoordination.ts | 2 +- packages/platform-bun/src/BunStream.ts | 2 +- .../src/NodeChildProcessSpawner.ts | 2 +- packages/platform-node-shared/src/NodeSink.ts | 2 +- .../platform-node-shared/src/NodeSocket.ts | 2 +- .../platform-node-shared/src/NodeStream.ts | 2 +- .../src/internal/process.ts | 2 +- .../test/NodeFileSystem.test.ts | 3 +- .../test/NodeStream.test.ts | 2 +- packages/platform-node/test/HttpApi.test.ts | 3 +- packages/sql/d1/test/Resolver.test.ts | 3 +- packages/sql/libsql/test/Resolver.test.ts | 3 +- packages/sql/pg/src/PgClient.ts | 2 +- .../sql/sqlite-node/test/Resolver.test.ts | 3 +- scripts/codemod.mjs | 2 +- scripts/eslint-examples.ts | 5 +- 149 files changed, 1140 insertions(+), 1179 deletions(-) rename packages/effect/src/{collections => }/Array.ts (93%) rename packages/effect/src/{collections => }/Chunk.ts (93%) rename packages/effect/src/{collections => }/Graph.ts (97%) rename packages/effect/src/{collections => }/HashMap.ts (91%) rename packages/effect/src/{collections => }/HashRing.ts (96%) rename packages/effect/src/{collections => }/HashSet.ts (90%) rename packages/effect/src/{collections => }/Iterable.ts (95%) rename packages/effect/src/{collections => }/MutableHashMap.ts (92%) rename packages/effect/src/{collections => }/MutableHashSet.ts (91%) rename packages/effect/src/{collections => }/MutableList.ts (95%) rename packages/effect/src/{collections => }/NonEmptyIterable.ts (92%) rename packages/effect/src/{collections => }/Trie.ts (92%) delete mode 100644 packages/effect/src/collections/index.ts delete mode 100644 packages/effect/src/collections/index.ts.tpl rename packages/effect/test/{collections => }/Array.test.ts (99%) rename packages/effect/test/{collections => }/Chunk.test.ts (99%) rename packages/effect/test/{collections => }/Graph.test.ts (99%) rename packages/effect/test/{collections => }/Iterable.test.ts (99%) rename packages/effect/test/{collections => }/MutableHashMap.test.ts (98%) rename packages/effect/test/{collections => }/Pathfinding.test.ts (99%) rename packages/effect/test/{collections => }/Trie.test.ts (99%) diff --git a/bundle/batching.ts b/bundle/batching.ts index c46ec219a9..486a2a7f17 100644 --- a/bundle/batching.ts +++ b/bundle/batching.ts @@ -1,4 +1,4 @@ -import * as Array from "#dist/effect/collections/Array" +import * as Array from "#dist/effect/Array" import * as Effect from "#dist/effect/Effect" import * as Exit from "#dist/effect/Exit" import * as Request from "#dist/effect/Request" diff --git a/packages/effect/benchmark/schema/tagged-union.ts b/packages/effect/benchmark/schema/tagged-union.ts index 4f7a9b363b..4f596c14e7 100644 --- a/packages/effect/benchmark/schema/tagged-union.ts +++ b/packages/effect/benchmark/schema/tagged-union.ts @@ -1,4 +1,4 @@ -import { Array as RA } from "effect/collections" +import { Array as RA } from "effect" import { Schema } from "effect/schema" import { Bench } from "tinybench" diff --git a/packages/effect/dtslint/collections/Array.tst.ts b/packages/effect/dtslint/collections/Array.tst.ts index abb9480d82..f6d8c9fb74 100644 --- a/packages/effect/dtslint/collections/Array.tst.ts +++ b/packages/effect/dtslint/collections/Array.tst.ts @@ -1,4 +1,4 @@ -import { Array } from "effect/collections" +import { Array } from "effect" import { hole, pipe } from "effect/Function" import { describe, expect, it } from "tstyche" diff --git a/packages/effect/dtslint/schema/Union.tst.ts b/packages/effect/dtslint/schema/Union.tst.ts index 3a08d5b300..28634c5dc5 100644 --- a/packages/effect/dtslint/schema/Union.tst.ts +++ b/packages/effect/dtslint/schema/Union.tst.ts @@ -1,5 +1,5 @@ import { Tuple } from "effect" -import type { Array as Arr } from "effect/collections" +import type { Array as Arr } from "effect" import { Schema } from "effect/schema" import { describe, expect, it } from "tstyche" diff --git a/packages/effect/package.json b/packages/effect/package.json index 9bdfe251e5..728a1ed0cb 100644 --- a/packages/effect/package.json +++ b/packages/effect/package.json @@ -29,7 +29,6 @@ "exports": { "./package.json": "./package.json", ".": "./src/index.ts", - "./collections": "./src/collections/index.ts", "./encoding": "./src/encoding/index.ts", "./interfaces": "./src/interfaces/index.ts", "./optic": "./src/optic/index.ts", @@ -72,7 +71,6 @@ "exports": { "./package.json": "./package.json", ".": "./dist/index.js", - "./collections": "./dist/collections/index.js", "./encoding": "./dist/encoding/index.js", "./interfaces": "./dist/interfaces/index.js", "./optic": "./dist/optic/index.js", diff --git a/packages/effect/src/collections/Array.ts b/packages/effect/src/Array.ts similarity index 93% rename from packages/effect/src/collections/Array.ts rename to packages/effect/src/Array.ts index d220255bb2..335342bbd0 100644 --- a/packages/effect/src/collections/Array.ts +++ b/packages/effect/src/Array.ts @@ -3,30 +3,30 @@ * * @since 2.0.0 */ -import * as moduleIterable from "../collections/Iterable.ts" -import * as Equivalence from "../Equivalence.ts" -import * as Filter from "../Filter.ts" -import type { LazyArg } from "../Function.ts" -import { dual, identity } from "../Function.ts" -import * as Equal from "../interfaces/Equal.ts" -import * as internalArray from "../internal/array.ts" -import * as internalDoNotation from "../internal/doNotation.ts" -import * as Option from "../Option.ts" -import * as Order from "../Order.ts" -import type * as Predicate from "../Predicate.ts" -import * as Record from "../Record.ts" -import * as Reducer from "../Reducer.ts" -import * as Result from "../Result.ts" -import * as Tuple from "../Tuple.ts" -import type { TypeLambda } from "../types/HKT.ts" -import type { NoInfer, TupleOf } from "../types/Types.ts" +import * as Equivalence from "./Equivalence.ts" +import * as Filter from "./Filter.ts" +import type { LazyArg } from "./Function.ts" +import { dual, identity } from "./Function.ts" +import * as Equal from "./interfaces/Equal.ts" +import * as internalArray from "./internal/array.ts" +import * as internalDoNotation from "./internal/doNotation.ts" +import * as moduleIterable from "./Iterable.ts" +import * as Option from "./Option.ts" +import * as Order from "./Order.ts" +import type * as Predicate from "./Predicate.ts" +import * as Record from "./Record.ts" +import * as Reducer from "./Reducer.ts" +import * as Result from "./Result.ts" +import * as Tuple from "./Tuple.ts" +import type { TypeLambda } from "./types/HKT.ts" +import type { NoInfer, TupleOf } from "./types/Types.ts" /** * Reference to the global Array constructor. * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const arr = new Array.Array(3) * console.log(arr) // [undefined, undefined, undefined] @@ -43,7 +43,7 @@ export const Array = globalThis.Array * @example * ```ts * import type { Kind } from "effect/types/HKT" - * import type { ReadonlyArrayTypeLambda } from "effect/collections/Array" + * import type { ReadonlyArrayTypeLambda } from "effect/Array" * * // Create a ReadonlyArray type using the type lambda * type NumberArray = Kind @@ -62,7 +62,7 @@ export interface ReadonlyArrayTypeLambda extends TypeLambda { * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const nonEmpty: Array.NonEmptyReadonlyArray = [1, 2, 3] * const head = nonEmpty[0] // 1 (guaranteed to exist) @@ -78,7 +78,7 @@ export type NonEmptyReadonlyArray = readonly [A, ...Array] * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const nonEmpty: Array.NonEmptyArray = [1, 2, 3] * nonEmpty.push(4) // Mutable operations are allowed @@ -94,7 +94,7 @@ export type NonEmptyArray = [A, ...Array] * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.make(1, 2, 3) * console.log(result) // [1, 2, 3] @@ -112,7 +112,7 @@ export const make = >( * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.allocate(3) * console.log(result) // [ <3 empty items> ] @@ -130,7 +130,7 @@ export const allocate = (n: number): Array => new Arra * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.makeBy(5, n => n * 2) * console.log(result) // [0, 2, 4, 6, 8] @@ -156,7 +156,7 @@ export const makeBy: { * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.range(1, 3) * console.log(result) // [1, 2, 3] @@ -175,7 +175,7 @@ export const range = (start: number, end: number): NonEmptyArray => * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.replicate("a", 3) * console.log(result) // ["a", "a", "a"] @@ -196,7 +196,7 @@ export const replicate: { * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.fromIterable(new Set([1, 2, 3])) * console.log(result) // [1, 2, 3] @@ -213,7 +213,7 @@ export const fromIterable = (collection: Iterable): Array => * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * console.log(Array.ensure("a")) // ["a"] * console.log(Array.ensure(["a"])) // ["a"] @@ -230,7 +230,7 @@ export const ensure = (self: ReadonlyArray | A): Array => Array.isArray * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.fromRecord({ a: 1, b: 2, c: 3 }) * console.log(result) // [["a", 1], ["b", 2], ["c", 3]] @@ -246,7 +246,7 @@ export const fromRecord: (self: Readonly>) => * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * import * as Option from "effect/Option" * * console.log(Array.fromOption(Option.some(1))) // [1] @@ -263,7 +263,7 @@ export const fromOption: (self: Option.Option) => Array = Option.toArra * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const match = Array.match({ * onEmpty: () => "empty", @@ -303,7 +303,7 @@ export const match: { * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const matchLeft = Array.matchLeft({ * onEmpty: () => "empty", @@ -343,7 +343,7 @@ export const matchLeft: { * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const matchRight = Array.matchRight({ * onEmpty: () => "empty", @@ -386,7 +386,7 @@ export const matchRight: { * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.prepend([2, 3, 4], 1) * console.log(result) // [1, 2, 3, 4] @@ -407,7 +407,7 @@ export const prepend: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.prependAll([2, 3], [0, 1]) * console.log(result) // [0, 1, 2, 3] @@ -434,7 +434,7 @@ export const prependAll: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.append([1, 2, 3], 4); * console.log(result) // [1, 2, 3, 4] @@ -454,7 +454,7 @@ export const append: { * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.appendAll([1, 2], [3, 4]) * console.log(result) // [1, 2, 3, 4] @@ -483,7 +483,7 @@ export const appendAll: { * @example * * ```ts - * import { Array } from "effect/collections"; + * import { Array } from "effect"; * * const result = Array.scan([1, 2, 3, 4], 0, (acc, value) => acc + value) * console.log(result) // [0, 1, 3, 6, 10] @@ -519,7 +519,7 @@ export const scan: { * @example * * ```ts - * import { Array } from "effect/collections"; + * import { Array } from "effect"; * * const result = Array.scanRight([1, 2, 3, 4], 0, (acc, value) => acc + value) * console.log(result) // [10, 9, 7, 4, 0] @@ -547,7 +547,7 @@ export const scanRight: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * console.log(Array.isArray(null)) // false * console.log(Array.isArray([1, 2, 3])) // true @@ -567,7 +567,7 @@ export const isArray: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * console.log(Array.isArrayEmpty([])) // true * console.log(Array.isArrayEmpty([1, 2, 3])) // false @@ -584,7 +584,7 @@ export const isArrayEmpty = (self: Array): self is [] => self.length === 0 * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * console.log(Array.isReadonlyArrayEmpty([])) // true * console.log(Array.isReadonlyArrayEmpty([1, 2, 3])) // false @@ -603,7 +603,7 @@ export const isReadonlyArrayEmpty: (self: ReadonlyArray) => self is readon * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * console.log(Array.isArrayNonEmpty([])) // false * console.log(Array.isArrayNonEmpty([1, 2, 3])) // true @@ -622,7 +622,7 @@ export const isArrayNonEmpty: (self: Array) => self is NonEmptyArray = * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * console.log(Array.isReadonlyArrayNonEmpty([])) // false * console.log(Array.isReadonlyArrayNonEmpty([1, 2, 3])) // true @@ -639,7 +639,7 @@ export const isReadonlyArrayNonEmpty: (self: ReadonlyArray) => self is Non * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.length([1, 2, 3]) * console.log(result) // 3 @@ -662,7 +662,7 @@ const clamp = (i: number, as: ReadonlyArray): number => Math.floor(Math.mi * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.get([1, 2, 3], 1) * console.log(result) // Some(2) @@ -687,7 +687,7 @@ export const get: { * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.getUnsafe([1, 2, 3], 1) * console.log(result) // 2 @@ -716,7 +716,7 @@ export const getUnsafe: { * @example * * ```ts - * import { Array } from "effect/collections"; + * import { Array } from "effect"; * * const result = Array.unprepend([1, 2, 3, 4]) * console.log(result) // [1, [2, 3, 4]] @@ -735,7 +735,7 @@ export const unprepend = ( * @example * * ```ts - * import { Array } from "effect/collections"; + * import { Array } from "effect"; * * const result = Array.unappend([1, 2, 3, 4]) * console.log(result) // [[1, 2, 3], 4] @@ -753,7 +753,7 @@ export const unappend = ( * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.head([1, 2, 3]) * console.log(result) // Some(1) @@ -773,7 +773,7 @@ export const head: (self: ReadonlyArray) => Option.Option = get(0) * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.headNonEmpty([1, 2, 3, 4]) * console.log(result) // 1 @@ -789,7 +789,7 @@ export const headNonEmpty: (self: NonEmptyReadonlyArray) => A = getUnsafe( * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.last([1, 2, 3]) * console.log(result) // Some(3) @@ -810,7 +810,7 @@ export const last = (self: ReadonlyArray): Option.Option => * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.lastNonEmpty([1, 2, 3, 4]) * console.log(result) // 4 @@ -826,7 +826,7 @@ export const lastNonEmpty = (self: NonEmptyReadonlyArray): A => self[self. * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * Array.tail([1, 2, 3, 4]) // [2, 3, 4] * Array.tail([]) // undefined @@ -846,7 +846,7 @@ export function tail(self: Iterable): Array | undefined { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.tailNonEmpty([1, 2, 3, 4]) * console.log(result) // [2, 3, 4] @@ -862,7 +862,7 @@ export const tailNonEmpty = (self: NonEmptyReadonlyArray): Array => sel * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * Array.init([1, 2, 3, 4]) // [1, 2, 3] * Array.init([]) // undefined @@ -882,7 +882,7 @@ export function init(self: Iterable): Array | undefined { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.initNonEmpty([1, 2, 3, 4]) * console.log(result) // [1, 2, 3] @@ -901,7 +901,7 @@ export const initNonEmpty = (self: NonEmptyReadonlyArray): Array => sel * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.take([1, 2, 3, 4, 5], 3) * console.log(result) // [1, 2, 3] @@ -926,7 +926,7 @@ export const take: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.takeRight([1, 2, 3, 4, 5], 3) * console.log(result) // [3, 4, 5] @@ -950,7 +950,7 @@ export const takeRight: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.takeWhile([1, 3, 2, 4, 1, 2], x => x < 4) * console.log(result) // [1, 3, 2] @@ -1002,7 +1002,7 @@ const spanIndex = (self: Iterable, predicate: (a: A, i: number) => boolean * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.span([1, 3, 2, 4, 5], x => x % 2 === 1) * console.log(result) // [[1, 3], [2, 4, 5]] @@ -1035,7 +1035,7 @@ export const span: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.drop([1, 2, 3, 4, 5], 2) * console.log(result) // [3, 4, 5] @@ -1060,7 +1060,7 @@ export const drop: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.dropRight([1, 2, 3, 4, 5], 2) * console.log(result) // [1, 2, 3] @@ -1083,7 +1083,7 @@ export const dropRight: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.dropWhile([1, 2, 3, 4, 5], x => x < 4) * console.log(result) // [4, 5] @@ -1107,7 +1107,7 @@ export const dropWhile: { * **Example** * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * Array.findFirstIndex( * [5, 3, 8, 9], @@ -1137,7 +1137,7 @@ export const findFirstIndex: { * **Example** * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * Array.findLastIndex( * [1, 3, 8, 9], @@ -1167,7 +1167,7 @@ export const findLastIndex: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.findFirst([1, 2, 3, 4, 5], x => x > 3) * console.log(result) // Option.some(4) @@ -1192,7 +1192,7 @@ export const findFirst: { * **Example** * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * Array.findFirstWithIndex([1, 2, 3, 4, 5], x => x > 3) // [4, 3] * ``` @@ -1237,7 +1237,7 @@ export const findFirstWithIndex: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.findLast([1, 2, 3, 4, 5], n => n % 2 === 0) * console.log(result) // Option.some(4) @@ -1284,7 +1284,7 @@ export const findLast: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * Array.insertAt(['a', 'b', 'c', 'e'], 3, 'd') // ['a', 'b', 'c', 'd', 'e'] * ``` @@ -1310,7 +1310,7 @@ export const insertAt: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.replace([1, 2, 3], 1, 4) * console.log(result) // [1, 4, 3] @@ -1340,7 +1340,7 @@ export const replace: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const input = [1, 2, 3, 4] * const result = Array.modify(input, 2, (n) => n * 2) @@ -1381,7 +1381,7 @@ export const modify: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const input = [1, 2, 3, 4] * const result = Array.remove(input, 2) @@ -1412,7 +1412,7 @@ export const remove: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.reverse([1, 2, 3, 4]) * console.log(result) // [4, 3, 2, 1] @@ -1432,7 +1432,7 @@ export const reverse = >( * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * import { Order } from "effect" * * const result = Array.sort([3, 1, 4, 1, 5], Order.number) @@ -1462,7 +1462,7 @@ export const sort: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * import { Order } from "effect" * * const result = Array.sortWith(["aaa", "b", "cc"], (s) => s.length, Order.number) @@ -1499,7 +1499,7 @@ export const sortWith: { * * ```ts * import { pipe } from "effect" - * import { Array } from "effect/collections" + * import { Array } from "effect" * import { Order } from "effect" * * const users = [ @@ -1554,7 +1554,7 @@ export const sortBy = >( * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.zip([1, 2, 3], ['a', 'b']) * console.log(result) // [[1, 'a'], [2, 'b']] @@ -1580,7 +1580,7 @@ export const zip: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.zipWith([1, 2, 3], [4, 5, 6], (a, b) => a + b) * console.log(result) // [5, 7, 9] @@ -1614,7 +1614,7 @@ export const zipWith: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.unzip([[1, "a"], [2, "b"], [3, "c"]]) * console.log(result) // [[1, 2, 3], ['a', 'b', 'c']] @@ -1648,7 +1648,7 @@ export const unzip: >( * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.intersperse([1, 2, 3], 0) * console.log(result) // [1, 0, 2, 0, 3] @@ -1685,7 +1685,7 @@ export const intersperse: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.modifyHeadNonEmpty([1, 2, 3], n => n * 10) * console.log(result) // [10, 2, 3] @@ -1711,7 +1711,7 @@ export const modifyHeadNonEmpty: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.setHeadNonEmpty([1, 2, 3], 10) * console.log(result) // [10, 2, 3] @@ -1734,7 +1734,7 @@ export const setHeadNonEmpty: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.modifyLastNonEmpty([1, 2, 3], n => n * 2) * console.log(result) // [1, 2, 6] @@ -1758,7 +1758,7 @@ export const modifyLastNonEmpty: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.setLastNonEmpty([1, 2, 3], 4) * console.log(result) // [1, 2, 4] @@ -1782,7 +1782,7 @@ export const setLastNonEmpty: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.rotate(['a', 'b', 'c', 'd'], 2) * console.log(result) // ['c', 'd', 'a', 'b'] @@ -1820,7 +1820,7 @@ export const rotate: { * * ```ts * import { pipe } from "effect" - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const isEquivalent = (a: number, b: number) => a === b * const containsNumber = Array.containsWith(isEquivalent) @@ -1853,7 +1853,7 @@ const _equivalence = Equal.equivalence() * * ```ts * import { pipe } from "effect" - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = pipe(['a', 'b', 'c', 'd'], Array.contains('c')) * console.log(result) // true @@ -1875,7 +1875,7 @@ export const contains: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.chop([1, 2, 3, 4, 5], (as): [number, Array] => [as[0] * 2, as.slice(1)]) * console.log(result) // [2, 4, 6, 8, 10] @@ -1927,7 +1927,7 @@ export const chop: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.splitAt([1, 2, 3, 4, 5], 3) * console.log(result) // [[1, 2, 3], [4, 5]] @@ -1958,7 +1958,7 @@ export const splitAt: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.splitAtNonEmpty(["a", "b", "c", "d", "e"], 3) * console.log(result) // [["a", "b", "c"], ["d", "e"]] @@ -1983,7 +1983,7 @@ export const splitAtNonEmpty: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.split([1, 2, 3, 4, 5, 6, 7, 8], 3) * console.log(result) // [[1, 2, 3], [4, 5, 6], [7, 8]] @@ -2007,7 +2007,7 @@ export const split: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.splitWhere([1, 2, 3, 4, 5], n => n > 3) * console.log(result) // [[1, 2, 3], [4, 5]] @@ -2033,7 +2033,7 @@ export const splitWhere: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.copy([1, 2, 3]) * console.log(result) // [1, 2, 3] @@ -2056,7 +2056,7 @@ export const copy: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.pad([1, 2, 3], 6, 0) * console.log(result) // [1, 2, 3, 0, 0, 0] @@ -2097,7 +2097,7 @@ export const pad: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.chunksOf([1, 2, 3, 4, 5], 2) * console.log(result) // [[1, 2], [3, 4], [5]] @@ -2136,7 +2136,7 @@ export const chunksOf: { * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const numbers = [1, 2, 3, 4, 5] * @@ -2167,7 +2167,7 @@ export const window: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.groupWith(["a", "a", "b", "b", "b", "c", "a"], (x, y) => x === y) * console.log(result) // [["a", "a"], ["b", "b", "b"], ["c"], ["a"]] @@ -2204,7 +2204,7 @@ export const groupWith: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.group([1, 1, 2, 2, 2, 3, 1]) * console.log(result) // [[1, 1], [2, 2, 2], [3], [1]] @@ -2224,7 +2224,7 @@ export const group: (self: NonEmptyReadonlyArray) => NonEmptyArray a === b) * console.log(union) // [1, 2, 3] @@ -2317,7 +2317,7 @@ export const unionWith: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.union([1, 2], [2, 3]) * console.log(result) // [1, 2, 3] @@ -2344,7 +2344,7 @@ export const union: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }] * const array2 = [{ id: 3 }, { id: 4 }, { id: 1 }] @@ -2374,7 +2374,7 @@ export const intersectionWith = (isEquivalent: (self: A, that: A) => boolean) * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.intersection([1, 2, 3], [3, 4, 1]) * console.log(result) // [1, 3] @@ -2395,7 +2395,7 @@ export const intersection: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const array1 = [1, 2, 3] * const array2 = [2, 3, 4] @@ -2424,7 +2424,7 @@ export const differenceWith = (isEquivalent: (self: A, that: A) => boolean): * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const difference = Array.difference([1, 2, 3], [2, 3, 4]) * console.log(difference) // [1] @@ -2443,7 +2443,7 @@ export const difference: { * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.empty() * console.log(result) // [] @@ -2459,7 +2459,7 @@ export const empty: () => Array = () => [] * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.of(1) * console.log(result) // [1] @@ -2475,7 +2475,7 @@ export const of = (a: A): NonEmptyArray => [a] * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * type ElementType = Array.ReadonlyArray.Infer> * // ElementType is string @@ -2488,7 +2488,7 @@ export const of = (a: A): NonEmptyArray => [a] * * @example * ```ts - * import type { Array } from "effect/collections" + * import type { Array } from "effect" * * // Using ReadonlyArray utility types * type ElementType = Array.ReadonlyArray.Infer @@ -2504,7 +2504,7 @@ export declare namespace ReadonlyArray { * * @example * ```ts - * import type { Array } from "effect/collections" + * import type { Array } from "effect" * * type StringArrayType = Array.ReadonlyArray.Infer * // StringArrayType is string @@ -2522,7 +2522,7 @@ export declare namespace ReadonlyArray { * * @example * ```ts - * import type { Array } from "effect/collections" + * import type { Array } from "effect" * * type Result = Array.ReadonlyArray.With * // Result is NonEmptyArray @@ -2539,7 +2539,7 @@ export declare namespace ReadonlyArray { * * @example * ```ts - * import type { Array } from "effect/collections" + * import type { Array } from "effect" * * type Result = Array.ReadonlyArray.OrNonEmpty * // Result is NonEmptyArray @@ -2561,7 +2561,7 @@ export declare namespace ReadonlyArray { * * @example * ```ts - * import type { Array } from "effect/collections" + * import type { Array } from "effect" * * type Result = Array.ReadonlyArray.AndNonEmpty * // Result is NonEmptyArray @@ -2583,7 +2583,7 @@ export declare namespace ReadonlyArray { * * @example * ```ts - * import type { Array } from "effect/collections" + * import type { Array } from "effect" * * type Nested = readonly (readonly number[])[] * type Flattened = Array.ReadonlyArray.Flatten @@ -2604,7 +2604,7 @@ export declare namespace ReadonlyArray { * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.map([1, 2, 3], x => x * 2) * console.log(result) // [2, 4, 6] @@ -2625,7 +2625,7 @@ export const map: { * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.flatMap([1, 2, 3], x => [x, x * 2]) * console.log(result) // [1, 2, 2, 4, 3, 6] @@ -2665,7 +2665,7 @@ export const flatMap: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.flatten([[1, 2], [], [3, 4], [], [5, 6]]) * console.log(result) // [1, 2, 3, 4, 5, 6] @@ -2685,7 +2685,7 @@ export const flatten: >>(self: S) => * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * import * as Option from "effect/Option" * * const evenSquares = (x: number) => x % 2 === 0 ? Option.some(x * x) : Option.none() @@ -2723,7 +2723,7 @@ export const filterMap: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * import * as Option from "effect/Option" * * const toSquareTillOdd = (x: number) => x % 2 === 0 ? Option.some(x * x) : Option.none() @@ -2762,7 +2762,7 @@ export const filterMapWhile: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * import { Result } from "effect"; * * const isEven = (x: number) => x % 2 === 0 @@ -2830,7 +2830,7 @@ export const partitionFilter: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * import * as Option from "effect/Option" * * const result = Array.getSomes([Option.some(1), Option.none(), Option.some(2)]) @@ -2851,7 +2851,7 @@ export const getSomes: >, X = any>( * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * import { Result } from "effect" * * const result = Array.getFailures([Result.succeed(1), Result.fail("err"), Result.succeed(2)]) @@ -2880,7 +2880,7 @@ export const getFailures = >>( * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * import { Result } from "effect" * * const result = Array.getSuccesses([Result.succeed(1), Result.fail("err"), Result.succeed(2)]) @@ -2908,7 +2908,7 @@ export const getSuccesses = >>( * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.filter([1, 2, 3, 4], x => x % 2 === 0) * console.log(result) // [2, 4] @@ -2942,7 +2942,7 @@ export const filter: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.partition([1, 2, 3, 4], n => n % 2 === 0) * console.log(result) // [[1, 3], [2, 4]] @@ -2985,7 +2985,7 @@ export const partition: { * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * import { Result } from "effect" * * const results = [Result.succeed(1), Result.fail("error"), Result.succeed(2)] @@ -3010,7 +3010,7 @@ export const separate: >>( * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.reduce([1, 2, 3], 0, (acc, n) => acc + n) * console.log(result) // 6 @@ -3034,7 +3034,7 @@ export const reduce: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.reduceRight([1, 2, 3], 0, (acc, n) => acc + n) * console.log(result) // 6 @@ -3058,7 +3058,7 @@ export const reduceRight: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const isEven = (n: number) => n % 2 === 0 * const to = Array.liftPredicate(isEven) @@ -3079,7 +3079,7 @@ export const liftPredicate: { // Note: I intentionally avoid using the NoInfer p * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * import * as Option from "effect/Option" * * const parseNumber = Array.liftOption((s: string) => { @@ -3104,7 +3104,7 @@ export const liftOption = , B>( * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * console.log(Array.fromNullishOr(1)) // [1] * console.log(Array.fromNullishOr(null)) // [] @@ -3121,7 +3121,7 @@ export const fromNullishOr = (a: A): Array> => a == null ? emp * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const parseNumber = Array.liftNullishOr((s: string) => { * const n = Number(s) @@ -3146,7 +3146,7 @@ export const liftNullishOr = , B>( * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.flatMapNullishOr([1, 2, 3], n => (n % 2 === 0 ? null : n)) * console.log(result) // [1, 3] @@ -3176,7 +3176,7 @@ export const flatMapNullishOr: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * import { Result } from "effect" * * const parseNumber = (s: string): Result.Result => @@ -3212,7 +3212,7 @@ export const liftResult = , E, B>( * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.every([2, 4, 6], x => x % 2 === 0) * console.log(result) // true @@ -3242,7 +3242,7 @@ export const every: { * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.some([1, 3, 4], x => x % 2 === 0) * console.log(result) // true @@ -3271,7 +3271,7 @@ export const some: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.extend([1, 2, 3], as => as.length) * console.log(result) // [3, 2, 1] @@ -3300,7 +3300,7 @@ export const extend: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * import { Order } from "effect" * * const result = Array.min([3, 1, 2], Order.number) @@ -3321,7 +3321,7 @@ export const min: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * import { Order } from "effect" * * const result = Array.max([3, 1, 2], Order.number) @@ -3341,7 +3341,7 @@ export const max: { * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.unfold(1, n => n <= 5 ? [n, n + 1] : undefined) * console.log(result) // [1, 2, 3, 4, 5] @@ -3370,7 +3370,7 @@ export const unfold = (b: B, f: (b: B) => readonly [A, B] | undefined): Ar * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * import { Order } from "effect" * * const arrayOrder = Array.getOrder(Order.number) @@ -3388,7 +3388,7 @@ export const getOrder: (O: Order.Order) => Order.Order> = * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const eq = Array.getEquivalence((a, b) => a === b) * console.log(eq([1, 2, 3], [1, 2, 3])) // true @@ -3407,7 +3407,7 @@ export const getEquivalence: ( * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * Array.forEach([1, 2, 3], n => console.log(n)) // 1, 2, 3 * ``` @@ -3427,7 +3427,7 @@ export const forEach: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.dedupeWith([1, 2, 2, 3, 3, 3], (a, b) => a === b) * console.log(result) // [1, 2, 3] @@ -3466,7 +3466,7 @@ export const dedupeWith: { * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.dedupe([1, 2, 1, 3, 2, 4]) * console.log(result) // [1, 2, 3, 4] @@ -3486,7 +3486,7 @@ export const dedupe = >( * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.dedupeAdjacentWith([1, 1, 2, 2, 3, 3], (a, b) => a === b) * console.log(result) // [1, 2, 3] @@ -3516,7 +3516,7 @@ export const dedupeAdjacentWith: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.dedupeAdjacent([1, 1, 2, 2, 3, 3]) * console.log(result) // [1, 2, 3] @@ -3533,7 +3533,7 @@ export const dedupeAdjacent: (self: Iterable) => Array = dedupeAdjacent * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const strings = ["a", "b", "c"] * const joined = Array.join(strings, "-") @@ -3554,7 +3554,7 @@ export const join: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.mapAccum([1, 2, 3], 0, (acc, n) => [acc + n, acc + n]) * console.log(result) // [6, [1, 3, 6]] @@ -3595,7 +3595,7 @@ export const mapAccum: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.cartesianWith([1, 2], ["a", "b"], (a, b) => `${a}-${b}`) * console.log(result) // ["1-a", "1-b", "2-a", "2-b"] @@ -3619,7 +3619,7 @@ export const cartesianWith: { * @example * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.cartesian([1, 2], ["a", "b"]) * console.log(result) // [[1, "a"], [1, "b"], [2, "a"], [2, "b"]] @@ -3658,7 +3658,7 @@ export const cartesian: { * * ```ts * import { pipe } from "effect" - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const doResult = pipe( * Array.Do, @@ -3708,7 +3708,7 @@ export const Do: ReadonlyArray<{}> = of({}) * * ```ts * import { pipe } from "effect" - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const doResult = pipe( * Array.Do, @@ -3770,7 +3770,7 @@ export const bind: { * * ```ts * import { pipe } from "effect" - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const doResult = pipe( * Array.Do, @@ -3836,7 +3836,7 @@ export { * * ```ts * import { pipe } from "effect" - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const doResult = pipe( * Array.Do, @@ -3896,7 +3896,7 @@ export function getReducerConcat(): Reducer.Reducer> { * **Example** * * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const result = Array.countBy([1, 2, 3, 4, 5], n => n % 2 === 0) * console.log(result) // 2 diff --git a/packages/effect/src/Brand.ts b/packages/effect/src/Brand.ts index 8ca905c340..ecf3f9652d 100644 --- a/packages/effect/src/Brand.ts +++ b/packages/effect/src/Brand.ts @@ -5,7 +5,7 @@ * * @since 2.0.0 */ -import * as Arr from "./collections/Array.ts" +import * as Arr from "./Array.ts" import * as Option from "./Option.ts" import * as Result from "./Result.ts" import * as AST from "./schema/AST.ts" diff --git a/packages/effect/src/Cache.ts b/packages/effect/src/Cache.ts index bec6a76012..edc3cf7b6d 100644 --- a/packages/effect/src/Cache.ts +++ b/packages/effect/src/Cache.ts @@ -1,8 +1,6 @@ /** * @since 4.0.0 */ -import * as Iterable from "./collections/Iterable.ts" -import * as MutableHashMap from "./collections/MutableHashMap.ts" import * as Deferred from "./Deferred.ts" import * as Duration from "./Duration.ts" import type * as Effect from "./Effect.ts" @@ -13,6 +11,8 @@ import type { Pipeable } from "./interfaces/Pipeable.ts" import * as core from "./internal/core.ts" import { PipeInspectableProto } from "./internal/core.ts" import * as effect from "./internal/effect.ts" +import * as Iterable from "./Iterable.ts" +import * as MutableHashMap from "./MutableHashMap.ts" import * as Option from "./Option.ts" import type { Predicate } from "./Predicate.ts" import * as ServiceMap from "./ServiceMap.ts" diff --git a/packages/effect/src/Channel.ts b/packages/effect/src/Channel.ts index c080e1a021..a038081cde 100644 --- a/packages/effect/src/Channel.ts +++ b/packages/effect/src/Channel.ts @@ -59,10 +59,9 @@ * @since 2.0.0 */ // @effect-diagnostics returnEffectInGen:off +import * as Arr from "./Array.ts" import * as Cause from "./Cause.ts" -import * as Arr from "./collections/Array.ts" -import * as Chunk from "./collections/Chunk.ts" -import * as Iterable from "./collections/Iterable.ts" +import * as Chunk from "./Chunk.ts" import * as Effect from "./Effect.ts" import * as Exit from "./Exit.ts" import * as Fiber from "./Fiber.ts" @@ -73,6 +72,7 @@ import type { Pipeable } from "./interfaces/Pipeable.ts" import { pipeArguments } from "./interfaces/Pipeable.ts" import { endSpan } from "./internal/effect.ts" import { addSpanStackTrace } from "./internal/tracer.ts" +import * as Iterable from "./Iterable.ts" import * as Layer from "./Layer.ts" import * as Option from "./Option.ts" import { hasProperty, isTagged } from "./Predicate.ts" @@ -633,7 +633,7 @@ export const fromArray = (array: ReadonlyArray): Channel => * @example * ```ts * import { Channel } from "effect" - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3) * const channel = Channel.fromChunk(chunk) @@ -3062,7 +3062,7 @@ export const filter: { * * @example * ```ts - * import { Array } from "effect/collections" + * import { Array } from "effect" * import { Filter } from "effect" * import { Channel } from "effect" * diff --git a/packages/effect/src/ChannelSchema.ts b/packages/effect/src/ChannelSchema.ts index a7c86e265f..cc15ba96ae 100644 --- a/packages/effect/src/ChannelSchema.ts +++ b/packages/effect/src/ChannelSchema.ts @@ -1,8 +1,8 @@ /** * @since 4.0.0 */ +import type * as Arr from "./Array.ts" import * as Channel from "./Channel.ts" -import type * as Arr from "./collections/Array.ts" import * as Effect from "./Effect.ts" import { dual } from "./Function.ts" import * as Schema from "./schema/Schema.ts" diff --git a/packages/effect/src/collections/Chunk.ts b/packages/effect/src/Chunk.ts similarity index 93% rename from packages/effect/src/collections/Chunk.ts rename to packages/effect/src/Chunk.ts index 28fbe4746a..76b2c0bebb 100644 --- a/packages/effect/src/collections/Chunk.ts +++ b/packages/effect/src/Chunk.ts @@ -30,7 +30,7 @@ * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * // Creating chunks * const chunk1 = Chunk.fromIterable([1, 2, 3]) @@ -44,7 +44,7 @@ * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * // Functional transformations * const numbers = Chunk.range(1, 5) // [1, 2, 3, 4, 5] @@ -55,7 +55,7 @@ * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" import { Effect } from "effect" * * // Working with Effects @@ -69,25 +69,25 @@ import { Effect } from "effect" * * @since 2.0.0 */ -import * as RA from "../collections/Array.ts" -import type { NonEmptyReadonlyArray } from "../collections/Array.ts" -import type { NonEmptyIterable } from "../collections/NonEmptyIterable.ts" -import * as Equivalence from "../Equivalence.ts" -import { format } from "../Formatter.ts" -import { dual, identity, pipe } from "../Function.ts" -import * as Equal from "../interfaces/Equal.ts" -import * as Hash from "../interfaces/Hash.ts" -import { type Inspectable, NodeInspectSymbol, toJson } from "../interfaces/Inspectable.ts" -import type { Pipeable } from "../interfaces/Pipeable.ts" -import { pipeArguments } from "../interfaces/Pipeable.ts" -import type { Option } from "../Option.ts" -import * as O from "../Option.ts" -import * as Order from "../Order.ts" -import { hasProperty, type Predicate, type Refinement } from "../Predicate.ts" -import type { Result } from "../Result.ts" -import type { TypeLambda } from "../types/HKT.ts" -import type { Covariant, NoInfer } from "../types/Types.ts" -import * as UndefinedOr from "../UndefinedOr.ts" +import * as RA from "./Array.ts" +import type { NonEmptyReadonlyArray } from "./Array.ts" +import * as Equivalence from "./Equivalence.ts" +import { format } from "./Formatter.ts" +import { dual, identity, pipe } from "./Function.ts" +import * as Equal from "./interfaces/Equal.ts" +import * as Hash from "./interfaces/Hash.ts" +import { type Inspectable, NodeInspectSymbol, toJson } from "./interfaces/Inspectable.ts" +import type { Pipeable } from "./interfaces/Pipeable.ts" +import { pipeArguments } from "./interfaces/Pipeable.ts" +import type { NonEmptyIterable } from "./NonEmptyIterable.ts" +import type { Option } from "./Option.ts" +import * as O from "./Option.ts" +import * as Order from "./Order.ts" +import { hasProperty, type Predicate, type Refinement } from "./Predicate.ts" +import type { Result } from "./Result.ts" +import type { TypeLambda } from "./types/HKT.ts" +import type { Covariant, NoInfer } from "./types/Types.ts" +import * as UndefinedOr from "./UndefinedOr.ts" const TypeId = "~effect/collections/Chunk" @@ -96,7 +96,7 @@ const TypeId = "~effect/collections/Chunk" * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk: Chunk.Chunk = Chunk.make(1, 2, 3) * console.log(chunk.length) // 3 @@ -122,7 +122,7 @@ export interface Chunk extends Iterable, Equal.Equal, Pipeable, Inspec * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const nonEmptyChunk: Chunk.NonEmptyChunk = Chunk.make(1, 2, 3) * console.log(Chunk.headNonEmpty(nonEmptyChunk)) // 1 @@ -140,7 +140,7 @@ export interface NonEmptyChunk extends Chunk, NonEmptyIterable {} * @example * ```ts * import type { Kind } from "effect/types/HKT" - * import type { ChunkTypeLambda } from "effect/collections/Chunk" + * import type { ChunkTypeLambda } from "effect/Chunk" * * // Create a Chunk type using the type lambda * type NumberChunk = Kind @@ -208,7 +208,7 @@ const emptyArray: ReadonlyArray = [] * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" import * as Equivalence from "effect/Equivalence" * * const chunk1 = Chunk.make(1, 2, 3) @@ -318,7 +318,7 @@ const makeChunk = (backing: Backing): Chunk => { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3) * const array = [1, 2, 3] @@ -343,7 +343,7 @@ const _empty = makeChunk({ _tag: "IEmpty" }) * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const emptyChunk = Chunk.empty() * console.log(Chunk.size(emptyChunk)) // 0 @@ -359,7 +359,7 @@ export const empty: () => Chunk = () => _empty * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4) * console.log(chunk) @@ -377,7 +377,7 @@ export const make = ]>(...as: As): NonEm * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.of("hello") * console.log(chunk) @@ -394,7 +394,7 @@ export const of = (a: A): NonEmptyChunk => makeChunk({ _tag: "ISingleton", * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.fromIterable([1, 2, 3]) * console.log(chunk) @@ -444,7 +444,7 @@ const toArray_ = (self: Chunk): Array => toReadonlyArray(self).slice() * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3) * const array = Chunk.toArray(chunk) @@ -493,7 +493,7 @@ const toReadonlyArray_ = (self: Chunk): ReadonlyArray => { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3) * const readonlyArray = Chunk.toReadonlyArray(chunk) @@ -538,7 +538,7 @@ const reverseChunk = (self: Chunk): Chunk => { * @example * * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3) * const result = Chunk.reverse(chunk) @@ -557,7 +557,7 @@ export const reverse: >(self: S) => Chunk.With(self: ReadonlyArray): Chunk => * * @example * ```ts - * import { Chunk } from "effect/collections" -import * as Array from "effect/collections/Array" + * import { Chunk } from "effect" +import * as Array from "effect/Array" * * const nonEmptyArray = Array.make(1, 2, 3, 4, 5) * const chunk = Chunk.fromNonEmptyArrayUnsafe(nonEmptyArray) @@ -632,7 +632,7 @@ export const fromNonEmptyArrayUnsafe = (self: NonEmptyReadonlyArray): NonE * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make("a", "b", "c", "d") * @@ -687,7 +687,7 @@ export const getUnsafe: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3) * const newChunk = Chunk.append(chunk, 4) @@ -712,7 +712,7 @@ export const append: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(2, 3, 4) * const newChunk = Chunk.prepend(chunk, 1) @@ -737,7 +737,7 @@ export const prepend: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.take(chunk, 3) @@ -794,7 +794,7 @@ export const take: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.drop(chunk, 2) @@ -850,7 +850,7 @@ export const drop: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.dropRight(chunk, 2) @@ -871,7 +871,7 @@ export const dropRight: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.dropWhile(chunk, (n) => n < 3) @@ -902,7 +902,7 @@ export const dropWhile: { * @example * * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const result = Chunk.make(1, 2).pipe(Chunk.prependAll(Chunk.make("a", "b")), Chunk.toArray) * @@ -929,7 +929,7 @@ export const prependAll: { * @example * * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const result = Chunk.make(1, 2).pipe(Chunk.appendAll(Chunk.make("a", "b")), Chunk.toArray) * @@ -993,7 +993,7 @@ export const appendAll: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import * as Option from "effect/Option" * * const chunk = Chunk.make("1", "2", "hello", "3", "world") @@ -1027,7 +1027,7 @@ export const filterMap: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5, 6) * const evenNumbers = Chunk.filter(chunk, (n) => n % 2 === 0) @@ -1057,7 +1057,7 @@ export const filter: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import * as Option from "effect/Option" * * const chunk = Chunk.make("1", "2", "hello", "3", "4") @@ -1089,7 +1089,7 @@ export const filterMapWhile: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import * as Option from "effect/Option" * * const chunk = Chunk.make(Option.some(1), Option.none(), Option.some(3)) @@ -1108,7 +1108,7 @@ export const compact = (self: Chunk>): Chunk => filterMap(self, * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3) * const duplicated = Chunk.flatMap(chunk, (n) => Chunk.make(n, n)) @@ -1157,7 +1157,7 @@ export const flatMap: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4) * @@ -1191,7 +1191,7 @@ export const forEach: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const nested = Chunk.make( * Chunk.make(1, 2), @@ -1220,7 +1220,7 @@ export const flatten: >>(self: S) => Chunk.Flatten * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5, 6, 7, 8, 9) * const chunked = Chunk.chunksOf(chunk, 3) @@ -1264,7 +1264,7 @@ export const chunksOf: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk1 = Chunk.make(1, 2, 3, 4) * const chunk2 = Chunk.make(3, 4, 5, 6) @@ -1299,7 +1299,7 @@ export const intersection: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * console.log(Chunk.isEmpty(Chunk.empty())) // true * console.log(Chunk.isEmpty(Chunk.make(1, 2, 3))) // false @@ -1315,7 +1315,7 @@ export const isEmpty = (self: Chunk): boolean => self.length === 0 * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * console.log(Chunk.isNonEmpty(Chunk.empty())) // false * console.log(Chunk.isNonEmpty(Chunk.make(1, 2, 3))) // true @@ -1331,7 +1331,7 @@ export const isNonEmpty = (self: Chunk): self is NonEmptyChunk => self. * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import * as Option from "effect/Option" * * console.log(Chunk.head(Chunk.empty())) // { _tag: "None" } @@ -1350,7 +1350,7 @@ export const head: (self: Chunk) => Option = get(0) * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4) * console.log(Chunk.headUnsafe(chunk)) // 1 @@ -1376,7 +1376,7 @@ export const headUnsafe = (self: Chunk): A => getUnsafe(self, 0) * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const nonEmptyChunk = Chunk.make(1, 2, 3, 4) * console.log(Chunk.headNonEmpty(nonEmptyChunk)) // 1 @@ -1398,7 +1398,7 @@ export const headNonEmpty: (self: NonEmptyChunk) => A = headUnsafe * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import * as Option from "effect/Option" * * console.log(Chunk.last(Chunk.empty())) // { _tag: "None" } @@ -1417,7 +1417,7 @@ export const last = (self: Chunk): Option => get(self, self.length - 1) * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4) * console.log(Chunk.lastUnsafe(chunk)) // 4 @@ -1443,7 +1443,7 @@ export const lastUnsafe = (self: Chunk): A => getUnsafe(self, self.length * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const nonEmptyChunk = Chunk.make(1, 2, 3, 4) * console.log(Chunk.lastNonEmpty(nonEmptyChunk)) // 4 @@ -1465,7 +1465,7 @@ export const lastNonEmpty: (self: NonEmptyChunk) => A = lastUnsafe * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * // Extract the element type from a Chunk * declare const chunk: Chunk.Chunk @@ -1485,7 +1485,7 @@ export declare namespace Chunk { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * declare const numberChunk: Chunk.Chunk * declare const stringChunk: Chunk.Chunk @@ -1504,7 +1504,7 @@ export declare namespace Chunk { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * declare const regularChunk: Chunk.Chunk * declare const nonEmptyChunk: Chunk.NonEmptyChunk @@ -1523,7 +1523,7 @@ export declare namespace Chunk { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * declare const emptyChunk: Chunk.Chunk * declare const nonEmptyChunk: Chunk.NonEmptyChunk @@ -1546,7 +1546,7 @@ export declare namespace Chunk { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * declare const emptyChunk: Chunk.Chunk * declare const nonEmptyChunk: Chunk.NonEmptyChunk @@ -1569,7 +1569,7 @@ export declare namespace Chunk { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * declare const nestedChunk: Chunk.Chunk> * declare const nestedNonEmpty: Chunk.NonEmptyChunk> @@ -1593,7 +1593,7 @@ export declare namespace Chunk { * @example * * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const result = Chunk.map(Chunk.make(1, 2), (n) => n + 1) * @@ -1618,7 +1618,7 @@ export const map: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const [finalState, mapped] = Chunk.mapAccum(chunk, 0, (state, current) => [ @@ -1655,7 +1655,7 @@ export const mapAccum: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5, 6) * const [odds, evens] = Chunk.partition(chunk, (n) => n % 2 === 0) @@ -1704,7 +1704,7 @@ export const partition: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import * as Result from "effect/Result" * * const chunk = Chunk.make("1", "hello", "2", "world", "3") @@ -1744,7 +1744,7 @@ export const partitionMap: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import * as Result from "effect/Result" * * const chunk = Chunk.make( @@ -1780,7 +1780,7 @@ export const separate = (self: Chunk>): [Chunk, Chunk] * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3) * console.log(Chunk.size(chunk)) // 3 @@ -1796,7 +1796,7 @@ export const size = (self: Chunk): number => self.length * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" import * as Order from "effect/Order" * * const numbers = Chunk.make(3, 1, 4, 1, 5, 9, 2, 6) @@ -1829,7 +1829,7 @@ export const sort: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" import * as Order from "effect/Order" * * const people = Chunk.make( @@ -1870,7 +1870,7 @@ export const sortWith: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5, 6) * const [before, after] = Chunk.splitAt(chunk, 3) @@ -1902,7 +1902,7 @@ export const splitAt: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const nonEmptyChunk = Chunk.make(1, 2, 3, 4, 5, 6) * const [before, after] = Chunk.splitNonEmptyAt(nonEmptyChunk, 3) @@ -1936,7 +1936,7 @@ export const splitNonEmptyAt: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5, 6, 7, 8, 9) * const chunks = Chunk.split(chunk, 3) @@ -1969,7 +1969,7 @@ export const split: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5, 6) * const [before, fromMatch] = Chunk.splitWhere(chunk, (n) => n > 3) @@ -2010,7 +2010,7 @@ export const splitWhere: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import * as Option from "effect/Option" * * const chunk = Chunk.make(1, 2, 3, 4) @@ -2033,7 +2033,7 @@ export const tail = (self: Chunk): Chunk | undefined => self.length > 0 * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const nonEmptyChunk = Chunk.make(1, 2, 3, 4) * const result = Chunk.tailNonEmpty(nonEmptyChunk) @@ -2057,7 +2057,7 @@ export const tailNonEmpty = (self: NonEmptyChunk): Chunk => drop(self, * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5, 6) * const lastThree = Chunk.takeRight(chunk, 3) @@ -2085,7 +2085,7 @@ export const takeRight: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 3, 2, 1) * const result = Chunk.takeWhile(chunk, (n) => n < 4) @@ -2126,7 +2126,7 @@ export const takeWhile: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk1 = Chunk.make(1, 2, 3) * const chunk2 = Chunk.make(3, 4, 5) @@ -2156,7 +2156,7 @@ export const union: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 2, 3, 1, 4, 3) * const result = Chunk.dedupe(chunk) @@ -2183,7 +2183,7 @@ export const dedupe = (self: Chunk): Chunk => fromArrayUnsafe(RA.dedupe * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 1, 2, 2, 2, 3, 1, 1) * const result = Chunk.dedupeAdjacent(chunk) @@ -2207,7 +2207,7 @@ export const dedupeAdjacent = (self: Chunk): Chunk => fromArrayUnsafe(R * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const pairs = Chunk.make([1, "a"] as const, [2, "b"] as const, [3, "c"] as const) * const [numbers, letters] = Chunk.unzip(pairs) @@ -2234,7 +2234,7 @@ export const unzip = (self: Chunk): [Chunk, Chunk] * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const numbers = Chunk.make(1, 2, 3) * const letters = Chunk.make("a", "b", "c") @@ -2265,7 +2265,7 @@ export const zipWith: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const numbers = Chunk.make(1, 2, 3) * const letters = Chunk.make("a", "b", "c") @@ -2295,7 +2295,7 @@ export const zip: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make("a", "b", "c", "d") * const result = Chunk.remove(chunk, 1) @@ -2327,7 +2327,7 @@ export const remove: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4) * const result = Chunk.modify(chunk, 1, (n) => n * 10) @@ -2360,7 +2360,7 @@ export const modify: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make("a", "b", "c", "d") * const result = Chunk.replace(chunk, 1, "X") @@ -2390,7 +2390,7 @@ export const replace: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.makeBy(5, (i) => i * 2) * console.log(chunk) @@ -2410,7 +2410,7 @@ export const makeBy: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.range(1, 5) * console.log(chunk) @@ -2432,7 +2432,7 @@ export const range = (start: number, end: number): NonEmptyChunk => * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * console.log(Chunk.contains(chunk, 3)) // true @@ -2461,7 +2461,7 @@ export const contains: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make({ id: 1, name: "Alice" }, { id: 2, name: "Bob" }) * @@ -2493,7 +2493,7 @@ export const containsWith: ( * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import { Option } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) @@ -2526,7 +2526,7 @@ export const findFirst: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.findFirstIndex(chunk, (n) => n > 3) @@ -2554,7 +2554,7 @@ export const findFirstIndex: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import * as Option from "effect/Option" * * const chunk = Chunk.make(1, 2, 3, 4, 5) @@ -2586,7 +2586,7 @@ export const findLast: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const result = Chunk.findLastIndex(chunk, (n) => n < 4) @@ -2614,7 +2614,7 @@ export const findLastIndex: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const allPositive = Chunk.make(1, 2, 3, 4, 5) * console.log(Chunk.every(allPositive, (n) => n > 0)) // true @@ -2651,7 +2651,7 @@ export const every: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * console.log(Chunk.some(chunk, (n) => n > 4)) // true @@ -2682,7 +2682,7 @@ export const some: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make("apple", "banana", "cherry") * const result = Chunk.join(chunk, ", ") @@ -2714,7 +2714,7 @@ export const join: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4, 5) * const sum = Chunk.reduce(chunk, 0, (acc, n) => acc + n) @@ -2743,7 +2743,7 @@ export const reduce: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3, 4) * const result = Chunk.reduceRight(chunk, 0, (acc, n) => acc + n) @@ -2773,7 +2773,7 @@ export const reduceRight: { * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk1 = Chunk.make({ id: 1, name: "Alice" }, { id: 2, name: "Bob" }) * const chunk2 = Chunk.make({ id: 1, name: "Alice" }, { id: 3, name: "Charlie" }) @@ -2810,7 +2810,7 @@ export const differenceWith = (isEquivalent: (self: A, that: A) => boolean): * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * * const chunk1 = Chunk.make(1, 2, 3, 4, 5) * const chunk2 = Chunk.make(3, 4, 6, 7) diff --git a/packages/effect/src/Cron.ts b/packages/effect/src/Cron.ts index d9630e52aa..9ca2ff0826 100644 --- a/packages/effect/src/Cron.ts +++ b/packages/effect/src/Cron.ts @@ -1,7 +1,7 @@ /** * @since 2.0.0 */ -import * as Arr from "./collections/Array.ts" +import * as Arr from "./Array.ts" import * as Data from "./Data.ts" import type * as DateTime from "./DateTime.ts" import * as equivalence from "./Equivalence.ts" diff --git a/packages/effect/src/DateTime.ts b/packages/effect/src/DateTime.ts index aed57fb5fd..8159eec405 100644 --- a/packages/effect/src/DateTime.ts +++ b/packages/effect/src/DateTime.ts @@ -401,7 +401,7 @@ export const Equivalence: equivalence.Equivalence = Internal.Equivalen * @example * ```ts * import { DateTime } from "effect" - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const dates = [ * DateTime.makeUnsafe("2024-03-01"), diff --git a/packages/effect/src/Effect.ts b/packages/effect/src/Effect.ts index b540ae5b78..e1c883fe25 100644 --- a/packages/effect/src/Effect.ts +++ b/packages/effect/src/Effect.ts @@ -67,9 +67,9 @@ * * @since 2.0.0 */ +import type * as Arr from "./Array.ts" import type * as Cause from "./Cause.ts" import type { Clock } from "./Clock.ts" -import type * as Arr from "./collections/Array.ts" import * as Duration from "./Duration.ts" import type { ExecutionPlan } from "./ExecutionPlan.ts" import * as Exit from "./Exit.ts" diff --git a/packages/effect/src/Equivalence.ts b/packages/effect/src/Equivalence.ts index e65023ae3a..118202f525 100644 --- a/packages/effect/src/Equivalence.ts +++ b/packages/effect/src/Equivalence.ts @@ -11,7 +11,7 @@ * @example * ```ts * import { Equivalence } from "effect" - * import { Array } from "effect/collections" + * import { Array } from "effect" * * // Case-insensitive string equivalence * const caseInsensitive = Equivalence.make((a, b) => diff --git a/packages/effect/src/ExecutionPlan.ts b/packages/effect/src/ExecutionPlan.ts index 58d0d889f0..dce3fa2a56 100644 --- a/packages/effect/src/ExecutionPlan.ts +++ b/packages/effect/src/ExecutionPlan.ts @@ -1,7 +1,7 @@ /** * @since 3.16.0 */ -import type { NonEmptyReadonlyArray } from "./collections/Array.ts" +import type { NonEmptyReadonlyArray } from "./Array.ts" import type * as Effect from "./Effect.ts" import { constant } from "./Function.ts" import type { Pipeable } from "./interfaces/Pipeable.ts" diff --git a/packages/effect/src/FiberMap.ts b/packages/effect/src/FiberMap.ts index 0f2ad3ba1e..8baeb73d49 100644 --- a/packages/effect/src/FiberMap.ts +++ b/packages/effect/src/FiberMap.ts @@ -2,8 +2,6 @@ * @since 2.0.0 */ import * as Cause from "./Cause.ts" -import * as Iterable from "./collections/Iterable.ts" -import * as MutableHashMap from "./collections/MutableHashMap.ts" import * as Deferred from "./Deferred.ts" import * as Effect from "./Effect.ts" import * as Exit from "./Exit.ts" @@ -13,6 +11,8 @@ import { constVoid, dual } from "./Function.ts" import type * as Inspectable from "./interfaces/Inspectable.ts" import { type Pipeable } from "./interfaces/Pipeable.ts" import { PipeInspectableProto } from "./internal/core.ts" +import * as Iterable from "./Iterable.ts" +import * as MutableHashMap from "./MutableHashMap.ts" import * as Option from "./Option.ts" import * as Predicate from "./Predicate.ts" import type * as Scope from "./Scope.ts" diff --git a/packages/effect/src/FiberSet.ts b/packages/effect/src/FiberSet.ts index 91fe903e1f..1e918b61ff 100644 --- a/packages/effect/src/FiberSet.ts +++ b/packages/effect/src/FiberSet.ts @@ -2,7 +2,6 @@ * @since 2.0.0 */ import * as Cause from "./Cause.ts" -import * as Iterable from "./collections/Iterable.ts" import * as Deferred from "./Deferred.ts" import * as Effect from "./Effect.ts" import * as Exit from "./Exit.ts" @@ -12,6 +11,7 @@ import { constVoid, dual } from "./Function.ts" import type * as Inspectable from "./interfaces/Inspectable.ts" import { type Pipeable } from "./interfaces/Pipeable.ts" import { PipeInspectableProto } from "./internal/core.ts" +import * as Iterable from "./Iterable.ts" import * as Predicate from "./Predicate.ts" import type * as Scope from "./Scope.ts" import type { ServiceMap } from "./ServiceMap.ts" diff --git a/packages/effect/src/Function.ts b/packages/effect/src/Function.ts index 0488370b05..cbb5bc5a65 100644 --- a/packages/effect/src/Function.ts +++ b/packages/effect/src/Function.ts @@ -531,7 +531,7 @@ export const untupled = , B>(f: (a: A) => B): ( * * ```ts skip-type-checking * import { pipe } from "effect" - * import { Array } from "effect/collections" + * import { Array } from "effect" * * pipe(as, Array.map(f), Array.filter(g)) * ``` diff --git a/packages/effect/src/collections/Graph.ts b/packages/effect/src/Graph.ts similarity index 97% rename from packages/effect/src/collections/Graph.ts rename to packages/effect/src/Graph.ts index f6cb44f838..8ba43165a0 100644 --- a/packages/effect/src/collections/Graph.ts +++ b/packages/effect/src/Graph.ts @@ -2,16 +2,16 @@ * @since 4.0.0 */ -import * as Data from "../Data.ts" -import { dual } from "../Function.ts" -import * as Equal from "../interfaces/Equal.ts" -import * as Hash from "../interfaces/Hash.ts" -import type { Inspectable } from "../interfaces/Inspectable.ts" -import { NodeInspectSymbol } from "../interfaces/Inspectable.ts" -import type { Pipeable } from "../interfaces/Pipeable.ts" -import { pipeArguments } from "../interfaces/Pipeable.ts" -import * as Option from "../Option.ts" -import type { Mutable } from "../types/Types.ts" +import * as Data from "./Data.ts" +import { dual } from "./Function.ts" +import * as Equal from "./interfaces/Equal.ts" +import * as Hash from "./interfaces/Hash.ts" +import type { Inspectable } from "./interfaces/Inspectable.ts" +import { NodeInspectSymbol } from "./interfaces/Inspectable.ts" +import type { Pipeable } from "./interfaces/Pipeable.ts" +import { pipeArguments } from "./interfaces/Pipeable.ts" +import * as Option from "./Option.ts" +import type { Mutable } from "./types/Types.ts" const TypeId = "~effect/collections/Graph" @@ -229,7 +229,7 @@ export const isGraph = (u: unknown): u is Graph => typeof u == * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * // Directed graph with initial nodes and edges * const graph = Graph.directed((mutable) => { @@ -270,7 +270,7 @@ export const directed = (mutate?: (mutable: MutableDirectedGraph) => * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * // Undirected graph with initial nodes and edges * const graph = Graph.undirected((mutable) => { @@ -315,7 +315,7 @@ export const undirected = (mutate?: (mutable: MutableUndirectedGraph * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed() * const mutable = Graph.beginMutation(graph) @@ -359,7 +359,7 @@ export const beginMutation = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed() * const mutable = Graph.beginMutation(graph) @@ -392,7 +392,7 @@ export const endMutation = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed() * const newGraph = Graph.mutate(graph, (mutable) => { @@ -430,7 +430,7 @@ export const mutate: { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const result = Graph.mutate(Graph.directed(), (mutable) => { * const nodeA = Graph.addNode(mutable, "Node A") @@ -467,7 +467,7 @@ export const addNode = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * import * as Option from "effect/Option" * * const graph = Graph.mutate(Graph.directed(), (mutable) => { @@ -503,7 +503,7 @@ export const getNode: { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.mutate(Graph.directed(), (mutable) => { * Graph.addNode(mutable, "Node A") @@ -534,7 +534,7 @@ export const hasNode: { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const emptyGraph = Graph.directed() * console.log(Graph.nodeCount(emptyGraph)) // 0 @@ -560,7 +560,7 @@ export const nodeCount = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.mutate(Graph.directed(), (mutable) => { * Graph.addNode(mutable, "Node A") @@ -602,7 +602,7 @@ export const findNode: { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.mutate(Graph.directed(), (mutable) => { * Graph.addNode(mutable, "Start A") @@ -646,7 +646,7 @@ export const findNodes: { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.mutate(Graph.directed(), (mutable) => { * const nodeA = Graph.addNode(mutable, "Node A") @@ -690,7 +690,7 @@ export const findEdge: { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.mutate(Graph.directed(), (mutable) => { * const nodeA = Graph.addNode(mutable, "Node A") @@ -737,7 +737,7 @@ export const findEdges: { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * Graph.addNode(mutable, "Node A") @@ -771,7 +771,7 @@ export const updateNode = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const result = Graph.mutate(Graph.directed(), (mutable) => { * const nodeA = Graph.addNode(mutable, "Node A") @@ -806,7 +806,7 @@ export const updateEdge = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * Graph.addNode(mutable, "node a") @@ -838,7 +838,7 @@ export const mapNodes = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const a = Graph.addNode(mutable, "A") @@ -875,7 +875,7 @@ export const mapEdges = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const a = Graph.addNode(mutable, "A") @@ -932,7 +932,7 @@ export const reverse = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * import * as Option from "effect/Option" * * const graph = Graph.directed((mutable) => { @@ -984,7 +984,7 @@ export const filterMapNodes = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * import * as Option from "effect/Option" * * const graph = Graph.directed((mutable) => { @@ -1040,7 +1040,7 @@ export const filterMapEdges = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * Graph.addNode(mutable, "active") @@ -1083,7 +1083,7 @@ export const filterNodes = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const a = Graph.addNode(mutable, "A") @@ -1158,7 +1158,7 @@ const invalidateCycleFlagOnAddition = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const result = Graph.mutate(Graph.directed(), (mutable) => { * const nodeA = Graph.addNode(mutable, "Node A") @@ -1230,7 +1230,7 @@ export const addEdge = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const result = Graph.mutate(Graph.directed(), (mutable) => { * const nodeA = Graph.addNode(mutable, "Node A") @@ -1293,7 +1293,7 @@ export const removeNode = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const result = Graph.mutate(Graph.directed(), (mutable) => { * const nodeA = Graph.addNode(mutable, "Node A") @@ -1385,7 +1385,7 @@ const removeEdgeInternal = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.mutate(Graph.directed(), (mutable) => { * const nodeA = Graph.addNode(mutable, "Node A") @@ -1424,7 +1424,7 @@ export const getEdge: { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.mutate(Graph.directed(), (mutable) => { * const nodeA = Graph.addNode(mutable, "Node A") @@ -1483,7 +1483,7 @@ export const hasEdge: { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const emptyGraph = Graph.directed() * console.log(Graph.edgeCount(emptyGraph)) // 0 @@ -1512,7 +1512,7 @@ export const edgeCount = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.mutate(Graph.directed(), (mutable) => { * const nodeA = Graph.addNode(mutable, "Node A") @@ -1574,7 +1574,7 @@ export const neighbors: { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const a = Graph.addNode(mutable, "A") @@ -1646,7 +1646,7 @@ export const neighborsDirected: { * * @example * ```ts - * import * as Graph from "effect/collections/Graph" + * import * as Graph from "effect/Graph" * * // Basic options with custom labels * const basicOptions: Graph.GraphVizOptions = { @@ -1690,7 +1690,7 @@ export interface GraphVizOptions { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.mutate(Graph.directed(), (mutable) => { * const nodeA = Graph.addNode(mutable, "Node A") @@ -1776,7 +1776,7 @@ export const toGraphViz: { * * @example * ```ts - * import * as Graph from "effect/collections/Graph" + * import * as Graph from "effect/Graph" * * // Shape selector function for different node types * const shapeSelector = (nodeData: string): Graph.MermaidNodeShape => { @@ -1816,7 +1816,7 @@ export type MermaidNodeShape = * * @example * ```ts - * import * as Graph from "effect/collections/Graph" + * import * as Graph from "effect/Graph" * * // Horizontal workflow diagram * const horizontalOptions: Graph.MermaidOptions = { @@ -1856,7 +1856,7 @@ export type MermaidDirection = * * @example * ```ts - * import * as Graph from "effect/collections/Graph" + * import * as Graph from "effect/Graph" * * // Force flowchart format (even for undirected graphs) * const flowchartOptions: Graph.MermaidOptions = { @@ -1893,7 +1893,7 @@ export type MermaidDiagramType = * * @example * ```ts - * import * as Graph from "effect/collections/Graph" + * import * as Graph from "effect/Graph" * * // Basic options with custom labels * const basicOptions: Graph.MermaidOptions = { @@ -2000,7 +2000,7 @@ const formatMermaidNode = ( * * @example * ```ts - * import * as Graph from "effect/collections/Graph" + * import * as Graph from "effect/Graph" * * // Basic directed graph export * const graph = Graph.directed((mutable) => { @@ -2023,7 +2023,7 @@ const formatMermaidNode = ( * * @example * ```ts - * import * as Graph from "effect/collections/Graph" + * import * as Graph from "effect/Graph" * * // Undirected graph with custom labels and direction * const socialGraph = Graph.undirected<{name: string}, string>((mutable) => { @@ -2050,7 +2050,7 @@ const formatMermaidNode = ( * * @example * ```ts - * import * as Graph from "effect/collections/Graph" + * import * as Graph from "effect/Graph" * * // Advanced styling with node shapes for flowchart * const workflow = Graph.directed<{type: string, name: string}, string>((mutable) => { @@ -2088,7 +2088,7 @@ const formatMermaidNode = ( * * @example * ```ts - * import * as Graph from "effect/collections/Graph" + * import * as Graph from "effect/Graph" * * // Real-world example: Software dependency graph * interface Dependency { @@ -2198,7 +2198,7 @@ export const toMermaid: { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const a = Graph.addNode(mutable, "A") @@ -2231,7 +2231,7 @@ export type Direction = "outgoing" | "incoming" * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * // Acyclic directed graph (DAG) * const dag = Graph.directed((mutable) => { @@ -2341,7 +2341,7 @@ export const isAcyclic = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * // Bipartite graph (alternating coloring possible) * const bipartite = Graph.undirected((mutable) => { @@ -2450,7 +2450,7 @@ const getUndirectedNeighbors = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.undirected((mutable) => { * const a = Graph.addNode(mutable, "A") @@ -2508,7 +2508,7 @@ export const connectedComponents = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const a = Graph.addNode(mutable, "A") @@ -2655,7 +2655,7 @@ export interface DijkstraConfig { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * import * as Option from "effect/Option" * * const graph = Graph.directed((mutable) => { @@ -2838,7 +2838,7 @@ export interface AllPairsResult { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const a = Graph.addNode(mutable, "A") @@ -2998,7 +2998,7 @@ export interface AstarConfig { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed<{x: number, y: number}, number>((mutable) => { * const a = Graph.addNode(mutable, {x: 0, y: 0}) @@ -3207,7 +3207,7 @@ export interface BellmanFordConfig { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const a = Graph.addNode(mutable, "A") @@ -3379,7 +3379,7 @@ export const bellmanFord: { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const a = Graph.addNode(mutable, "A") @@ -3451,7 +3451,7 @@ export class Walker implements Iterable<[T, N]> { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const a = Graph.addNode(mutable, "A") @@ -3503,7 +3503,7 @@ export type EdgeWalker = Walker> * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const a = Graph.addNode(mutable, "A") @@ -3526,7 +3526,7 @@ export const indices = (walker: Walker): Iterable => walker.visit * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const a = Graph.addNode(mutable, "A") @@ -3549,7 +3549,7 @@ export const values = (walker: Walker): Iterable => walker.visit( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const a = Graph.addNode(mutable, "A") @@ -3587,7 +3587,7 @@ export interface SearchConfig { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const a = Graph.addNode(mutable, "A") @@ -3680,7 +3680,7 @@ export const dfs: { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const a = Graph.addNode(mutable, "A") @@ -3779,7 +3779,7 @@ export interface TopoConfig { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const a = Graph.addNode(mutable, "A") @@ -3913,7 +3913,7 @@ export const topo: { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const root = Graph.addNode(mutable, "root") @@ -4016,7 +4016,7 @@ export const dfsPostOrder: { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const a = Graph.addNode(mutable, "A") @@ -4061,7 +4061,7 @@ export const nodes = ( * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const a = Graph.addNode(mutable, "A") @@ -4118,7 +4118,7 @@ export interface ExternalsConfig { * * @example * ```ts - * import { Graph } from "effect/collections" + * import { Graph } from "effect" * * const graph = Graph.directed((mutable) => { * const source = Graph.addNode(mutable, "source") // 0 - no incoming diff --git a/packages/effect/src/collections/HashMap.ts b/packages/effect/src/HashMap.ts similarity index 91% rename from packages/effect/src/collections/HashMap.ts rename to packages/effect/src/HashMap.ts index ec5ce92c1b..40d3dcf2a1 100644 --- a/packages/effect/src/collections/HashMap.ts +++ b/packages/effect/src/HashMap.ts @@ -2,12 +2,12 @@ * @since 2.0.0 */ -import type { Equal } from "../interfaces/Equal.ts" -import type { Inspectable } from "../interfaces/Inspectable.ts" -import type { Pipeable } from "../interfaces/Pipeable.ts" -import * as internal from "../internal/hashMap.ts" -import type { Option } from "../Option.ts" -import type { NoInfer } from "../types/Types.ts" +import type { Equal } from "./interfaces/Equal.ts" +import type { Inspectable } from "./interfaces/Inspectable.ts" +import type { Pipeable } from "./interfaces/Pipeable.ts" +import * as internal from "./internal/hashMap.ts" +import type { Option } from "./Option.ts" +import type { NoInfer } from "./types/Types.ts" const TypeId = internal.HashMapTypeId @@ -18,7 +18,7 @@ const TypeId = internal.HashMapTypeId * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * import * as Option from "effect/Option" * * // Create a HashMap @@ -49,7 +49,7 @@ export interface HashMap extends Iterable<[Key, Value]>, Equ * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * import * as Option from "effect/Option" * * // Create a concrete HashMap for type extraction @@ -86,7 +86,7 @@ export declare namespace HashMap { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * import * as Option from "effect/Option" * * const map = HashMap.make(["a", 1], ["b", 2]) @@ -109,7 +109,7 @@ export declare namespace HashMap { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * // Create a HashMap to extract key type from * const userMap = HashMap.make( @@ -134,7 +134,7 @@ export declare namespace HashMap { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * // Create a HashMap with user data * const userMap = HashMap.make( @@ -163,7 +163,7 @@ export declare namespace HashMap { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * // Create a product catalog HashMap * const catalog = HashMap.make( @@ -194,7 +194,7 @@ export declare namespace HashMap { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map = HashMap.make(["a", 1], ["b", 2]) * const notMap = { a: 1 } @@ -217,7 +217,7 @@ export const isHashMap: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map = HashMap.empty() * console.log(HashMap.isEmpty(map)) // true @@ -234,7 +234,7 @@ export const empty: () => HashMap = internal.empty * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map = HashMap.make(["a", 1], ["b", 2], ["c", 3]) * console.log(HashMap.size(map)) // 3 @@ -256,7 +256,7 @@ export const make: >( * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const entries = [["a", 1], ["b", 2], ["c", 3]] as const * const map = HashMap.fromIterable(entries) @@ -274,7 +274,7 @@ export const fromIterable: (entries: Iterable) => HashMap * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const emptyMap = HashMap.empty() * const nonEmptyMap = HashMap.make(["a", 1]) @@ -294,7 +294,7 @@ export const isEmpty: (self: HashMap) => boolean = internal.isEmpty * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * import * as Option from "effect/Option" * * const map = HashMap.make(["a", 1], ["b", 2]) @@ -320,7 +320,7 @@ export const get: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" import { Hash } from "effect/interfaces" * import * as Option from "effect/Option" * @@ -360,7 +360,7 @@ export const getHash: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * import * as Option from "effect/Option" * * const config = HashMap.make( @@ -396,7 +396,7 @@ export const getUnsafe: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map = HashMap.make(["a", 1], ["b", 2]) * @@ -422,7 +422,7 @@ export const has: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" import { Hash } from "effect/interfaces" * * // Create a map with case-sensitive keys @@ -453,7 +453,7 @@ export const hasHash: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const hm = HashMap.make([1, 'a']) * HashMap.hasBy(hm, (value, key) => value === 'a' && key === 1) // -> true @@ -474,7 +474,7 @@ export const hasBy: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map1 = HashMap.make(["a", 1]) * const map2 = HashMap.set(map1, "b", 2) @@ -499,7 +499,7 @@ export const set: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map = HashMap.make(["a", 1], ["b", 2], ["c", 3]) * const keys = Array.from(HashMap.keys(map)) @@ -516,7 +516,7 @@ export const keys: (self: HashMap) => IterableIterator = internal * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map = HashMap.make(["a", 1], ["b", 2], ["c", 3]) * const values = Array.from(HashMap.values(map)) @@ -533,7 +533,7 @@ export const values: (self: HashMap) => IterableIterator = intern * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const employees = HashMap.make( * ["alice", { department: "engineering", salary: 90000 }], @@ -564,7 +564,7 @@ export const toValues = (self: HashMap): Array => Array.from(valu * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * // Create a configuration map * const config = HashMap.make( @@ -599,7 +599,7 @@ export const entries: (self: HashMap) => IterableIterator<[K, V]> = * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const gameScores = HashMap.make( * ["alice", 1250], @@ -632,7 +632,7 @@ export const toEntries = (self: HashMap): Array<[K, V]> => Array.fro * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const emptyMap = HashMap.empty() * const map = HashMap.make(["a", 1], ["b", 2], ["c", 3]) @@ -651,7 +651,7 @@ export const size: (self: HashMap) => number = internal.size * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map = HashMap.make(["a", 1]) * @@ -678,7 +678,7 @@ export const beginMutation: (self: HashMap) => HashMap = inter * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * // Start with an existing map * const original = HashMap.make(["x", 10], ["y", 20]) @@ -709,7 +709,7 @@ export const endMutation: (self: HashMap) => HashMap = interna * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map1 = HashMap.make(["a", 1]) * const map2 = HashMap.mutate(map1, (mutable) => { @@ -737,7 +737,7 @@ export const mutate: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * import * as Option from "effect/Option" * * const map = HashMap.make(["a", 1], ["b", 2]) @@ -770,7 +770,7 @@ export const modifyAt: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" import { Hash } from "effect/interfaces" * import * as Option from "effect/Option" * @@ -809,7 +809,7 @@ export const modifyHash: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map1 = HashMap.make(["a", 1], ["b", 2]) * const map2 = HashMap.modify(map1, "a", (value) => value * 3) @@ -831,7 +831,7 @@ export const modify: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map1 = HashMap.make(["a", 1], ["b", 2]) * const map2 = HashMap.make(["b", 20], ["c", 3]) @@ -855,7 +855,7 @@ export const union: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map1 = HashMap.make(["a", 1], ["b", 2], ["c", 3]) * const map2 = HashMap.remove(map1, "b") @@ -878,7 +878,7 @@ export const remove: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map1 = HashMap.make(["a", 1], ["b", 2], ["c", 3], ["d", 4]) * const map2 = HashMap.removeMany(map1, ["b", "d"]) @@ -901,7 +901,7 @@ export const removeMany: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map1 = HashMap.make(["a", 1], ["b", 2]) * const newEntries = [["c", 3], ["d", 4], ["a", 10]] as const // "a" will be overwritten @@ -925,7 +925,7 @@ export const setMany: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map1 = HashMap.make(["a", 1], ["b", 2], ["c", 3]) * const map2 = HashMap.map(map1, (value, key) => `${key}:${value * 2}`) @@ -949,7 +949,7 @@ export const map: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map1 = HashMap.make(["a", 1], ["b", 2]) * const map2 = HashMap.flatMap(map1, (value, key) => @@ -974,7 +974,7 @@ export const flatMap: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map = HashMap.make(["a", 1], ["b", 2]) * const collected: Array<[string, number]> = [] @@ -999,7 +999,7 @@ export const forEach: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map = HashMap.make(["a", 1], ["b", 2], ["c", 3]) * const sum = HashMap.reduce(map, 0, (acc, value) => acc + value) @@ -1020,7 +1020,7 @@ export const reduce: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map1 = HashMap.make(["a", 1], ["b", 2], ["c", 3], ["d", 4]) * const map2 = HashMap.filter(map1, (value) => value % 2 === 0) @@ -1044,7 +1044,7 @@ export const filter: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * import * as Option from "effect/Option" * * const map1 = HashMap.make( @@ -1070,7 +1070,7 @@ export const compact: (self: HashMap>) => HashMap = int * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * import * as Option from "effect/Option" * * const map1 = HashMap.make(["a", 1], ["b", 2], ["c", 3], ["d", 4]) @@ -1097,7 +1097,7 @@ export const filterMap: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map = HashMap.make(["a", 1], ["b", 2], ["c", 3]) * const result = HashMap.findFirst(map, (value) => value > 1) @@ -1117,7 +1117,7 @@ export const findFirst: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map = HashMap.make(["a", 1], ["b", 2], ["c", 3]) * @@ -1138,7 +1138,7 @@ export const some: { * * @example * ```ts - * import * as HashMap from "effect/collections/HashMap" + * import * as HashMap from "effect/HashMap" * * const map = HashMap.make(["a", 1], ["b", 2], ["c", 3]) * diff --git a/packages/effect/src/collections/HashRing.ts b/packages/effect/src/HashRing.ts similarity index 96% rename from packages/effect/src/collections/HashRing.ts rename to packages/effect/src/HashRing.ts index bcd77a9857..b85458bbd2 100644 --- a/packages/effect/src/collections/HashRing.ts +++ b/packages/effect/src/HashRing.ts @@ -1,13 +1,13 @@ /** * @since 4.0.0 */ -import { dual } from "../Function.ts" -import * as Hash from "../interfaces/Hash.ts" -import { type Pipeable } from "../interfaces/Pipeable.ts" -import * as PrimaryKey from "../interfaces/PrimaryKey.ts" -import { PipeInspectableProto } from "../internal/core.ts" -import { hasProperty } from "../Predicate.ts" +import { dual } from "./Function.ts" +import * as Hash from "./interfaces/Hash.ts" +import { type Pipeable } from "./interfaces/Pipeable.ts" +import * as PrimaryKey from "./interfaces/PrimaryKey.ts" +import { PipeInspectableProto } from "./internal/core.ts" import * as Iterable from "./Iterable.ts" +import { hasProperty } from "./Predicate.ts" const TypeId = "~effect/cluster/HashRing" as const diff --git a/packages/effect/src/collections/HashSet.ts b/packages/effect/src/HashSet.ts similarity index 90% rename from packages/effect/src/collections/HashSet.ts rename to packages/effect/src/HashSet.ts index b694e6a8d4..5b994baed3 100644 --- a/packages/effect/src/collections/HashSet.ts +++ b/packages/effect/src/HashSet.ts @@ -2,13 +2,13 @@ * @since 2.0.0 */ -import * as Dual from "../Function.ts" -import type { Equal } from "../interfaces/Equal.ts" -import type { Inspectable } from "../interfaces/Inspectable.ts" -import type { Pipeable } from "../interfaces/Pipeable.ts" -import * as internal from "../internal/hashSet.ts" -import type { Predicate, Refinement } from "../Predicate.ts" -import type { NoInfer } from "../types/Types.ts" +import * as Dual from "./Function.ts" +import type { Equal } from "./interfaces/Equal.ts" +import type { Inspectable } from "./interfaces/Inspectable.ts" +import type { Pipeable } from "./interfaces/Pipeable.ts" +import * as internal from "./internal/hashSet.ts" +import type { Predicate, Refinement } from "./Predicate.ts" +import type { NoInfer } from "./types/Types.ts" const TypeId = internal.HashSetTypeId @@ -18,7 +18,7 @@ const TypeId = internal.HashSetTypeId * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * // Create a HashSet * const set = HashSet.make("apple", "banana", "cherry") @@ -49,7 +49,7 @@ export interface HashSet extends Iterable, Equal, Pipeable, In * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * // Create a concrete HashSet for type extraction * const fruits = HashSet.make("apple", "banana", "cherry") @@ -70,7 +70,7 @@ export declare namespace HashSet { /** * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * const numbers = HashSet.make(1, 2, 3, 4, 5) * @@ -91,7 +91,7 @@ export declare namespace HashSet { * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * const set = HashSet.empty() * @@ -113,7 +113,7 @@ export const empty: () => HashSet = internal.empty * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * const fruits = HashSet.make("apple", "banana", "cherry") * console.log(HashSet.size(fruits)) // 3 @@ -137,7 +137,7 @@ export const make: >( * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * const fromArray = HashSet.fromIterable(["a", "b", "c", "b", "a"]) * console.log(HashSet.size(fromArray)) // 3 @@ -159,7 +159,7 @@ export const fromIterable: (values: Iterable) => HashSet = internal.fro * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * const set = HashSet.make(1, 2, 3) * const array = [1, 2, 3] @@ -182,7 +182,7 @@ export const isHashSet: { * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * const set = HashSet.make("a", "b") * const withC = HashSet.add(set, "c") @@ -212,7 +212,7 @@ export const add: { * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * const set = HashSet.make("apple", "banana", "cherry") * @@ -254,7 +254,7 @@ export const has: { * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * const set = HashSet.make("a", "b", "c") * const withoutB = HashSet.remove(set, "b") @@ -284,7 +284,7 @@ export const remove: { * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * const empty = HashSet.empty() * console.log(HashSet.size(empty)) // 0 @@ -306,7 +306,7 @@ export const size: (self: HashSet) => number = internal.size * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * const empty = HashSet.empty() * console.log(HashSet.isEmpty(empty)) // true @@ -325,7 +325,7 @@ export const isEmpty: (self: HashSet) => boolean = internal.isEmpty * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * const set1 = HashSet.make("a", "b") * const set2 = HashSet.make("b", "c") @@ -351,7 +351,7 @@ export const union: { * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * const set1 = HashSet.make("a", "b", "c") * const set2 = HashSet.make("b", "c", "d") @@ -377,7 +377,7 @@ export const intersection: { * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * const set1 = HashSet.make("a", "b", "c") * const set2 = HashSet.make("b", "d") @@ -403,7 +403,7 @@ export const difference: { * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * const small = HashSet.make("a", "b") * const large = HashSet.make("a", "b", "c", "d") @@ -431,7 +431,7 @@ export const isSubset: { * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * const numbers = HashSet.make(1, 2, 3) * const doubled = HashSet.map(numbers, n => n * 2) @@ -461,7 +461,7 @@ export const map: { * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * const numbers = HashSet.make(1, 2, 3, 4, 5, 6) * const evens = HashSet.filter(numbers, n => n % 2 === 0) @@ -494,7 +494,7 @@ export const filter: { * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * const numbers = HashSet.make(1, 2, 3, 4, 5) * @@ -521,7 +521,7 @@ export const some: { * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * const numbers = HashSet.make(2, 4, 6, 8) * @@ -548,7 +548,7 @@ export const every: { * * @example * ```ts - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * * const numbers = HashSet.make(1, 2, 3, 4, 5) * const sum = HashSet.reduce(numbers, 0, (acc, n) => acc + n) diff --git a/packages/effect/src/collections/Iterable.ts b/packages/effect/src/Iterable.ts similarity index 95% rename from packages/effect/src/collections/Iterable.ts rename to packages/effect/src/Iterable.ts index 3cd13c5de4..d9494b3a17 100644 --- a/packages/effect/src/collections/Iterable.ts +++ b/packages/effect/src/Iterable.ts @@ -12,7 +12,7 @@ * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // Create iterables * const numbers = Iterable.range(1, 5) @@ -30,17 +30,17 @@ * @since 2.0.0 */ -import type { NonEmptyArray } from "../collections/Array.ts" -import { dual, identity } from "../Function.ts" -import * as Equal from "../interfaces/Equal.ts" -import type { Option } from "../Option.ts" -import * as O from "../Option.ts" -import { isBoolean } from "../Predicate.ts" -import type * as Record from "../Record.ts" -import type { Result } from "../Result.ts" -import * as R from "../Result.ts" -import * as Tuple from "../Tuple.ts" -import type { NoInfer } from "../types/Types.ts" +import type { NonEmptyArray } from "./Array.ts" +import { dual, identity } from "./Function.ts" +import * as Equal from "./interfaces/Equal.ts" +import type { Option } from "./Option.ts" +import * as O from "./Option.ts" +import { isBoolean } from "./Predicate.ts" +import type * as Record from "./Record.ts" +import type { Result } from "./Result.ts" +import * as R from "./Result.ts" +import * as Tuple from "./Tuple.ts" +import type { NoInfer } from "./types/Types.ts" /** * Creates an iterable by applying a function to consecutive integers. @@ -54,7 +54,7 @@ import type { NoInfer } from "../types/Types.ts" * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // Generate first 5 even numbers * const evens = Iterable.makeBy(n => n * 2, { length: 5 }) @@ -100,7 +100,7 @@ export const makeBy = (f: (i: number) => A, options?: { * @example * ```ts * import * as assert from "node:assert" - * import { range } from "effect/collections/Iterable" + * import { range } from "effect/Iterable" * * assert.deepStrictEqual(Array.from(range(1, 3)), [1, 2, 3]) * ``` @@ -125,7 +125,7 @@ export const range = (start: number, end?: number): Iterable => { * @example * ```ts * import * as assert from "node:assert" - * import { replicate } from "effect/collections/Iterable" + * import { replicate } from "effect/Iterable" * * assert.deepStrictEqual(Array.from(replicate("a", 3)), ["a", "a", "a"]) * ``` @@ -159,7 +159,7 @@ export const forever = (self: Iterable): Iterable => repeat(self, Infin * @example * ```ts * import * as assert from "node:assert" - * import { fromRecord } from "effect/collections/Iterable" + * import { fromRecord } from "effect/Iterable" * * const x = { a: 1, b: 2, c: 3 } * assert.deepStrictEqual(Array.from(fromRecord(x)), [["a", 1], ["b", 2], ["c", 3]]) @@ -183,7 +183,7 @@ export const fromRecord = (self: Readonly>): I * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * const numbers = [2, 3, 4] * const withOne = Iterable.prepend(numbers, 1) @@ -209,7 +209,7 @@ export const prepend: { * @example * ```ts * import * as assert from "node:assert" - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * assert.deepStrictEqual( * Array.from(Iterable.prependAll([1, 2], ["a", "b"])), @@ -233,7 +233,7 @@ export const prependAll: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * const numbers = [1, 2, 3] * const withFour = Iterable.append(numbers, 4) @@ -260,7 +260,7 @@ export const append: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * const first = [1, 2, 3] * const second = [4, 5, 6] @@ -316,7 +316,7 @@ export const appendAll: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // Running sum of numbers * const numbers = [1, 2, 3, 4, 5] @@ -366,7 +366,7 @@ export const scan: { * @example * ```ts * import * as assert from "node:assert" - * import { isEmpty } from "effect/collections/Iterable" + * import { isEmpty } from "effect/Iterable" * * assert.deepStrictEqual(isEmpty([]), true); * assert.deepStrictEqual(isEmpty([1, 2, 3]), false); @@ -385,7 +385,7 @@ export const isEmpty = (self: Iterable): self is Iterable => { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * const numbers = [1, 2, 3, 4, 5] * console.log(Iterable.size(numbers)) // 5 @@ -419,7 +419,7 @@ export const size = (self: Iterable): number => { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * import * as Option from "effect/Option" * * const numbers = [1, 2, 3] @@ -451,7 +451,7 @@ export const head = (self: Iterable): Option => { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * const numbers = [1, 2, 3] * console.log(Iterable.headUnsafe(numbers)) // 1 @@ -489,7 +489,7 @@ export const headUnsafe = (self: Iterable): A => { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * const numbers = [1, 2, 3, 4, 5] * const firstThree = Iterable.take(numbers, 3) @@ -536,7 +536,7 @@ export const take: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * const numbers = [2, 4, 6, 8, 3, 10, 12] * const evenPrefix = Iterable.takeWhile(numbers, x => x % 2 === 0) @@ -589,7 +589,7 @@ export const takeWhile: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * const numbers = [1, 2, 3, 4, 5] * const withoutFirstTwo = Iterable.drop(numbers, 2) @@ -639,7 +639,7 @@ export const drop: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * import * as Option from "effect/Option" * * const numbers = [1, 3, 4, 6, 8] @@ -703,7 +703,7 @@ export const findFirst: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * import * as Option from "effect/Option" * * const numbers = [1, 3, 4, 6, 8, 2] @@ -761,7 +761,7 @@ export const findLast: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * const numbers = [1, 2, 3] * const letters = ["a", "b", "c"] @@ -804,7 +804,7 @@ export const zip: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // Add corresponding elements * const a = [1, 2, 3, 4] @@ -862,7 +862,7 @@ export const zipWith: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // Join numbers with separator * const numbers = [1, 2, 3, 4] @@ -923,7 +923,7 @@ export const intersperse: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // Custom equivalence for objects * const byId = (a: { id: number }, b: { id: number }) => a.id === b.id @@ -973,7 +973,7 @@ const _equivalence = Equal.equivalence() * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * const numbers = [1, 2, 3, 4, 5] * console.log(Iterable.contains(numbers, 3)) // true @@ -1008,7 +1008,7 @@ export const contains: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9] * const chunks = Iterable.chunksOf(numbers, 3) @@ -1075,7 +1075,7 @@ export const chunksOf: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // Group consecutive equal numbers * const numbers = [1, 1, 2, 2, 2, 3, 1, 1] @@ -1152,7 +1152,7 @@ export const groupWith: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * const numbers = [1, 1, 2, 2, 2, 3, 1, 1] * const grouped = Iterable.group(numbers) @@ -1189,7 +1189,7 @@ export const group: (self: Iterable) => Iterable> = group * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // Group by string length * const words = ["a", "bb", "ccc", "dd", "eee", "f"] @@ -1270,7 +1270,7 @@ const constEmptyIterator: Iterator = { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * const empty = Iterable.empty() * console.log(Array.from(empty)) // [] @@ -1298,7 +1298,7 @@ export const empty = (): Iterable => constEmpty * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * const single = Iterable.of(42) * console.log(Array.from(single)) // [42] @@ -1336,7 +1336,7 @@ export const of = (a: A): Iterable => [a] * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // Transform numbers to their squares * const numbers = [1, 2, 3, 4, 5] @@ -1384,7 +1384,7 @@ export const map: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // Expand each number to a range * const numbers = [1, 2, 3] @@ -1429,7 +1429,7 @@ export const flatMap: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // Flatten nested arrays * const nested = [[1, 2], [3, 4], [5, 6]] @@ -1487,7 +1487,7 @@ export const flatten = (self: Iterable>): Iterable => ({ * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * import * as Option from "effect/Option" * * // Parse strings to numbers, keeping only valid ones @@ -1552,7 +1552,7 @@ export const filterMap: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * import * as Option from "effect/Option" * * // Parse numbers until we hit an invalid one @@ -1610,7 +1610,7 @@ export const filterMapWhile: { * @example * ```ts * import * as assert from "node:assert" - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * import * as Option from "effect/Option" * * assert.deepStrictEqual( @@ -1630,7 +1630,7 @@ export const getSomes: (self: Iterable>) => Iterable = filterMap * @example * ```ts * import * as assert from "node:assert" - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * import * as Result from "effect/Result" * * assert.deepStrictEqual( @@ -1650,7 +1650,7 @@ export const getFailures = (self: Iterable>): Iterable => * @example * ```ts * import * as assert from "node:assert" - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * import * as Result from "effect/Result" * * assert.deepStrictEqual( @@ -1676,7 +1676,7 @@ export const getSuccesses = (self: Iterable>): Iterable => * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // Filter even numbers * const numbers = [1, 2, 3, 4, 5, 6] @@ -1739,7 +1739,7 @@ export const filter: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // Extract valid elements from nullable function results * const data = ["1", "2", "invalid", "4"] @@ -1790,7 +1790,7 @@ export const flatMapNullishOr: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * const numbers = [1, 3, 5, 7, 8] * const hasEven = Iterable.some(numbers, x => x % 2 === 0) @@ -1848,7 +1848,7 @@ export const some: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // Generate Fibonacci sequence * const fibonacci = Iterable.unfold([0, 1], ([a, b]) => @@ -1903,7 +1903,7 @@ export const unfold = (b: B, f: (b: B) => readonly [A, B] | undefined): It * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // Print each element * const numbers = [1, 2, 3, 4, 5] @@ -1953,7 +1953,7 @@ export const forEach: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // Sum all numbers * const numbers = [1, 2, 3, 4, 5] @@ -2005,7 +2005,7 @@ export const reduce: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // Remove adjacent duplicates with custom equality * const numbers = [1, 1, 2, 2, 3, 1, 1] @@ -2074,7 +2074,7 @@ export const dedupeAdjacentWith: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // Remove adjacent duplicate numbers * const numbers = [1, 1, 2, 2, 2, 3, 1, 1] @@ -2113,7 +2113,7 @@ export const dedupeAdjacent: (self: Iterable) => Iterable = dedupeAdjac * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // Create coordinate pairs * const xs = [1, 2] @@ -2165,7 +2165,7 @@ export const cartesianWith: { * * @example * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * // All pairs of numbers and letters * const numbers = [1, 2, 3] @@ -2214,7 +2214,7 @@ export const cartesian: { * **Example** * * ```ts - * import { Iterable } from "effect/collections" + * import { Iterable } from "effect" * * const result = Iterable.countBy([1, 2, 3, 4, 5], n => n % 2 === 0) * console.log(result) // 2 diff --git a/packages/effect/src/Layer.ts b/packages/effect/src/Layer.ts index 018470a7cf..103d814ef9 100644 --- a/packages/effect/src/Layer.ts +++ b/packages/effect/src/Layer.ts @@ -17,8 +17,8 @@ * * @since 2.0.0 */ +import type { NonEmptyArray } from "./Array.ts" import type * as Cause from "./Cause.ts" -import type { NonEmptyArray } from "./collections/Array.ts" import * as Deferred from "./Deferred.ts" import type { Effect } from "./Effect.ts" import type * as Exit from "./Exit.ts" diff --git a/packages/effect/src/Logger.ts b/packages/effect/src/Logger.ts index 85b42c0048..168af4d879 100644 --- a/packages/effect/src/Logger.ts +++ b/packages/effect/src/Logger.ts @@ -99,8 +99,8 @@ * }) * ``` */ +import * as Array from "./Array.ts" import type * as Cause from "./Cause.ts" -import * as Array from "./collections/Array.ts" import type * as Duration from "./Duration.ts" import type * as Effect from "./Effect.ts" import type * as Fiber from "./Fiber.ts" diff --git a/packages/effect/src/Metric.ts b/packages/effect/src/Metric.ts index 6894df03cf..9a64936273 100644 --- a/packages/effect/src/Metric.ts +++ b/packages/effect/src/Metric.ts @@ -137,7 +137,7 @@ * ``` */ -import * as Arr from "./collections/Array.ts" +import * as Arr from "./Array.ts" import * as Duration from "./Duration.ts" import type { Effect } from "./Effect.ts" import type { Exit } from "./Exit.ts" diff --git a/packages/effect/src/collections/MutableHashMap.ts b/packages/effect/src/MutableHashMap.ts similarity index 92% rename from packages/effect/src/collections/MutableHashMap.ts rename to packages/effect/src/MutableHashMap.ts index 2e3ac3148f..39e7c1ecfb 100644 --- a/packages/effect/src/collections/MutableHashMap.ts +++ b/packages/effect/src/MutableHashMap.ts @@ -24,22 +24,22 @@ * @since 2.0.0 * @category data-structures */ -import type { NonEmptyArray } from "../collections/Array.ts" -import { format } from "../Formatter.ts" -import { dual } from "../Function.ts" -import * as Equal from "../interfaces/Equal.ts" -import * as Hash from "../interfaces/Hash.ts" -import { type Inspectable, NodeInspectSymbol, toJson } from "../interfaces/Inspectable.ts" -import type { Pipeable } from "../interfaces/Pipeable.ts" -import { pipeArguments } from "../interfaces/Pipeable.ts" -import * as Option from "../Option.ts" +import type { NonEmptyArray } from "./Array.ts" +import { format } from "./Formatter.ts" +import { dual } from "./Function.ts" +import * as Equal from "./interfaces/Equal.ts" +import * as Hash from "./interfaces/Hash.ts" +import { type Inspectable, NodeInspectSymbol, toJson } from "./interfaces/Inspectable.ts" +import type { Pipeable } from "./interfaces/Pipeable.ts" +import { pipeArguments } from "./interfaces/Pipeable.ts" +import * as Option from "./Option.ts" const TypeId = "~effect/collections/MutableHashMap" /** * @example * ```ts - * import * as MutableHashMap from "effect/collections/MutableHashMap" + * import * as MutableHashMap from "effect/MutableHashMap" * * // Create a mutable hash map with string keys and number values * const map: MutableHashMap.MutableHashMap = MutableHashMap.empty() @@ -97,7 +97,7 @@ const MutableHashMapProto: Omit, "backing" | "b * * @example * ```ts - * import * as MutableHashMap from "effect/collections/MutableHashMap" + * import * as MutableHashMap from "effect/MutableHashMap" * * const map = MutableHashMap.empty() * @@ -123,7 +123,7 @@ export const empty = (): MutableHashMap => { * * @example * ```ts - * import * as MutableHashMap from "effect/collections/MutableHashMap" + * import * as MutableHashMap from "effect/MutableHashMap" * * const map = MutableHashMap.make( * ["key1", 42], @@ -150,7 +150,7 @@ export const make: >( * * @example * ```ts - * import * as MutableHashMap from "effect/collections/MutableHashMap" + * import * as MutableHashMap from "effect/MutableHashMap" * * const entries = [ * ["apple", 1], @@ -184,7 +184,7 @@ export const fromIterable = (entries: Iterable): MutableH * * @example * ```ts - * import * as MutableHashMap from "effect/collections/MutableHashMap" + * import * as MutableHashMap from "effect/MutableHashMap" * import * as Option from "effect/Option" * * const map = MutableHashMap.make(["key1", 42], ["key2", 100]) @@ -232,7 +232,7 @@ const isSimpleKey = (u: unknown): boolean => typeof u !== "object" && typeof u ! * * @example * ```ts - * import * as MutableHashMap from "effect/collections/MutableHashMap" + * import * as MutableHashMap from "effect/MutableHashMap" * * const map = MutableHashMap.make( * ["apple", 1], @@ -257,7 +257,7 @@ export const keys = (self: MutableHashMap): Iterable => self.back * * @example * ```ts - * import * as MutableHashMap from "effect/collections/MutableHashMap" + * import * as MutableHashMap from "effect/MutableHashMap" * * const map = MutableHashMap.make( * ["apple", 1], @@ -302,7 +302,7 @@ const getFromBucket = ( * * @example * ```ts - * import * as MutableHashMap from "effect/collections/MutableHashMap" + * import * as MutableHashMap from "effect/MutableHashMap" * * const map = MutableHashMap.make(["key1", 42], ["key2", 100]) * @@ -331,7 +331,7 @@ export const has: { * * @example * ```ts - * import * as MutableHashMap from "effect/collections/MutableHashMap" + * import * as MutableHashMap from "effect/MutableHashMap" * * const map = MutableHashMap.empty() * @@ -407,7 +407,7 @@ const getRefKey = ( * * @example * ```ts - * import * as MutableHashMap from "effect/collections/MutableHashMap" + * import * as MutableHashMap from "effect/MutableHashMap" * * const map = MutableHashMap.make(["count", 5], ["total", 100]) * @@ -473,7 +473,7 @@ export const modify: { * * @example * ```ts - * import * as MutableHashMap from "effect/collections/MutableHashMap" + * import * as MutableHashMap from "effect/MutableHashMap" * import * as Option from "effect/Option" * * const map = MutableHashMap.make(["count", 5]) @@ -536,7 +536,7 @@ export const modifyAt: { * * @example * ```ts - * import * as MutableHashMap from "effect/collections/MutableHashMap" + * import * as MutableHashMap from "effect/MutableHashMap" * * const map = MutableHashMap.make( * ["key1", 42], @@ -602,7 +602,7 @@ export const remove: { * * @example * ```ts - * import * as MutableHashMap from "effect/collections/MutableHashMap" + * import * as MutableHashMap from "effect/MutableHashMap" * * const map = MutableHashMap.make( * ["key1", 42], @@ -637,7 +637,7 @@ export const clear = (self: MutableHashMap) => { * * @example * ```ts - * import * as MutableHashMap from "effect/collections/MutableHashMap" + * import * as MutableHashMap from "effect/MutableHashMap" * * const map = MutableHashMap.empty() * console.log(MutableHashMap.size(map)) // 0 diff --git a/packages/effect/src/collections/MutableHashSet.ts b/packages/effect/src/MutableHashSet.ts similarity index 91% rename from packages/effect/src/collections/MutableHashSet.ts rename to packages/effect/src/MutableHashSet.ts index 118baee387..0d39b2c7ba 100644 --- a/packages/effect/src/collections/MutableHashSet.ts +++ b/packages/effect/src/MutableHashSet.ts @@ -24,19 +24,19 @@ * @since 2.0.0 * @category data-structures */ -import * as MutableHashMap from "../collections/MutableHashMap.ts" -import { format } from "../Formatter.ts" -import * as Dual from "../Function.ts" -import { type Inspectable, NodeInspectSymbol, toJson } from "../interfaces/Inspectable.ts" -import type { Pipeable } from "../interfaces/Pipeable.ts" -import { pipeArguments } from "../interfaces/Pipeable.ts" +import { format } from "./Formatter.ts" +import * as Dual from "./Function.ts" +import { type Inspectable, NodeInspectSymbol, toJson } from "./interfaces/Inspectable.ts" +import type { Pipeable } from "./interfaces/Pipeable.ts" +import { pipeArguments } from "./interfaces/Pipeable.ts" +import * as MutableHashMap from "./MutableHashMap.ts" const TypeId = "~effect/collections/MutableHashSet" /** * @example * ```ts - * import { MutableHashSet } from "effect/collections" + * import { MutableHashSet } from "effect" * * // Create a mutable hash set * const set: MutableHashSet.MutableHashSet = MutableHashSet.make("apple", "banana") @@ -98,7 +98,7 @@ const fromHashMap = (keyMap: MutableHashMap.MutableHashMap): Muta * * @example * ```ts - * import { MutableHashSet } from "effect/collections" + * import { MutableHashSet } from "effect" * * const set = MutableHashSet.empty() * @@ -122,7 +122,7 @@ export const empty = (): MutableHashSet => fromHashMap(MutableHash * * @example * ```ts - * import { MutableHashSet } from "effect/collections" + * import { MutableHashSet } from "effect" * * const values = ["apple", "banana", "apple", "cherry", "banana"] * const set = MutableHashSet.fromIterable(values) @@ -151,7 +151,7 @@ export const fromIterable = (keys: Iterable): MutableHashSet => * * @example * ```ts - * import { MutableHashSet } from "effect/collections" + * import { MutableHashSet } from "effect" * * const set = MutableHashSet.make("apple", "banana", "apple", "cherry") * @@ -181,7 +181,7 @@ export const make = >( * * @example * ```ts - * import { MutableHashSet } from "effect/collections" + * import { MutableHashSet } from "effect" * * const set = MutableHashSet.empty() * @@ -218,7 +218,7 @@ export const add: { * * @example * ```ts - * import { MutableHashSet } from "effect/collections" + * import { MutableHashSet } from "effect" * * const set = MutableHashSet.make("apple", "banana", "cherry") * @@ -251,7 +251,7 @@ export const has: { * * @example * ```ts - * import { MutableHashSet } from "effect/collections" + * import { MutableHashSet } from "effect" * * const set = MutableHashSet.make("apple", "banana", "cherry") * @@ -288,7 +288,7 @@ export const remove: { * * @example * ```ts - * import { MutableHashSet } from "effect/collections" + * import { MutableHashSet } from "effect" * * const set = MutableHashSet.empty() * console.log(MutableHashSet.size(set)) // 0 @@ -316,7 +316,7 @@ export const size = (self: MutableHashSet): number => MutableHashMap.size( * * @example * ```ts - * import { MutableHashSet } from "effect/collections" + * import { MutableHashSet } from "effect" * * const set = MutableHashSet.make("apple", "banana", "cherry") * diff --git a/packages/effect/src/collections/MutableList.ts b/packages/effect/src/MutableList.ts similarity index 95% rename from packages/effect/src/collections/MutableList.ts rename to packages/effect/src/MutableList.ts index 4044e5838f..93cfb7834c 100644 --- a/packages/effect/src/collections/MutableList.ts +++ b/packages/effect/src/MutableList.ts @@ -34,7 +34,7 @@ * @since 4.0.0 * @category data-structures */ -import * as Arr from "../collections/Array.ts" +import * as Arr from "./Array.ts" /** * A mutable linked list data structure optimized for high-throughput operations. @@ -43,7 +43,7 @@ import * as Arr from "../collections/Array.ts" * * @example * ```ts - * import * as MutableList from "effect/collections/MutableList" + * import * as MutableList from "effect/MutableList" * * // Create a mutable list * const list: MutableList.MutableList = MutableList.make() @@ -79,7 +79,7 @@ export interface MutableList { * * @example * ```ts - * import * as MutableList from "effect/collections/MutableList" + * import * as MutableList from "effect/MutableList" * * // Type annotation using the namespace * const processQueue = (queue: MutableList.MutableList) => { @@ -116,7 +116,7 @@ export declare namespace MutableList { * * @example * ```ts - * import * as MutableList from "effect/collections/MutableList" + * import * as MutableList from "effect/MutableList" * * const list = MutableList.make() * MutableList.append(list, 1) @@ -153,7 +153,7 @@ export declare namespace MutableList { * * @example * ```ts - * import * as MutableList from "effect/collections/MutableList" + * import * as MutableList from "effect/MutableList" * * const list = MutableList.make() * @@ -191,7 +191,7 @@ export const Empty: unique symbol = Symbol.for("effect/MutableList/Empty") * * @example * ```ts - * import * as MutableList from "effect/collections/MutableList" + * import * as MutableList from "effect/MutableList" * * const list = MutableList.make() * @@ -235,7 +235,7 @@ export type Empty = typeof Empty * * @example * ```ts - * import * as MutableList from "effect/collections/MutableList" + * import * as MutableList from "effect/MutableList" * * const list = MutableList.make() * @@ -274,7 +274,7 @@ const emptyBucket = (): MutableList.Bucket => ({ * * @example * ```ts - * import * as MutableList from "effect/collections/MutableList" + * import * as MutableList from "effect/MutableList" * * const list = MutableList.make() * @@ -316,7 +316,7 @@ export const append = (self: MutableList, message: A): void => { * * @example * ```ts - * import * as MutableList from "effect/collections/MutableList" + * import * as MutableList from "effect/MutableList" * * const list = MutableList.make() * @@ -358,7 +358,7 @@ export const prepend = (self: MutableList, message: A): void => { * * @example * ```ts - * import * as MutableList from "effect/collections/MutableList" + * import * as MutableList from "effect/MutableList" * * const list = MutableList.make() * MutableList.append(list, 4) @@ -393,7 +393,7 @@ export const prependAll = (self: MutableList, messages: Iterable): void * * @example * ```ts - * import * as MutableList from "effect/collections/MutableList" + * import * as MutableList from "effect/MutableList" * * const list = MutableList.make() * MutableList.append(list, 4) @@ -430,7 +430,7 @@ export const prependAllUnsafe = (self: MutableList, messages: ReadonlyArra * * @example * ```ts - * import * as MutableList from "effect/collections/MutableList" + * import * as MutableList from "effect/MutableList" * * const list = MutableList.make() * MutableList.append(list, 1) @@ -471,7 +471,7 @@ export const appendAll = (self: MutableList, messages: Iterable): numbe * * @example * ```ts - * import * as MutableList from "effect/collections/MutableList" + * import * as MutableList from "effect/MutableList" * * const list = MutableList.make() * MutableList.append(list, 1) @@ -519,7 +519,7 @@ export const appendAllUnsafe = (self: MutableList, messages: ReadonlyArray * * @example * ```ts - * import * as MutableList from "effect/collections/MutableList" + * import * as MutableList from "effect/MutableList" * * const list = MutableList.make() * MutableList.appendAll(list, [1, 2, 3, 4, 5]) @@ -558,7 +558,7 @@ export const clear = (self: MutableList): void => { * * @example * ```ts - * import * as MutableList from "effect/collections/MutableList" + * import * as MutableList from "effect/MutableList" * * const list = MutableList.make() * MutableList.appendAll(list, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) @@ -655,7 +655,7 @@ export const takeNVoid = (self: MutableList, n: number): void => { * * @example * ```ts - * import * as MutableList from "effect/collections/MutableList" + * import * as MutableList from "effect/MutableList" * * const list = MutableList.make() * MutableList.appendAll(list, ["apple", "banana", "cherry"]) @@ -696,7 +696,7 @@ export const takeAll = (self: MutableList): Array => takeN(self, self.l * * @example * ```ts - * import * as MutableList from "effect/collections/MutableList" + * import * as MutableList from "effect/MutableList" * * const list = MutableList.make() * MutableList.appendAll(list, ["first", "second", "third"]) @@ -781,7 +781,7 @@ export const toArray = (self: MutableList): Array => toArrayN(self, sel * * @example * ```ts - * import * as MutableList from "effect/collections/MutableList" + * import * as MutableList from "effect/MutableList" * * const list = MutableList.make() * MutableList.appendAll(list, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) @@ -844,7 +844,7 @@ export const filter = (self: MutableList, f: (value: A, i: number) => bool * * @example * ```ts - * import * as MutableList from "effect/collections/MutableList" + * import * as MutableList from "effect/MutableList" * * const list = MutableList.make() * MutableList.appendAll(list, ["apple", "banana", "apple", "cherry", "apple"]) diff --git a/packages/effect/src/collections/NonEmptyIterable.ts b/packages/effect/src/NonEmptyIterable.ts similarity index 92% rename from packages/effect/src/collections/NonEmptyIterable.ts rename to packages/effect/src/NonEmptyIterable.ts index 9ddae7d278..131893e3b2 100644 --- a/packages/effect/src/collections/NonEmptyIterable.ts +++ b/packages/effect/src/NonEmptyIterable.ts @@ -23,7 +23,7 @@ * ## Basic Usage * * ```ts - * import * as NonEmptyIterable from "effect/collections/NonEmptyIterable" + * import * as NonEmptyIterable from "effect/NonEmptyIterable" * * // NonEmptyIterable is a type that represents any iterable with at least one element * function processNonEmpty(data: NonEmptyIterable.NonEmptyIterable): A { @@ -54,9 +54,9 @@ * * ```ts * import { pipe } from "effect" - * import * as NonEmptyIterable from "effect/collections/NonEmptyIterable" - * import { Array } from "effect/collections" - * import * as Chunk from "effect/collections/Chunk" + * import * as NonEmptyIterable from "effect/NonEmptyIterable" + * import { Array } from "effect" + * import * as Chunk from "effect/Chunk" * * // Creating non-empty arrays * const nonEmptyArray = Array.make(1, 2, 3) as unknown as NonEmptyIterable.NonEmptyIterable @@ -94,9 +94,9 @@ * * ```ts * import { pipe } from "effect" - * import * as NonEmptyIterable from "effect/collections/NonEmptyIterable" - * import { Array } from "effect/collections" - * import * as Chunk from "effect/collections/Chunk" + * import * as NonEmptyIterable from "effect/NonEmptyIterable" + * import { Array } from "effect" + * import * as Chunk from "effect/Chunk" * * // Many Array functions work with NonEmptyIterable * declare const nonEmptyData: NonEmptyIterable.NonEmptyIterable @@ -128,7 +128,7 @@ * * @example * ```ts - * import * as NonEmptyIterable from "effect/collections/NonEmptyIterable" + * import * as NonEmptyIterable from "effect/NonEmptyIterable" * * // The symbol is used internally for type branding * declare const data: NonEmptyIterable @@ -161,9 +161,9 @@ export declare const nonEmpty: unique symbol * * @example * ```ts - * import * as NonEmptyIterable from "effect/collections/NonEmptyIterable" - * import { Array } from "effect/collections" - * import * as Chunk from "effect/collections/Chunk" + * import * as NonEmptyIterable from "effect/NonEmptyIterable" + * import { Array } from "effect" + * import * as Chunk from "effect/Chunk" * * // Function that requires non-empty data * function getFirst(data: NonEmptyIterable.NonEmptyIterable): A { @@ -210,9 +210,9 @@ export interface NonEmptyIterable extends Iterable { * * @example * ```ts - * import * as NonEmptyIterable from "effect/collections/NonEmptyIterable" - * import { Array } from "effect/collections" - * import * as Chunk from "effect/collections/Chunk" + * import * as NonEmptyIterable from "effect/NonEmptyIterable" + * import { Array } from "effect" + * import * as Chunk from "effect/Chunk" * * // Helper to make iterator iterable for Array.from * const iteratorToIterable = (iterator: Iterator): Iterable => ({ diff --git a/packages/effect/src/Pool.ts b/packages/effect/src/Pool.ts index db0c1054fe..21dc2116e0 100644 --- a/packages/effect/src/Pool.ts +++ b/packages/effect/src/Pool.ts @@ -3,13 +3,13 @@ */ import type * as Cause from "./Cause.ts" import { Clock } from "./Clock.ts" -import * as Iterable from "./collections/Iterable.ts" import * as Duration from "./Duration.ts" import * as Effect from "./Effect.ts" import type * as Exit from "./Exit.ts" import * as Fiber from "./Fiber.ts" import { dual, identity } from "./Function.ts" import { type Pipeable, pipeArguments } from "./interfaces/Pipeable.ts" +import * as Iterable from "./Iterable.ts" import { hasProperty } from "./Predicate.ts" import * as Queue from "./Queue.ts" import { UnhandledLogLevel } from "./References.ts" diff --git a/packages/effect/src/PubSub.ts b/packages/effect/src/PubSub.ts index 1473692fda..e8012488d3 100644 --- a/packages/effect/src/PubSub.ts +++ b/packages/effect/src/PubSub.ts @@ -30,14 +30,14 @@ * * @since 2.0.0 */ -import * as Arr from "./collections/Array.ts" -import * as MutableList from "./collections/MutableList.ts" +import * as Arr from "./Array.ts" import * as Deferred from "./Deferred.ts" import * as Effect from "./Effect.ts" import * as Exit from "./Exit.ts" import type { LazyArg } from "./Function.ts" import { dual, identity } from "./Function.ts" import { type Pipeable, pipeArguments } from "./interfaces/Pipeable.ts" +import * as MutableList from "./MutableList.ts" import * as MutableRef from "./MutableRef.ts" import { nextPow2 } from "./Number.ts" import * as Scope from "./Scope.ts" diff --git a/packages/effect/src/Queue.ts b/packages/effect/src/Queue.ts index 5b85fc0823..9c73dfb0f5 100644 --- a/packages/effect/src/Queue.ts +++ b/packages/effect/src/Queue.ts @@ -33,9 +33,8 @@ * * @since 3.8.0 */ +import * as Arr from "./Array.ts" import type { Cause } from "./Cause.ts" -import * as Arr from "./collections/Array.ts" -import * as MutableList from "./collections/MutableList.ts" import type { Effect } from "./Effect.ts" import type { Exit, Failure } from "./Exit.ts" import * as Filter from "./Filter.ts" @@ -44,6 +43,7 @@ import type { Inspectable } from "./interfaces/Inspectable.ts" import * as core from "./internal/core.ts" import { PipeInspectableProto } from "./internal/core.ts" import * as internalEffect from "./internal/effect.ts" +import * as MutableList from "./MutableList.ts" import { hasProperty } from "./Predicate.ts" import * as Pull from "./Pull.ts" import type { Scheduler } from "./Scheduler.ts" diff --git a/packages/effect/src/RcMap.ts b/packages/effect/src/RcMap.ts index 52160047ab..d9a60a8b43 100644 --- a/packages/effect/src/RcMap.ts +++ b/packages/effect/src/RcMap.ts @@ -3,7 +3,6 @@ */ import * as Cause from "./Cause.ts" import { Clock } from "./Clock.ts" -import * as MutableHashMap from "./collections/MutableHashMap.ts" import * as Deferred from "./Deferred.ts" import * as Duration from "./Duration.ts" import * as Effect from "./Effect.ts" @@ -12,6 +11,7 @@ import * as Fiber from "./Fiber.ts" import { constant, dual, flow } from "./Function.ts" import type { Pipeable } from "./interfaces/Pipeable.ts" import { pipeArguments } from "./interfaces/Pipeable.ts" +import * as MutableHashMap from "./MutableHashMap.ts" import * as Scope from "./Scope.ts" import * as ServiceMap from "./ServiceMap.ts" @@ -116,7 +116,7 @@ export declare namespace State { * @category Models * @example * ```ts - * import * as MutableHashMap from "effect/collections/MutableHashMap" + * import * as MutableHashMap from "effect/MutableHashMap" * import { RcMap } from "effect" * * // State.Open contains the active resource map diff --git a/packages/effect/src/RequestResolver.ts b/packages/effect/src/RequestResolver.ts index 1732bca378..02852e0860 100644 --- a/packages/effect/src/RequestResolver.ts +++ b/packages/effect/src/RequestResolver.ts @@ -1,11 +1,9 @@ /** * @since 2.0.0 */ +import type { NonEmptyArray } from "./Array.ts" +import * as Arr from "./Array.ts" import * as Cache from "./Cache.ts" -import type { NonEmptyArray } from "./collections/Array.ts" -import * as Arr from "./collections/Array.ts" -import * as Iterable from "./collections/Iterable.ts" -import * as MutableHashMap from "./collections/MutableHashMap.ts" import type * as Duration from "./Duration.ts" import * as Effect from "./Effect.ts" import * as Exit from "./Exit.ts" @@ -14,6 +12,8 @@ import { type Pipeable, pipeArguments } from "./interfaces/Pipeable.ts" import { exitFail, exitSucceed } from "./internal/core.ts" import * as effect from "./internal/effect.ts" import * as internal from "./internal/request.ts" +import * as Iterable from "./Iterable.ts" +import * as MutableHashMap from "./MutableHashMap.ts" import { hasProperty } from "./Predicate.ts" import type * as Request from "./Request.ts" import type * as Schema from "./schema/Schema.ts" diff --git a/packages/effect/src/ScopedCache.ts b/packages/effect/src/ScopedCache.ts index fa11d91261..9201cf9abf 100644 --- a/packages/effect/src/ScopedCache.ts +++ b/packages/effect/src/ScopedCache.ts @@ -1,8 +1,7 @@ /** * @since 4.0.0 */ -import * as Arr from "./collections/Array.ts" -import * as MutableHashMap from "./collections/MutableHashMap.ts" +import * as Arr from "./Array.ts" import * as Deferred from "./Deferred.ts" import * as Duration from "./Duration.ts" import type * as Effect from "./Effect.ts" @@ -13,6 +12,7 @@ import type { Pipeable } from "./interfaces/Pipeable.ts" import * as core from "./internal/core.ts" import { PipeInspectableProto } from "./internal/core.ts" import * as effect from "./internal/effect.ts" +import * as MutableHashMap from "./MutableHashMap.ts" import * as Option from "./Option.ts" import * as Predicate from "./Predicate.ts" import * as Scope from "./Scope.ts" diff --git a/packages/effect/src/Sink.ts b/packages/effect/src/Sink.ts index 76b899874b..65d084945b 100644 --- a/packages/effect/src/Sink.ts +++ b/packages/effect/src/Sink.ts @@ -1,11 +1,11 @@ /** * @since 2.0.0 */ +import type { NonEmptyReadonlyArray } from "./Array.ts" +import * as Arr from "./Array.ts" import type * as Cause from "./Cause.ts" import * as Channel from "./Channel.ts" -import type { NonEmptyReadonlyArray } from "./collections/Array.ts" -import * as Arr from "./collections/Array.ts" -import * as Chunk from "./collections/Chunk.ts" +import * as Chunk from "./Chunk.ts" import * as Effect from "./Effect.ts" import * as Filter from "./Filter.ts" import type { LazyArg } from "./Function.ts" diff --git a/packages/effect/src/Stream.ts b/packages/effect/src/Stream.ts index 6e9e9d1d62..38e6682497 100644 --- a/packages/effect/src/Stream.ts +++ b/packages/effect/src/Stream.ts @@ -2,13 +2,10 @@ * @since 2.0.0 */ // @effect-diagnostics returnEffectInGen:off +import * as Arr from "./Array.ts" import * as Cause from "./Cause.ts" import * as Channel from "./Channel.ts" import { Clock } from "./Clock.ts" -import * as Arr from "./collections/Array.ts" -import * as Iterable from "./collections/Iterable.ts" -import * as MutableHashMap from "./collections/MutableHashMap.ts" -import * as MutableList from "./collections/MutableList.ts" import * as Duration from "./Duration.ts" import * as Effect from "./Effect.ts" import * as ExecutionPlan from "./ExecutionPlan.ts" @@ -21,7 +18,10 @@ import * as Equal from "./interfaces/Equal.ts" import { type Pipeable, pipeArguments } from "./interfaces/Pipeable.ts" import * as internalExecutionPlan from "./internal/executionPlan.ts" import { addSpanStackTrace } from "./internal/tracer.ts" +import * as Iterable from "./Iterable.ts" import type * as Layer from "./Layer.ts" +import * as MutableHashMap from "./MutableHashMap.ts" +import * as MutableList from "./MutableList.ts" import * as Option from "./Option.ts" import { hasProperty, isTagged } from "./Predicate.ts" import type * as PubSub from "./PubSub.ts" diff --git a/packages/effect/src/String.ts b/packages/effect/src/String.ts index 9d113aac51..7cd59a6787 100644 --- a/packages/effect/src/String.ts +++ b/packages/effect/src/String.ts @@ -6,7 +6,7 @@ * @since 2.0.0 */ -import type { NonEmptyArray } from "./collections/Array.ts" +import type { NonEmptyArray } from "./Array.ts" import { dual } from "./Function.ts" import * as readonlyArray from "./internal/array.ts" import * as number from "./Number.ts" diff --git a/packages/effect/src/Take.ts b/packages/effect/src/Take.ts index a6e06ef230..85ca4bfe48 100644 --- a/packages/effect/src/Take.ts +++ b/packages/effect/src/Take.ts @@ -1,7 +1,7 @@ /** * @since 2.0.0 */ -import type { NonEmptyReadonlyArray } from "./collections/Array.ts" +import type { NonEmptyReadonlyArray } from "./Array.ts" import * as Effect from "./Effect.ts" import * as Exit from "./Exit.ts" import * as Pull from "./Pull.ts" diff --git a/packages/effect/src/collections/Trie.ts b/packages/effect/src/Trie.ts similarity index 92% rename from packages/effect/src/collections/Trie.ts rename to packages/effect/src/Trie.ts index cd8fde7a65..d25d0cc75f 100644 --- a/packages/effect/src/collections/Trie.ts +++ b/packages/effect/src/Trie.ts @@ -15,12 +15,12 @@ * * @since 2.0.0 */ -import type { Equal } from "../interfaces/Equal.ts" -import type { Inspectable } from "../interfaces/Inspectable.ts" -import type { Pipeable } from "../interfaces/Pipeable.ts" -import * as TR from "../internal/trie.ts" -import type { Option } from "../Option.ts" -import type { Covariant, NoInfer } from "../types/Types.ts" +import type { Equal } from "./interfaces/Equal.ts" +import type { Inspectable } from "./interfaces/Inspectable.ts" +import type { Pipeable } from "./interfaces/Pipeable.ts" +import * as TR from "./internal/trie.ts" +import type { Option } from "./Option.ts" +import type { Covariant, NoInfer } from "./types/Types.ts" const TypeId = TR.TrieTypeId @@ -28,7 +28,7 @@ const TypeId = TR.TrieTypeId * @example * ```ts * import * as Option from "effect/Option" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * * // Create a trie with string-to-number mappings * const trie: Trie.Trie = Trie.make( @@ -74,7 +74,7 @@ export interface Trie extends Iterable<[string, Value]>, Equal, Pi * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * import * as Equal from "effect/interfaces/Equal" * * const trie = Trie.empty() @@ -94,7 +94,7 @@ export const empty: () => Trie = TR.empty * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * import * as Equal from "effect/interfaces/Equal" * * const iterable: Array = [["call", 0], ["me", 1], ["mind", 2], ["mid", 3]] @@ -116,7 +116,7 @@ export const fromIterable: (entries: Iterable) => Trie< * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * import * as Equal from "effect/interfaces/Equal" * * const trie = Trie.make(["ca", 0], ["me", 1]) @@ -138,7 +138,7 @@ export const make: >( * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * * const trie1 = Trie.empty().pipe( * Trie.insert("call", 0) @@ -169,7 +169,7 @@ export const insert: { * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * * const trie = Trie.empty().pipe( * Trie.insert("cab", 0), @@ -194,7 +194,7 @@ export const keys: (self: Trie) => IterableIterator = TR.keys * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * * const trie = Trie.empty().pipe( * Trie.insert("call", 0), @@ -219,7 +219,7 @@ export const values: (self: Trie) => IterableIterator = TR.values * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * * const trie = Trie.empty().pipe( * Trie.insert("call", 0), @@ -243,7 +243,7 @@ export const entries: (self: Trie) => IterableIterator<[string, V]> = TR.e * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * * const trie = Trie.empty().pipe( * Trie.insert("call", 0), @@ -266,7 +266,7 @@ export const toEntries = (self: Trie): Array<[string, V]> => Array.from(en * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * * const trie = Trie.empty().pipe( * Trie.insert("she", 0), @@ -294,7 +294,7 @@ export const keysWithPrefix: { * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * * const trie = Trie.empty().pipe( * Trie.insert("she", 0), @@ -324,7 +324,7 @@ export const valuesWithPrefix: { * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * * const trie = Trie.empty().pipe( * Trie.insert("she", 0), @@ -352,7 +352,7 @@ export const entriesWithPrefix: { * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * * const trie = Trie.empty().pipe( * Trie.insert("shells", 0), @@ -380,7 +380,7 @@ export const toEntriesWithPrefix: { * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * * const trie = Trie.empty().pipe( * Trie.insert("shells", 0), @@ -408,7 +408,7 @@ export const longestPrefixOf: { * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * * const trie = Trie.empty().pipe( * Trie.insert("a", 0), @@ -430,7 +430,7 @@ export const size: (self: Trie) => number = TR.size * ```ts * import * as assert from "node:assert" * import * as Option from "effect/Option" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * * const trie = Trie.empty().pipe( * Trie.insert("call", 0), @@ -463,7 +463,7 @@ export const get: { * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * * const trie = Trie.empty().pipe( * Trie.insert("call", 0), @@ -496,7 +496,7 @@ export const has: { * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * * const trie = Trie.empty() * const trie1 = trie.pipe(Trie.insert("ma", 0)) @@ -519,7 +519,7 @@ export const isEmpty: (self: Trie) => boolean = TR.isEmpty * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * * const trie = Trie.empty().pipe( * Trie.insert("call", 0), @@ -544,7 +544,7 @@ export const getUnsafe: { * ```ts * import * as assert from "node:assert" * import * as Option from "effect/Option" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * * const trie = Trie.empty().pipe( * Trie.insert("call", 0), @@ -575,7 +575,7 @@ export const remove: { * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * * const trie = Trie.empty().pipe( * Trie.insert("shells", 0), @@ -617,7 +617,7 @@ export const reduce: { * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * import * as Equal from "effect/interfaces/Equal" * * const trie = Trie.empty().pipe( @@ -656,7 +656,7 @@ export const map: { * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * import * as Equal from "effect/interfaces/Equal" * * const trie = Trie.empty().pipe( @@ -695,7 +695,7 @@ export const filter: { * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * import * as Equal from "effect/interfaces/Equal" * import * as Option from "effect/Option" * @@ -735,7 +735,7 @@ export const filterMap: { * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * import * as Equal from "effect/interfaces/Equal" * import * as Option from "effect/Option" * @@ -764,7 +764,7 @@ export const compact: (self: Trie>) => Trie = TR.compact * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * * let value = 0 * @@ -794,7 +794,7 @@ export const forEach: { * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * import * as Equal from "effect/interfaces/Equal" * import * as Option from "effect/Option" * @@ -823,7 +823,7 @@ export const modify: { * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * import * as Equal from "effect/interfaces/Equal" * * const trie = Trie.empty().pipe( @@ -852,7 +852,7 @@ export const removeMany: { * @example * ```ts * import * as assert from "node:assert" - * import * as Trie from "effect/collections/Trie" + * import * as Trie from "effect/Trie" * import * as Equal from "effect/interfaces/Equal" * * const trie = Trie.empty().pipe( diff --git a/packages/effect/src/collections/index.ts b/packages/effect/src/collections/index.ts deleted file mode 100644 index c54a68320a..0000000000 --- a/packages/effect/src/collections/index.ts +++ /dev/null @@ -1,371 +0,0 @@ -/** - * @since 4.0.0 - */ - -/** - * This module provides utility functions for working with arrays in TypeScript. - * - * @since 2.0.0 - */ -export * as Array from "./Array.ts" - -/** - * The `Chunk` module provides an immutable, high-performance sequence data structure - * optimized for functional programming patterns. A `Chunk` is a persistent data structure - * that supports efficient append, prepend, and concatenation operations. - * - * ## What is a Chunk? - * - * A `Chunk` is an immutable sequence of elements of type `A` that provides: - * - **O(1) append and prepend operations** - * - **Efficient concatenation** through tree-like structure - * - **Memory efficiency** with structural sharing - * - **Rich API** with functional programming operations - * - **Type safety** with full TypeScript integration - * - * ## Key Features - * - * - **Immutable**: All operations return new chunks without modifying the original - * - **Efficient**: Optimized data structure with logarithmic complexity for most operations - * - **Functional**: Rich set of transformation and combination operators - * - **Lazy evaluation**: Many operations are deferred until needed - * - **Interoperable**: Easy conversion to/from arrays and other collections - * - * ## Performance Characteristics - * - * - **Append/Prepend**: O(1) amortized - * - **Random Access**: O(log n) - * - **Concatenation**: O(log min(m, n)) - * - **Iteration**: O(n) - * - **Memory**: Structural sharing minimizes allocation - * - * @example - * ```ts - * import { Chunk } from "effect/collections" - * - * // Creating chunks - * const chunk1 = Chunk.fromIterable([1, 2, 3]) - * const chunk2 = Chunk.fromIterable([4, 5, 6]) - * const empty = Chunk.empty() - * - * // Combining chunks - * const combined = Chunk.appendAll(chunk1, chunk2) - * console.log(Chunk.toReadonlyArray(combined)) // [1, 2, 3, 4, 5, 6] - * ``` - * - * @example - * ```ts - * import { Chunk } from "effect/collections" - * - * // Functional transformations - * const numbers = Chunk.range(1, 5) // [1, 2, 3, 4, 5] - * const doubled = Chunk.map(numbers, (n) => n * 2) // [2, 4, 6, 8, 10] - * const evens = Chunk.filter(doubled, (n) => n % 4 === 0) // [4, 8] - * const sum = Chunk.reduce(evens, 0, (acc, n) => acc + n) // 12 - * ``` - * - * @example - * ```ts - * import { Chunk } from "effect/collections" -import { Effect } from "effect" - * - * // Working with Effects - * const processChunk = (chunk: Chunk.Chunk) => - * Effect.gen(function* () { - * const mapped = Chunk.map(chunk, (n) => n * 2) - * const filtered = Chunk.filter(mapped, (n) => n > 5) - * return Chunk.toReadonlyArray(filtered) - * }) - * ``` - * - * @since 2.0.0 - */ -export * as Chunk from "./Chunk.ts" - -/** - * @since 4.0.0 - */ -export * as Graph from "./Graph.ts" - -/** - * @since 2.0.0 - */ -export * as HashMap from "./HashMap.ts" - -/** - * @since 4.0.0 - */ -export * as HashRing from "./HashRing.ts" - -/** - * @since 2.0.0 - */ -export * as HashSet from "./HashSet.ts" - -/** - * This module provides utility functions for working with Iterables in TypeScript. - * - * Iterables are objects that implement the iterator protocol, allowing them to be - * consumed with `for...of` loops, spread syntax, and other iteration constructs. - * This module provides a comprehensive set of functions for creating, transforming, - * and working with iterables in a functional programming style. - * - * Unlike arrays, iterables can be lazy and potentially infinite, making them suitable - * for stream processing and memory-efficient data manipulation. All functions in this - * module preserve the lazy nature of iterables where possible. - * - * @example - * ```ts - * import { Iterable } from "effect/collections" - * - * // Create iterables - * const numbers = Iterable.range(1, 5) - * const doubled = Iterable.map(numbers, x => x * 2) - * const filtered = Iterable.filter(doubled, x => x > 5) - * - * console.log(Array.from(filtered)) // [6, 8, 10] - * - * // Infinite iterables - * const fibonacci = Iterable.unfold([0, 1], ([a, b]) => [a, [b, a + b]]) - * const first10 = Iterable.take(fibonacci, 10) - * console.log(Array.from(first10)) // [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] - * ``` - * - * @since 2.0.0 - */ -export * as Iterable from "./Iterable.ts" - -/** - * MutableHashMap is a high-performance, mutable hash map implementation designed for efficient key-value storage - * with support for both structural and referential equality. It provides O(1) average-case performance for - * basic operations and integrates seamlessly with Effect's Equal and Hash interfaces. - * - * The implementation uses a hybrid approach: - * - Referential keys (without Equal implementation) are stored in a native Map - * - Structural keys (with Equal implementation) are stored in hash buckets with collision handling - * - * Key Features: - * - Mutable operations for performance-critical scenarios - * - Supports both structural and referential equality - * - Efficient collision handling through bucketing - * - Iterable interface for easy traversal - * - Memory-efficient storage with automatic bucket management - * - * Performance Characteristics: - * - Get/Set/Has: O(1) average, O(n) worst case (hash collisions) - * - Remove: O(1) average, O(n) worst case - * - Clear: O(1) - * - Size: O(1) - * - Iteration: O(n) - * - * @since 2.0.0 - * @category data-structures - */ -export * as MutableHashMap from "./MutableHashMap.ts" - -/** - * @fileoverview - * MutableHashSet is a high-performance, mutable set implementation that provides efficient storage - * and retrieval of unique values. Built on top of MutableHashMap, it inherits the same performance - * characteristics and support for both structural and referential equality. - * - * The implementation uses a MutableHashMap internally where each value is stored as a key with a - * boolean flag, providing O(1) average-case performance for all operations. - * - * Key Features: - * - Mutable operations for performance-critical scenarios - * - Supports both structural and referential equality - * - Efficient duplicate detection and removal - * - Iterable interface for easy traversal - * - Memory-efficient storage with automatic deduplication - * - Seamless integration with Effect's Equal and Hash interfaces - * - * Performance Characteristics: - * - Add/Has/Remove: O(1) average, O(n) worst case (hash collisions) - * - Clear: O(1) - * - Size: O(1) - * - Iteration: O(n) - * - * @since 2.0.0 - * @category data-structures - */ -export * as MutableHashSet from "./MutableHashSet.ts" - -/** - * @fileoverview - * MutableList is an efficient, mutable linked list implementation optimized for high-throughput - * scenarios like logging, queuing, and streaming. It uses a bucket-based architecture where - * elements are stored in arrays (buckets) linked together, providing optimal performance for - * both append and prepend operations. - * - * The implementation uses a sophisticated bucket system: - * - Each bucket contains an array of elements with an offset pointer - * - Buckets can be marked as mutable or immutable for optimization - * - Elements are taken from the head and added to the tail - * - Memory is efficiently managed through bucket reuse and cleanup - * - * Key Features: - * - Highly optimized for high-frequency append/prepend operations - * - Memory efficient with automatic cleanup of consumed elements - * - Support for bulk operations (appendAll, prependAll, takeN) - * - Filtering and removal operations - * - Zero-copy optimizations for certain scenarios - * - * Performance Characteristics: - * - Append/Prepend: O(1) amortized - * - Take/TakeN: O(1) per element taken - * - Length: O(1) - * - Clear: O(1) - * - Filter: O(n) - * - * Ideal Use Cases: - * - High-throughput logging systems - * - Producer-consumer queues - * - Streaming data buffers - * - Real-time data processing pipelines - * - * @since 4.0.0 - * @category data-structures - */ -export * as MutableList from "./MutableList.ts" - -/** - * @since 2.0.0 - * - * The `NonEmptyIterable` module provides types and utilities for working with iterables - * that are guaranteed to contain at least one element. This provides compile-time - * safety when working with collections that must not be empty. - * - * ## Key Features - * - * - **Type Safety**: Compile-time guarantee that the iterable contains at least one element - * - **Iterator Protocol**: Fully compatible with JavaScript's built-in iteration protocol - * - **Functional Operations**: Safe operations that preserve the non-empty property - * - **Lightweight**: Minimal overhead with maximum type safety - * - * ## Why NonEmptyIterable? - * - * Many operations require non-empty collections to be meaningful: - * - Finding the maximum or minimum value - * - Getting the first or last element - * - Reducing without an initial value - * - Operations that would otherwise need runtime checks - * - * ## Basic Usage - * - * ```ts - * import * as NonEmptyIterable from "effect/collections/NonEmptyIterable" - * - * // NonEmptyIterable is a type that represents any iterable with at least one element - * function processNonEmpty(data: NonEmptyIterable.NonEmptyIterable): A { - * // Safe to get the first element - guaranteed to exist - * const [first] = NonEmptyIterable.unprepend(data) - * return first - * } - * - * // Using Array.make to create non-empty arrays - * const numbers = Array.make(1, 2, 3, 4, 5) as unknown as NonEmptyIterable.NonEmptyIterable - * const firstNumber = processNonEmpty(numbers) // number - * - * // Regular arrays can be asserted as NonEmptyIterable when known to be non-empty - * const values = [1, 2, 3] as unknown as NonEmptyIterable.NonEmptyIterable - * const firstValue = processNonEmpty(values) // number - * - * // Custom iterables that are guaranteed non-empty - * function* generateNumbers(): NonEmptyIterable.NonEmptyIterable { - * yield 1 - * yield 2 - * yield 3 - * } - * - * const firstGenerated = processNonEmpty(generateNumbers()) // number - * ``` - * - * ## Working with Different Iterable Types - * - * ```ts - * import { pipe } from "effect" - * import * as NonEmptyIterable from "effect/collections/NonEmptyIterable" - * import { Array } from "effect/collections" - * import * as Chunk from "effect/collections/Chunk" - * - * // Creating non-empty arrays - * const nonEmptyArray = Array.make(1, 2, 3) as unknown as NonEmptyIterable.NonEmptyIterable - * - * // Working with strings (assert as NonEmptyIterable when known to be non-empty) - * const nonEmptyString = "hello" as unknown as NonEmptyIterable.NonEmptyIterable - * const [firstChar] = NonEmptyIterable.unprepend(nonEmptyString) - * console.log(firstChar) // "h" - * - * // Working with Maps (assert when known to be non-empty) - * const nonEmptyMap = new Map([ - * ["key1", "value1"], - * ["key2", "value2"] - * ]) as unknown as NonEmptyIterable.NonEmptyIterable<[string, string]> - * const [firstEntry] = NonEmptyIterable.unprepend(nonEmptyMap) - * console.log(firstEntry) // ["key1", "value1"] - * - * // Custom generator functions - * function* fibonacci(): NonEmptyIterable.NonEmptyIterable { - * let a = 1, b = 1 - * yield a - * while (true) { - * yield b - * const next = a + b - * a = b - * b = next - * } - * } - * - * const [firstFib, restFib] = NonEmptyIterable.unprepend(fibonacci() as unknown as NonEmptyIterable.NonEmptyIterable) - * console.log(firstFib) // 1 - * ``` - * - * ## Integration with Effect Arrays - * - * ```ts - * import { pipe } from "effect" - * import * as NonEmptyIterable from "effect/collections/NonEmptyIterable" - * import { Array } from "effect/collections" - * import * as Chunk from "effect/collections/Chunk" - * - * // Many Array functions work with NonEmptyIterable - * declare const nonEmptyData: NonEmptyIterable.NonEmptyIterable - * - * const processData = pipe( - * nonEmptyData, - * Array.fromIterable, - * Array.map(x => x * 2), - * Array.filter(x => x > 5), - * // Result is a regular array since filtering might make it empty - * ) - * - * // Safe operations that preserve non-emptiness - * const doubledData = pipe( - * nonEmptyData, - * Array.fromIterable, - * Array.map(x => x * 2) - * // This would still be non-empty if the source was non-empty - * ) - * ``` - */ -export * as NonEmptyIterable from "./NonEmptyIterable.ts" - -/** - * A `Trie` is used for locating specific `string` keys from within a set. - * - * It works similar to `HashMap`, but with keys required to be `string`. - * This constraint unlocks some performance optimizations and new methods to get string prefixes (e.g. `keysWithPrefix`, `longestPrefixOf`). - * - * Prefix search is also the main feature that makes a `Trie` more suited than `HashMap` for certain usecases. - * - * A `Trie` is often used to store a dictionary (list of words) that can be searched - * in a manner that allows for efficient generation of completion lists - * (e.g. predict the rest of a word a user is typing). - * - * A `Trie` has O(n) lookup time where `n` is the size of the key, - * or even less than `n` on search misses. - * - * @since 2.0.0 - */ -export * as Trie from "./Trie.ts" diff --git a/packages/effect/src/collections/index.ts.tpl b/packages/effect/src/collections/index.ts.tpl deleted file mode 100644 index c2aac82f76..0000000000 --- a/packages/effect/src/collections/index.ts.tpl +++ /dev/null @@ -1,3 +0,0 @@ -/** - * @since 4.0.0 - */ diff --git a/packages/effect/src/index.ts b/packages/effect/src/index.ts index f0980b48d3..ee6fea5566 100644 --- a/packages/effect/src/index.ts +++ b/packages/effect/src/index.ts @@ -29,6 +29,13 @@ export { pipe } from "./Function.ts" +/** + * This module provides utility functions for working with arrays in TypeScript. + * + * @since 2.0.0 + */ +export * as Array from "./Array.ts" + /** * This module provides utility functions and type class instances for working with the `BigDecimal` type in TypeScript. * It includes functions for basic arithmetic operations, as well as type class instances for `Equivalence` and `Order`. @@ -188,6 +195,79 @@ export * as Channel from "./Channel.ts" */ export * as ChannelSchema from "./ChannelSchema.ts" +/** + * The `Chunk` module provides an immutable, high-performance sequence data structure + * optimized for functional programming patterns. A `Chunk` is a persistent data structure + * that supports efficient append, prepend, and concatenation operations. + * + * ## What is a Chunk? + * + * A `Chunk` is an immutable sequence of elements of type `A` that provides: + * - **O(1) append and prepend operations** + * - **Efficient concatenation** through tree-like structure + * - **Memory efficiency** with structural sharing + * - **Rich API** with functional programming operations + * - **Type safety** with full TypeScript integration + * + * ## Key Features + * + * - **Immutable**: All operations return new chunks without modifying the original + * - **Efficient**: Optimized data structure with logarithmic complexity for most operations + * - **Functional**: Rich set of transformation and combination operators + * - **Lazy evaluation**: Many operations are deferred until needed + * - **Interoperable**: Easy conversion to/from arrays and other collections + * + * ## Performance Characteristics + * + * - **Append/Prepend**: O(1) amortized + * - **Random Access**: O(log n) + * - **Concatenation**: O(log min(m, n)) + * - **Iteration**: O(n) + * - **Memory**: Structural sharing minimizes allocation + * + * @example + * ```ts + * import { Chunk } from "effect" + * + * // Creating chunks + * const chunk1 = Chunk.fromIterable([1, 2, 3]) + * const chunk2 = Chunk.fromIterable([4, 5, 6]) + * const empty = Chunk.empty() + * + * // Combining chunks + * const combined = Chunk.appendAll(chunk1, chunk2) + * console.log(Chunk.toReadonlyArray(combined)) // [1, 2, 3, 4, 5, 6] + * ``` + * + * @example + * ```ts + * import { Chunk } from "effect" + * + * // Functional transformations + * const numbers = Chunk.range(1, 5) // [1, 2, 3, 4, 5] + * const doubled = Chunk.map(numbers, (n) => n * 2) // [2, 4, 6, 8, 10] + * const evens = Chunk.filter(doubled, (n) => n % 4 === 0) // [4, 8] + * const sum = Chunk.reduce(evens, 0, (acc, n) => acc + n) // 12 + * ``` + * + * @example + * ```ts + * import { Chunk } from "effect" +import { Effect } from "effect" + * + * // Working with Effects + * const processChunk = (chunk: Chunk.Chunk) => + * Effect.gen(function* () { + * const mapped = Chunk.map(chunk, (n) => n * 2) + * const filtered = Chunk.filter(mapped, (n) => n > 5) + * return Chunk.toReadonlyArray(filtered) + * }) + * ``` + * + * @since 2.0.0 + */ +export * as Chunk from "./Chunk.ts" + /** * The `Clock` module provides functionality for time-based operations in Effect applications. * It offers precise time measurements, scheduling capabilities, and controlled time management @@ -540,7 +620,7 @@ export * as Effect from "./Effect.ts" * @example * ```ts * import { Equivalence } from "effect" - * import { Array } from "effect/collections" + * import { Array } from "effect" * * // Case-insensitive string equivalence * const caseInsensitive = Equivalence.make((a, b) => @@ -694,6 +774,59 @@ export * as Formatter from "./Formatter.ts" */ export * as Function from "./Function.ts" +/** + * @since 4.0.0 + */ +export * as Graph from "./Graph.ts" + +/** + * @since 2.0.0 + */ +export * as HashMap from "./HashMap.ts" + +/** + * @since 4.0.0 + */ +export * as HashRing from "./HashRing.ts" + +/** + * @since 2.0.0 + */ +export * as HashSet from "./HashSet.ts" + +/** + * This module provides utility functions for working with Iterables in TypeScript. + * + * Iterables are objects that implement the iterator protocol, allowing them to be + * consumed with `for...of` loops, spread syntax, and other iteration constructs. + * This module provides a comprehensive set of functions for creating, transforming, + * and working with iterables in a functional programming style. + * + * Unlike arrays, iterables can be lazy and potentially infinite, making them suitable + * for stream processing and memory-efficient data manipulation. All functions in this + * module preserve the lazy nature of iterables where possible. + * + * @example + * ```ts + * import { Iterable } from "effect" + * + * // Create iterables + * const numbers = Iterable.range(1, 5) + * const doubled = Iterable.map(numbers, x => x * 2) + * const filtered = Iterable.filter(doubled, x => x > 5) + * + * console.log(Array.from(filtered)) // [6, 8, 10] + * + * // Infinite iterables + * const fibonacci = Iterable.unfold([0, 1], ([a, b]) => [a, [b, a + b]]) + * const first10 = Iterable.take(fibonacci, 10) + * console.log(Array.from(first10)) // [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] + * ``` + * + * @since 2.0.0 + */ +export * as Iterable from "./Iterable.ts" + /** * A `Layer` describes how to build one or more services in your * application. Services can be injected into effects via @@ -1100,6 +1233,100 @@ export * as Match from "./Match.ts" */ export * as Metric from "./Metric.ts" +/** + * MutableHashMap is a high-performance, mutable hash map implementation designed for efficient key-value storage + * with support for both structural and referential equality. It provides O(1) average-case performance for + * basic operations and integrates seamlessly with Effect's Equal and Hash interfaces. + * + * The implementation uses a hybrid approach: + * - Referential keys (without Equal implementation) are stored in a native Map + * - Structural keys (with Equal implementation) are stored in hash buckets with collision handling + * + * Key Features: + * - Mutable operations for performance-critical scenarios + * - Supports both structural and referential equality + * - Efficient collision handling through bucketing + * - Iterable interface for easy traversal + * - Memory-efficient storage with automatic bucket management + * + * Performance Characteristics: + * - Get/Set/Has: O(1) average, O(n) worst case (hash collisions) + * - Remove: O(1) average, O(n) worst case + * - Clear: O(1) + * - Size: O(1) + * - Iteration: O(n) + * + * @since 2.0.0 + * @category data-structures + */ +export * as MutableHashMap from "./MutableHashMap.ts" + +/** + * @fileoverview + * MutableHashSet is a high-performance, mutable set implementation that provides efficient storage + * and retrieval of unique values. Built on top of MutableHashMap, it inherits the same performance + * characteristics and support for both structural and referential equality. + * + * The implementation uses a MutableHashMap internally where each value is stored as a key with a + * boolean flag, providing O(1) average-case performance for all operations. + * + * Key Features: + * - Mutable operations for performance-critical scenarios + * - Supports both structural and referential equality + * - Efficient duplicate detection and removal + * - Iterable interface for easy traversal + * - Memory-efficient storage with automatic deduplication + * - Seamless integration with Effect's Equal and Hash interfaces + * + * Performance Characteristics: + * - Add/Has/Remove: O(1) average, O(n) worst case (hash collisions) + * - Clear: O(1) + * - Size: O(1) + * - Iteration: O(n) + * + * @since 2.0.0 + * @category data-structures + */ +export * as MutableHashSet from "./MutableHashSet.ts" + +/** + * @fileoverview + * MutableList is an efficient, mutable linked list implementation optimized for high-throughput + * scenarios like logging, queuing, and streaming. It uses a bucket-based architecture where + * elements are stored in arrays (buckets) linked together, providing optimal performance for + * both append and prepend operations. + * + * The implementation uses a sophisticated bucket system: + * - Each bucket contains an array of elements with an offset pointer + * - Buckets can be marked as mutable or immutable for optimization + * - Elements are taken from the head and added to the tail + * - Memory is efficiently managed through bucket reuse and cleanup + * + * Key Features: + * - Highly optimized for high-frequency append/prepend operations + * - Memory efficient with automatic cleanup of consumed elements + * - Support for bulk operations (appendAll, prependAll, takeN) + * - Filtering and removal operations + * - Zero-copy optimizations for certain scenarios + * + * Performance Characteristics: + * - Append/Prepend: O(1) amortized + * - Take/TakeN: O(1) per element taken + * - Length: O(1) + * - Clear: O(1) + * - Filter: O(n) + * + * Ideal Use Cases: + * - High-throughput logging systems + * - Producer-consumer queues + * - Streaming data buffers + * - Real-time data processing pipelines + * + * @since 4.0.0 + * @category data-structures + */ +export * as MutableList from "./MutableList.ts" + /** * @fileoverview * MutableRef provides a mutable reference container that allows safe mutation of values @@ -1134,6 +1361,128 @@ export * as Metric from "./Metric.ts" */ export * as MutableRef from "./MutableRef.ts" +/** + * @since 2.0.0 + * + * The `NonEmptyIterable` module provides types and utilities for working with iterables + * that are guaranteed to contain at least one element. This provides compile-time + * safety when working with collections that must not be empty. + * + * ## Key Features + * + * - **Type Safety**: Compile-time guarantee that the iterable contains at least one element + * - **Iterator Protocol**: Fully compatible with JavaScript's built-in iteration protocol + * - **Functional Operations**: Safe operations that preserve the non-empty property + * - **Lightweight**: Minimal overhead with maximum type safety + * + * ## Why NonEmptyIterable? + * + * Many operations require non-empty collections to be meaningful: + * - Finding the maximum or minimum value + * - Getting the first or last element + * - Reducing without an initial value + * - Operations that would otherwise need runtime checks + * + * ## Basic Usage + * + * ```ts + * import * as NonEmptyIterable from "effect/NonEmptyIterable" + * + * // NonEmptyIterable is a type that represents any iterable with at least one element + * function processNonEmpty(data: NonEmptyIterable.NonEmptyIterable): A { + * // Safe to get the first element - guaranteed to exist + * const [first] = NonEmptyIterable.unprepend(data) + * return first + * } + * + * // Using Array.make to create non-empty arrays + * const numbers = Array.make(1, 2, 3, 4, 5) as unknown as NonEmptyIterable.NonEmptyIterable + * const firstNumber = processNonEmpty(numbers) // number + * + * // Regular arrays can be asserted as NonEmptyIterable when known to be non-empty + * const values = [1, 2, 3] as unknown as NonEmptyIterable.NonEmptyIterable + * const firstValue = processNonEmpty(values) // number + * + * // Custom iterables that are guaranteed non-empty + * function* generateNumbers(): NonEmptyIterable.NonEmptyIterable { + * yield 1 + * yield 2 + * yield 3 + * } + * + * const firstGenerated = processNonEmpty(generateNumbers()) // number + * ``` + * + * ## Working with Different Iterable Types + * + * ```ts + * import { pipe } from "effect" + * import * as NonEmptyIterable from "effect/NonEmptyIterable" + * import { Array } from "effect" + * import * as Chunk from "effect/Chunk" + * + * // Creating non-empty arrays + * const nonEmptyArray = Array.make(1, 2, 3) as unknown as NonEmptyIterable.NonEmptyIterable + * + * // Working with strings (assert as NonEmptyIterable when known to be non-empty) + * const nonEmptyString = "hello" as unknown as NonEmptyIterable.NonEmptyIterable + * const [firstChar] = NonEmptyIterable.unprepend(nonEmptyString) + * console.log(firstChar) // "h" + * + * // Working with Maps (assert when known to be non-empty) + * const nonEmptyMap = new Map([ + * ["key1", "value1"], + * ["key2", "value2"] + * ]) as unknown as NonEmptyIterable.NonEmptyIterable<[string, string]> + * const [firstEntry] = NonEmptyIterable.unprepend(nonEmptyMap) + * console.log(firstEntry) // ["key1", "value1"] + * + * // Custom generator functions + * function* fibonacci(): NonEmptyIterable.NonEmptyIterable { + * let a = 1, b = 1 + * yield a + * while (true) { + * yield b + * const next = a + b + * a = b + * b = next + * } + * } + * + * const [firstFib, restFib] = NonEmptyIterable.unprepend(fibonacci() as unknown as NonEmptyIterable.NonEmptyIterable) + * console.log(firstFib) // 1 + * ``` + * + * ## Integration with Effect Arrays + * + * ```ts + * import { pipe } from "effect" + * import * as NonEmptyIterable from "effect/NonEmptyIterable" + * import { Array } from "effect" + * import * as Chunk from "effect/Chunk" + * + * // Many Array functions work with NonEmptyIterable + * declare const nonEmptyData: NonEmptyIterable.NonEmptyIterable + * + * const processData = pipe( + * nonEmptyData, + * Array.fromIterable, + * Array.map(x => x * 2), + * Array.filter(x => x > 5), + * // Result is a regular array since filtering might make it empty + * ) + * + * // Safe operations that preserve non-emptiness + * const doubledData = pipe( + * nonEmptyData, + * Array.fromIterable, + * Array.map(x => x * 2) + * // This would still be non-empty if the source was non-empty + * ) + * ``` + */ +export * as NonEmptyIterable from "./NonEmptyIterable.ts" + /** * This module provides small, allocation-free utilities for working with values of type * `A | null`, where `null` means "no value". @@ -1625,6 +1974,25 @@ export * as Take from "./Take.ts" */ export * as Tracer from "./Tracer.ts" +/** + * A `Trie` is used for locating specific `string` keys from within a set. + * + * It works similar to `HashMap`, but with keys required to be `string`. + * This constraint unlocks some performance optimizations and new methods to get string prefixes (e.g. `keysWithPrefix`, `longestPrefixOf`). + * + * Prefix search is also the main feature that makes a `Trie` more suited than `HashMap` for certain usecases. + * + * A `Trie` is often used to store a dictionary (list of words) that can be searched + * in a manner that allows for efficient generation of completion lists + * (e.g. predict the rest of a word a user is typing). + * + * A `Trie` has O(n) lookup time where `n` is the size of the key, + * or even less than `n` on search misses. + * + * @since 2.0.0 + */ +export * as Trie from "./Trie.ts" + /** * This module provides utility functions for working with tuples in TypeScript. * diff --git a/packages/effect/src/interfaces/Equal.ts b/packages/effect/src/interfaces/Equal.ts index 84f4ed3f13..ec6a49501b 100644 --- a/packages/effect/src/interfaces/Equal.ts +++ b/packages/effect/src/interfaces/Equal.ts @@ -346,7 +346,7 @@ export const isEqual = (u: unknown): u is Equal => hasProperty(u, symbol) * @example * ```ts * import { Equal } from "effect/interfaces" - * import { Array } from "effect/collections" + * import { Array } from "effect" * * const eq = Equal.equivalence() * const result = Array.dedupeWith([1, 2, 2, 3, 1], eq) diff --git a/packages/effect/src/internal/arbitrary.ts b/packages/effect/src/internal/arbitrary.ts index 45f54d4b19..e1240b2930 100644 --- a/packages/effect/src/internal/arbitrary.ts +++ b/packages/effect/src/internal/arbitrary.ts @@ -1,5 +1,5 @@ +import * as Array from "../Array.ts" import * as Boolean from "../Boolean.ts" -import * as Array from "../collections/Array.ts" import type * as Combiner from "../Combiner.ts" import { memoize } from "../Function.ts" import * as Number from "../Number.ts" diff --git a/packages/effect/src/internal/array.ts b/packages/effect/src/internal/array.ts index 48823d6513..9f5100e336 100644 --- a/packages/effect/src/internal/array.ts +++ b/packages/effect/src/internal/array.ts @@ -2,7 +2,7 @@ * @since 2.0.0 */ -import type { NonEmptyArray } from "../collections/Array.ts" +import type { NonEmptyArray } from "../Array.ts" /** @internal */ export const isArrayNonEmpty = (self: ReadonlyArray): self is NonEmptyArray => self.length > 0 diff --git a/packages/effect/src/internal/effect.ts b/packages/effect/src/internal/effect.ts index abf0db07db..bfea48a1b6 100644 --- a/packages/effect/src/internal/effect.ts +++ b/packages/effect/src/internal/effect.ts @@ -1,6 +1,6 @@ +import * as Arr from "../Array.ts" import type * as Cause from "../Cause.ts" import type * as Clock from "../Clock.ts" -import * as Arr from "../collections/Array.ts" import type * as Console from "../Console.ts" import * as Duration from "../Duration.ts" import type * as Effect from "../Effect.ts" diff --git a/packages/effect/src/internal/request.ts b/packages/effect/src/internal/request.ts index f3d02da746..d969c2bcca 100644 --- a/packages/effect/src/internal/request.ts +++ b/packages/effect/src/internal/request.ts @@ -1,4 +1,4 @@ -import type { NonEmptyArray } from "../collections/Array.ts" +import type { NonEmptyArray } from "../Array.ts" import type { Effect } from "../Effect.ts" import type { Exit } from "../Exit.ts" import type { Fiber } from "../Fiber.ts" diff --git a/packages/effect/src/internal/trie.ts b/packages/effect/src/internal/trie.ts index de81e172a0..00af6a452a 100644 --- a/packages/effect/src/internal/trie.ts +++ b/packages/effect/src/internal/trie.ts @@ -1,4 +1,3 @@ -import type * as TR from "../collections/Trie.ts" import { format } from "../Formatter.ts" import { dual, identity, pipe } from "../Function.ts" import * as Equal from "../interfaces/Equal.ts" @@ -8,6 +7,7 @@ import { pipeArguments } from "../interfaces/Pipeable.ts" import * as Option from "../Option.ts" import type * as Ordering from "../Ordering.ts" import { hasProperty } from "../Predicate.ts" +import type * as TR from "../Trie.ts" import type { NoInfer } from "../types/Types.ts" /** @internal */ diff --git a/packages/effect/src/platform/FileSystem.ts b/packages/effect/src/platform/FileSystem.ts index 60da571614..805e143d93 100644 --- a/packages/effect/src/platform/FileSystem.ts +++ b/packages/effect/src/platform/FileSystem.ts @@ -37,8 +37,8 @@ * * @since 4.0.0 */ +import * as Arr from "../Array.ts" import * as Brand from "../Brand.ts" -import * as Arr from "../collections/Array.ts" import * as Effect from "../Effect.ts" import { pipe } from "../Function.ts" import * as Layer from "../Layer.ts" diff --git a/packages/effect/src/schema/AST.ts b/packages/effect/src/schema/AST.ts index 1f4368c193..8a58ed2715 100644 --- a/packages/effect/src/schema/AST.ts +++ b/packages/effect/src/schema/AST.ts @@ -2,8 +2,8 @@ * @since 4.0.0 */ +import * as Arr from "../Array.ts" import * as Cause from "../Cause.ts" -import * as Arr from "../collections/Array.ts" import type * as Combiner from "../Combiner.ts" import * as Effect from "../Effect.ts" import type * as Exit from "../Exit.ts" diff --git a/packages/effect/src/schema/FromJsonSchema.ts b/packages/effect/src/schema/FromJsonSchema.ts index 326c7c3c0c..21e87e1ffb 100644 --- a/packages/effect/src/schema/FromJsonSchema.ts +++ b/packages/effect/src/schema/FromJsonSchema.ts @@ -16,7 +16,7 @@ * * @since 4.0.0 */ -import * as Arr from "../collections/Array.ts" +import * as Arr from "../Array.ts" import * as Combiner from "../Combiner.ts" import { format, formatPropertyKey } from "../Formatter.ts" import { remainder } from "../Number.ts" diff --git a/packages/effect/src/schema/Parser.ts b/packages/effect/src/schema/Parser.ts index fe7b1004c4..ea13f03fc8 100644 --- a/packages/effect/src/schema/Parser.ts +++ b/packages/effect/src/schema/Parser.ts @@ -2,8 +2,8 @@ * @since 4.0.0 */ +import * as Arr from "../Array.ts" import * as Cause from "../Cause.ts" -import * as Arr from "../collections/Array.ts" import * as Effect from "../Effect.ts" import * as Exit from "../Exit.ts" import * as Filter from "../Filter.ts" diff --git a/packages/effect/src/schema/Schema.ts b/packages/effect/src/schema/Schema.ts index 9550c1b3a3..8db5d914bb 100644 --- a/packages/effect/src/schema/Schema.ts +++ b/packages/effect/src/schema/Schema.ts @@ -3,9 +3,9 @@ */ import type { StandardJSONSchemaV1, StandardSchemaV1 } from "@standard-schema/spec" +import * as Arr from "../Array.ts" import type * as Brand from "../Brand.ts" import * as Cause_ from "../Cause.ts" -import * as Arr from "../collections/Array.ts" import type * as Combiner from "../Combiner.ts" import * as Data from "../Data.ts" import * as DateTime from "../DateTime.ts" diff --git a/packages/effect/src/schema/Standard.ts b/packages/effect/src/schema/Standard.ts index caa7cdce41..daf5f92b2e 100644 --- a/packages/effect/src/schema/Standard.ts +++ b/packages/effect/src/schema/Standard.ts @@ -1,7 +1,7 @@ /** * @since 4.0.0 */ -import * as Arr from "../collections/Array.ts" +import * as Arr from "../Array.ts" import { format, formatPropertyKey } from "../Formatter.ts" import * as Option from "../Option.ts" import * as Predicate from "../Predicate.ts" diff --git a/packages/effect/src/stm/TxChunk.ts b/packages/effect/src/stm/TxChunk.ts index 5f07fbddbf..0361fef8be 100644 --- a/packages/effect/src/stm/TxChunk.ts +++ b/packages/effect/src/stm/TxChunk.ts @@ -9,7 +9,7 @@ * * @since 4.0.0 */ -import * as Chunk from "../collections/Chunk.ts" +import * as Chunk from "../Chunk.ts" import * as Effect from "../Effect.ts" import { format } from "../Formatter.ts" import { dual } from "../Function.ts" @@ -33,7 +33,7 @@ const TypeId = "~effect/transactions/TxChunk" * @example * ```ts * import { Effect } from "effect" - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import { TxChunk } from "effect/stm" * * const program = Effect.gen(function*() { @@ -99,7 +99,7 @@ const TxChunkProto = { * @example * ```ts * import { Effect } from "effect" - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import { TxChunk } from "effect/stm" * * const program = Effect.gen(function*() { @@ -159,7 +159,7 @@ export const empty = (): Effect.Effect> => * @example * ```ts * import { Effect } from "effect" - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import { TxChunk } from "effect/stm" * * const program = Effect.gen(function*() { @@ -194,7 +194,7 @@ export const fromIterable = (iterable: Iterable): Effect.Effect * * @example * ```ts - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import { TxChunk, TxRef } from "effect/stm" * * // Create a TxChunk from an existing TxRef (advanced usage) @@ -223,7 +223,7 @@ export const makeUnsafe = (ref: TxRef.TxRef>): TxChunk => { * @example * ```ts * import { Effect } from "effect" - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import { TxChunk } from "effect/stm" * * const program = Effect.gen(function*() { @@ -267,7 +267,7 @@ export const modify: { * @example * ```ts * import { Effect } from "effect" - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import { TxChunk } from "effect/stm" * * const program = Effect.gen(function*() { @@ -300,7 +300,7 @@ export const update: { * @example * ```ts * import { Effect } from "effect" - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import { TxChunk } from "effect/stm" * * const program = Effect.gen(function*() { @@ -330,7 +330,7 @@ export const get = (self: TxChunk): Effect.Effect> => TxRef * @example * ```ts * import { Effect } from "effect" - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import { TxChunk } from "effect/stm" * * const program = Effect.gen(function*() { @@ -362,7 +362,7 @@ export const set: { * @example * ```ts * import { Effect } from "effect" - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import { TxChunk } from "effect/stm" * * const program = Effect.gen(function*() { @@ -396,7 +396,7 @@ export const append: { * @example * ```ts * import { Effect } from "effect" - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import { TxChunk } from "effect/stm" * * const program = Effect.gen(function*() { @@ -512,7 +512,7 @@ export const isNonEmpty = (self: TxChunk): Effect.Effect => * @example * ```ts * import { Effect } from "effect" - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import { TxChunk } from "effect/stm" * * const program = Effect.gen(function*() { @@ -543,7 +543,7 @@ export const take: { * @example * ```ts * import { Effect } from "effect" - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import { TxChunk } from "effect/stm" * * const program = Effect.gen(function*() { @@ -574,7 +574,7 @@ export const drop: { * @example * ```ts * import { Effect } from "effect" - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import { TxChunk } from "effect/stm" * * const program = Effect.gen(function*() { @@ -610,7 +610,7 @@ export const slice: { * @example * ```ts * import { Effect } from "effect" - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import { TxChunk } from "effect/stm" * * const program = Effect.gen(function*() { @@ -645,7 +645,7 @@ export const map: { * @example * ```ts * import { Effect } from "effect" - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import { TxChunk } from "effect/stm" * * const program = Effect.gen(function*() { @@ -683,7 +683,7 @@ export const filter: { * @example * ```ts * import { Effect } from "effect" - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import { TxChunk } from "effect/stm" * * const program = Effect.gen(function*() { @@ -720,7 +720,7 @@ export const appendAll: { * @example * ```ts * import { Effect } from "effect" - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import { TxChunk } from "effect/stm" * * const program = Effect.gen(function*() { @@ -759,7 +759,7 @@ export const prependAll: { * @example * ```ts * import { Effect } from "effect" - * import { Chunk } from "effect/collections" + * import { Chunk } from "effect" * import { TxChunk } from "effect/stm" * * const program = Effect.gen(function*() { diff --git a/packages/effect/src/stm/TxHashMap.ts b/packages/effect/src/stm/TxHashMap.ts index f01a6426aa..e38835fb1f 100644 --- a/packages/effect/src/stm/TxHashMap.ts +++ b/packages/effect/src/stm/TxHashMap.ts @@ -2,10 +2,10 @@ * @since 2.0.0 */ -import * as HashMap from "../collections/HashMap.ts" import * as Effect from "../Effect.ts" import { format } from "../Formatter.ts" import { dual } from "../Function.ts" +import * as HashMap from "../HashMap.ts" import type { Inspectable } from "../interfaces/Inspectable.ts" import { NodeInspectSymbol, toJson } from "../interfaces/Inspectable.ts" import type { Pipeable } from "../interfaces/Pipeable.ts" @@ -908,7 +908,7 @@ export const entries = (self: TxHashMap): Effect.Effect(self: TxHashMap): Effect.Effect(values: Iterable): Effect.Effect * @example * ```ts * import { Effect } from "effect" - * import * as HashSet from "effect/collections/HashSet" + * import * as HashSet from "effect/HashSet" * import { TxHashSet } from "effect/stm" * * const program = Effect.gen(function*() { @@ -275,7 +275,7 @@ export const fromHashSet = (hashSet: HashSet.HashSet): Effect.Effect { class Service extends ServiceMap.Service()("Service", { diff --git a/packages/effect/test/FiberMap.test.ts b/packages/effect/test/FiberMap.test.ts index eef71ed02b..d3ae693968 100644 --- a/packages/effect/test/FiberMap.test.ts +++ b/packages/effect/test/FiberMap.test.ts @@ -1,7 +1,6 @@ import { assert, describe, it } from "@effect/vitest" import { assertFalse, assertTrue, strictEqual } from "@effect/vitest/utils" -import { Deferred, Effect, Exit, Fiber, FiberMap, pipe, Ref, Scope } from "effect" -import { Array } from "effect/collections" +import { Array, Deferred, Effect, Exit, Fiber, FiberMap, pipe, Ref, Scope } from "effect" import { TestClock } from "effect/testing" describe("FiberMap", () => { diff --git a/packages/effect/test/FiberSet.test.ts b/packages/effect/test/FiberSet.test.ts index 6363dd71a5..b463bace67 100644 --- a/packages/effect/test/FiberSet.test.ts +++ b/packages/effect/test/FiberSet.test.ts @@ -1,7 +1,6 @@ import { assert, describe, it } from "@effect/vitest" import { assertFalse, assertTrue, strictEqual } from "@effect/vitest/utils" -import { Deferred, Effect, Exit, Fiber, FiberSet, pipe, Ref, Scope } from "effect" -import { Array } from "effect/collections" +import { Array, Deferred, Effect, Exit, Fiber, FiberSet, pipe, Ref, Scope } from "effect" import { TestClock } from "effect/testing" describe("FiberSet", () => { diff --git a/packages/effect/test/collections/Graph.test.ts b/packages/effect/test/Graph.test.ts similarity index 99% rename from packages/effect/test/collections/Graph.test.ts rename to packages/effect/test/Graph.test.ts index c5c1b7adc6..c8f4104b0c 100644 --- a/packages/effect/test/collections/Graph.test.ts +++ b/packages/effect/test/Graph.test.ts @@ -6,8 +6,7 @@ import { deepStrictEqual, strictEqual } from "@effect/vitest/utils" -import { Option } from "effect" -import { Graph } from "effect/collections" +import { Graph, Option } from "effect" import { Equal, Hash } from "effect/interfaces" import { describe, expect, it } from "vitest" diff --git a/packages/effect/test/HashMap.test.ts b/packages/effect/test/HashMap.test.ts index 96a7b498fe..45ef8cb590 100644 --- a/packages/effect/test/HashMap.test.ts +++ b/packages/effect/test/HashMap.test.ts @@ -1,5 +1,4 @@ -import { Option } from "effect" -import { HashMap } from "effect/collections" +import { HashMap, Option } from "effect" import { Equal, Hash } from "effect/interfaces" import { describe, expect, it } from "vitest" diff --git a/packages/effect/test/HashSet.test.ts b/packages/effect/test/HashSet.test.ts index 328c86aa7a..fa81aec383 100644 --- a/packages/effect/test/HashSet.test.ts +++ b/packages/effect/test/HashSet.test.ts @@ -1,4 +1,4 @@ -import { HashSet } from "effect/collections" +import { HashSet } from "effect" import { Equal, Hash } from "effect/interfaces" import { describe, expect, it } from "vitest" diff --git a/packages/effect/test/collections/Iterable.test.ts b/packages/effect/test/Iterable.test.ts similarity index 99% rename from packages/effect/test/collections/Iterable.test.ts rename to packages/effect/test/Iterable.test.ts index 84adee3d54..449ee101d0 100644 --- a/packages/effect/test/collections/Iterable.test.ts +++ b/packages/effect/test/Iterable.test.ts @@ -1,7 +1,6 @@ import { describe, it } from "@effect/vitest" import { assertFalse, assertNone, assertSome, assertTrue, deepStrictEqual, strictEqual } from "@effect/vitest/utils" -import { Equivalence, Option } from "effect" -import { Iterable as Iter } from "effect/collections" +import { Equivalence, Iterable as Iter, Option } from "effect" import { pipe } from "effect/Function" import type { Predicate } from "effect/Predicate" diff --git a/packages/effect/test/collections/MutableHashMap.test.ts b/packages/effect/test/MutableHashMap.test.ts similarity index 98% rename from packages/effect/test/collections/MutableHashMap.test.ts rename to packages/effect/test/MutableHashMap.test.ts index 36591ffe87..f4b1b3d70f 100644 --- a/packages/effect/test/collections/MutableHashMap.test.ts +++ b/packages/effect/test/MutableHashMap.test.ts @@ -1,7 +1,6 @@ import { describe, it } from "@effect/vitest" import { assertFalse, assertNone, assertSome, assertTrue, deepStrictEqual, strictEqual } from "@effect/vitest/utils" -import { Option, pipe } from "effect" -import { MutableHashMap as HM } from "effect/collections" +import { MutableHashMap as HM, Option, pipe } from "effect" import { Equal, Hash } from "effect/interfaces" class Key implements Equal.Equal { diff --git a/packages/effect/test/collections/Pathfinding.test.ts b/packages/effect/test/Pathfinding.test.ts similarity index 99% rename from packages/effect/test/collections/Pathfinding.test.ts rename to packages/effect/test/Pathfinding.test.ts index a9c7b93de5..9429cb2874 100644 --- a/packages/effect/test/collections/Pathfinding.test.ts +++ b/packages/effect/test/Pathfinding.test.ts @@ -1,6 +1,5 @@ import { describe, it } from "@effect/vitest" -import { Data, Option } from "effect" -import { Graph } from "effect/collections" +import { Data, Graph, Option } from "effect" import type { Types } from "effect/types" import { AssertionError } from "node:assert" diff --git a/packages/effect/test/PubSub.test.ts b/packages/effect/test/PubSub.test.ts index 96f37ee191..2a0eefc6e4 100644 --- a/packages/effect/test/PubSub.test.ts +++ b/packages/effect/test/PubSub.test.ts @@ -1,6 +1,5 @@ import { assert, describe, it } from "@effect/vitest" -import { Effect, Fiber, PubSub } from "effect" -import { Array } from "effect/collections" +import { Array, Effect, Fiber, PubSub } from "effect" import { pipe } from "effect/Function" describe("PubSub", () => { diff --git a/packages/effect/test/Redacted.test.ts b/packages/effect/test/Redacted.test.ts index e5f233382f..47e29fb43e 100644 --- a/packages/effect/test/Redacted.test.ts +++ b/packages/effect/test/Redacted.test.ts @@ -1,7 +1,6 @@ import { describe, it } from "@effect/vitest" import { assertFalse, assertTrue, strictEqual, throws } from "@effect/vitest/utils" -import { Redacted } from "effect" -import { Chunk } from "effect/collections" +import { Chunk, Redacted } from "effect" import { Equal, Hash } from "effect/interfaces" describe("Redacted", () => { diff --git a/packages/effect/test/Result.test.ts b/packages/effect/test/Result.test.ts index a11506959f..7923b078e3 100644 --- a/packages/effect/test/Result.test.ts +++ b/packages/effect/test/Result.test.ts @@ -1,5 +1,4 @@ -import { Cause, Effect, Equivalence, flow, identity, Option, pipe, Result, String as Str } from "effect" -import { Chunk } from "effect/collections" +import { Cause, Chunk, Effect, Equivalence, flow, identity, Option, pipe, Result, String as Str } from "effect" import { Equal } from "effect/interfaces" import { inspect } from "node:util" import { describe, it } from "vitest" diff --git a/packages/effect/test/Schedule.test.ts b/packages/effect/test/Schedule.test.ts index ec949cd39c..8c0293040e 100644 --- a/packages/effect/test/Schedule.test.ts +++ b/packages/effect/test/Schedule.test.ts @@ -1,6 +1,5 @@ import { describe, expect, it } from "@effect/vitest" -import { Duration, Effect, Fiber, Pull, Schedule } from "effect" -import { Array } from "effect/collections" +import { Array, Duration, Effect, Fiber, Pull, Schedule } from "effect" import { constant, constUndefined } from "effect/Function" import { TestClock } from "effect/testing" diff --git a/packages/effect/test/Sink.test.ts b/packages/effect/test/Sink.test.ts index 0815e90459..1399749abb 100644 --- a/packages/effect/test/Sink.test.ts +++ b/packages/effect/test/Sink.test.ts @@ -1,7 +1,6 @@ import { describe, it } from "@effect/vitest" import { assertExitFailure, assertExitSuccess, deepStrictEqual, strictEqual } from "@effect/vitest/utils" -import { Cause, Effect, Ref, Sink, Stream } from "effect" -import { Array } from "effect/collections" +import { Array, Cause, Effect, Ref, Sink, Stream } from "effect" import { constTrue, pipe } from "effect/Function" describe("Sink", () => { diff --git a/packages/effect/test/Stream.test.ts b/packages/effect/test/Stream.test.ts index 7ba037e687..06e20bd835 100644 --- a/packages/effect/test/Stream.test.ts +++ b/packages/effect/test/Stream.test.ts @@ -2,6 +2,7 @@ import { assert, describe, it } from "@effect/vitest" import { assertExitFailure, assertSuccess, assertTrue, deepStrictEqual, strictEqual } from "@effect/vitest/utils" import { + Array, Cause, Clock, Deferred, @@ -17,8 +18,7 @@ import { Sink, Stream } from "effect" -import { Array } from "effect/collections" -import { isReadonlyArrayNonEmpty, type NonEmptyArray } from "effect/collections/Array" +import { isReadonlyArrayNonEmpty, type NonEmptyArray } from "effect/Array" import { constFalse, constTrue, constVoid, pipe } from "effect/Function" import { TestClock } from "effect/testing" import * as fc from "effect/testing/FastCheck" diff --git a/packages/effect/test/SubscriptionRef.test.ts b/packages/effect/test/SubscriptionRef.test.ts index 0dd494109e..e3174132a1 100644 --- a/packages/effect/test/SubscriptionRef.test.ts +++ b/packages/effect/test/SubscriptionRef.test.ts @@ -1,6 +1,5 @@ import { assert, describe, it } from "@effect/vitest" -import { Effect, Exit, Fiber, Number, Pull, Random, Stream, SubscriptionRef } from "effect" -import { Array } from "effect/collections" +import { Array, Effect, Exit, Fiber, Number, Pull, Random, Stream, SubscriptionRef } from "effect" describe("SubscriptionRef", () => { it.effect("multiple subscribers can receive changes", () => diff --git a/packages/effect/test/collections/Trie.test.ts b/packages/effect/test/Trie.test.ts similarity index 99% rename from packages/effect/test/collections/Trie.test.ts rename to packages/effect/test/Trie.test.ts index 69c920da75..27b21f6fe2 100644 --- a/packages/effect/test/collections/Trie.test.ts +++ b/packages/effect/test/Trie.test.ts @@ -1,9 +1,9 @@ import { describe, it } from "@effect/vitest" import { assertNone, assertSome, deepStrictEqual, strictEqual, throws } from "@effect/vitest/utils" -import * as Trie from "effect/collections/Trie" import { pipe } from "effect/Function" import * as Equal from "effect/interfaces/Equal" import * as Option from "effect/Option" +import * as Trie from "effect/Trie" describe("Trie", () => { it("toString", () => { diff --git a/packages/effect/test/TxChunk.test.ts b/packages/effect/test/TxChunk.test.ts index 063d5dad50..38fa382537 100644 --- a/packages/effect/test/TxChunk.test.ts +++ b/packages/effect/test/TxChunk.test.ts @@ -1,5 +1,4 @@ -import { Effect } from "effect" -import { Chunk } from "effect/collections" +import { Chunk, Effect } from "effect" import { TxChunk } from "effect/stm" import { describe, expect, it } from "vitest" diff --git a/packages/effect/test/TxHashMap.test.ts b/packages/effect/test/TxHashMap.test.ts index aa53468a34..7d8969b29c 100644 --- a/packages/effect/test/TxHashMap.test.ts +++ b/packages/effect/test/TxHashMap.test.ts @@ -1,6 +1,5 @@ import { assert, describe, it } from "@effect/vitest" -import { Option } from "effect" -import { HashMap } from "effect/collections" +import { HashMap, Option } from "effect" import * as Effect from "effect/Effect" import { Hash } from "effect/interfaces" import { TxHashMap } from "effect/stm" diff --git a/packages/effect/test/TxHashSet.test.ts b/packages/effect/test/TxHashSet.test.ts index 27679736a2..3e29847a26 100644 --- a/packages/effect/test/TxHashSet.test.ts +++ b/packages/effect/test/TxHashSet.test.ts @@ -1,5 +1,5 @@ import { assert, describe, it } from "@effect/vitest" -import { HashSet } from "effect/collections" +import { HashSet } from "effect" import * as Effect from "effect/Effect" import { Equal, Hash } from "effect/interfaces" import { TxHashSet } from "effect/stm" diff --git a/packages/effect/test/TxQueue.test.ts b/packages/effect/test/TxQueue.test.ts index 69a77e9b5b..28094ec43e 100644 --- a/packages/effect/test/TxQueue.test.ts +++ b/packages/effect/test/TxQueue.test.ts @@ -1,7 +1,6 @@ import { assert, describe, it } from "@effect/vitest" -import { Fiber, Option } from "effect" +import { Chunk, Fiber, Option } from "effect" import * as Cause from "effect/Cause" -import { Chunk } from "effect/collections" import * as Effect from "effect/Effect" import { TxQueue } from "effect/stm" diff --git a/packages/effect/test/batching/Request.test.ts b/packages/effect/test/batching/Request.test.ts index 6ce6d70fd7..bdb2fbdb7b 100644 --- a/packages/effect/test/batching/Request.test.ts +++ b/packages/effect/test/batching/Request.test.ts @@ -1,7 +1,6 @@ import { assert, describe, expect, it } from "@effect/vitest" -import { Data, Fiber, ServiceMap } from "effect" +import { Array, Data, Fiber, ServiceMap } from "effect" import * as Cause from "effect/Cause" -import { Array } from "effect/collections" import * as Effect from "effect/Effect" import * as Exit from "effect/Exit" import { flow, pipe } from "effect/Function" diff --git a/packages/effect/test/cluster/Sharding.test.ts b/packages/effect/test/cluster/Sharding.test.ts index 38ddbf4682..5c44a2d5db 100644 --- a/packages/effect/test/cluster/Sharding.test.ts +++ b/packages/effect/test/cluster/Sharding.test.ts @@ -1,6 +1,5 @@ import { assert, describe, expect, it } from "@effect/vitest" -import { Cause, Clock, Effect, Exit, Fiber, Layer, MutableRef, Option, Queue, Stream } from "effect" -import { Array } from "effect/collections" +import { Array, Cause, Clock, Effect, Exit, Fiber, Layer, MutableRef, Option, Queue, Stream } from "effect" import { TestClock } from "effect/testing" import { MessageStorage, diff --git a/packages/effect/test/unstable/cli/services/MockTerminal.ts b/packages/effect/test/unstable/cli/services/MockTerminal.ts index ec4507409f..a7b83e0fb3 100644 --- a/packages/effect/test/unstable/cli/services/MockTerminal.ts +++ b/packages/effect/test/unstable/cli/services/MockTerminal.ts @@ -1,4 +1,4 @@ -import * as Array from "effect/collections/Array" +import * as Array from "effect/Array" import * as Console from "effect/Console" import * as Effect from "effect/Effect" import * as Layer from "effect/Layer" diff --git a/packages/effect/test/unstable/cli/services/TestActions.ts b/packages/effect/test/unstable/cli/services/TestActions.ts index 95ff8fd4bd..e4223ee5de 100644 --- a/packages/effect/test/unstable/cli/services/TestActions.ts +++ b/packages/effect/test/unstable/cli/services/TestActions.ts @@ -1,5 +1,4 @@ -import { Effect, Layer, Ref, ServiceMap } from "effect" -import { Array as Arr } from "effect/collections" +import { Array as Arr, Effect, Layer, Ref, ServiceMap } from "effect" export interface TestAction { readonly command: string diff --git a/packages/effect/test/unstable/observability/OtlpMetrics.test.ts b/packages/effect/test/unstable/observability/OtlpMetrics.test.ts index b3a97b3938..adce74cfdc 100644 --- a/packages/effect/test/unstable/observability/OtlpMetrics.test.ts +++ b/packages/effect/test/unstable/observability/OtlpMetrics.test.ts @@ -1,6 +1,5 @@ import { assert, describe, it } from "@effect/vitest" -import { Effect, Layer, Metric, Predicate, Ref, ServiceMap } from "effect" -import { Array } from "effect/collections" +import { Array, Effect, Layer, Metric, Predicate, Ref, ServiceMap } from "effect" import { TestClock } from "effect/testing" import { HttpClient, type HttpClientError, HttpClientResponse } from "effect/unstable/http" import { OtlpMetrics } from "effect/unstable/observability" diff --git a/packages/effect/test/utils/chunkCoordination.ts b/packages/effect/test/utils/chunkCoordination.ts index cd7f9590c0..895fde37e9 100644 --- a/packages/effect/test/utils/chunkCoordination.ts +++ b/packages/effect/test/utils/chunkCoordination.ts @@ -1,4 +1,4 @@ -import type * as Arr from "effect/collections/Array" +import type * as Arr from "effect/Array" import * as Effect from "effect/Effect" import * as Queue from "effect/Queue" import * as Stream from "effect/Stream" diff --git a/packages/platform-bun/src/BunStream.ts b/packages/platform-bun/src/BunStream.ts index f8d9ef2b96..807b2b1e7c 100644 --- a/packages/platform-bun/src/BunStream.ts +++ b/packages/platform-bun/src/BunStream.ts @@ -1,8 +1,8 @@ /** * @since 1.0.0 */ +import * as Arr from "effect/Array" import * as Channel from "effect/Channel" -import * as Arr from "effect/collections/Array" import * as Effect from "effect/Effect" import type { LazyArg } from "effect/Function" import * as Pull from "effect/Pull" diff --git a/packages/platform-node-shared/src/NodeChildProcessSpawner.ts b/packages/platform-node-shared/src/NodeChildProcessSpawner.ts index a6758aec94..85924c32d6 100644 --- a/packages/platform-node-shared/src/NodeChildProcessSpawner.ts +++ b/packages/platform-node-shared/src/NodeChildProcessSpawner.ts @@ -3,7 +3,7 @@ * * @since 4.0.0 */ -import type * as Arr from "effect/collections/Array" +import type * as Arr from "effect/Array" import * as Deferred from "effect/Deferred" import * as Effect from "effect/Effect" import * as Exit from "effect/Exit" diff --git a/packages/platform-node-shared/src/NodeSink.ts b/packages/platform-node-shared/src/NodeSink.ts index dfd05b188b..1af05651ee 100644 --- a/packages/platform-node-shared/src/NodeSink.ts +++ b/packages/platform-node-shared/src/NodeSink.ts @@ -1,8 +1,8 @@ /** * @since 1.0.0 */ +import type { NonEmptyReadonlyArray } from "effect/Array" import * as Channel from "effect/Channel" -import type { NonEmptyReadonlyArray } from "effect/collections/Array" import * as Effect from "effect/Effect" import { identity, type LazyArg } from "effect/Function" import type { PlatformError } from "effect/platform/PlatformError" diff --git a/packages/platform-node-shared/src/NodeSocket.ts b/packages/platform-node-shared/src/NodeSocket.ts index b7b6f845b9..757897b6b8 100644 --- a/packages/platform-node-shared/src/NodeSocket.ts +++ b/packages/platform-node-shared/src/NodeSocket.ts @@ -1,8 +1,8 @@ /** * @since 1.0.0 */ +import type { Array } from "effect" import * as Channel from "effect/Channel" -import type { Array } from "effect/collections" import * as Deferred from "effect/Deferred" import type * as Duration from "effect/Duration" import * as Effect from "effect/Effect" diff --git a/packages/platform-node-shared/src/NodeStream.ts b/packages/platform-node-shared/src/NodeStream.ts index ad54d2f599..3a1d751624 100644 --- a/packages/platform-node-shared/src/NodeStream.ts +++ b/packages/platform-node-shared/src/NodeStream.ts @@ -1,9 +1,9 @@ /** * @since 1.0.0 */ +import * as Arr from "effect/Array" import * as Cause from "effect/Cause" import * as Channel from "effect/Channel" -import * as Arr from "effect/collections/Array" import * as Effect from "effect/Effect" import * as Exit from "effect/Exit" import * as Fiber from "effect/Fiber" diff --git a/packages/platform-node-shared/src/internal/process.ts b/packages/platform-node-shared/src/internal/process.ts index 95bbeff56b..8c9350b9c4 100644 --- a/packages/platform-node-shared/src/internal/process.ts +++ b/packages/platform-node-shared/src/internal/process.ts @@ -9,7 +9,7 @@ * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import * as Arr from "effect/collections/Array" +import * as Arr from "effect/Array" import type { TemplateExpression, TemplateExpressionItem } from "effect/unstable/process/ChildProcess" /** @internal */ diff --git a/packages/platform-node-shared/test/NodeFileSystem.test.ts b/packages/platform-node-shared/test/NodeFileSystem.test.ts index 88277e4c7a..83932732d5 100644 --- a/packages/platform-node-shared/test/NodeFileSystem.test.ts +++ b/packages/platform-node-shared/test/NodeFileSystem.test.ts @@ -1,7 +1,6 @@ import * as NodeFileSystem from "@effect/platform-node-shared/NodeFileSystem" import { assert, describe, expect, it } from "@effect/vitest" -import { Option } from "effect" -import { Array } from "effect/collections" +import { Array, Option } from "effect" import * as Effect from "effect/Effect" import * as Fs from "effect/platform/FileSystem" import * as Stream from "effect/Stream" diff --git a/packages/platform-node-shared/test/NodeStream.test.ts b/packages/platform-node-shared/test/NodeStream.test.ts index 9cfd7582a7..edd098bcb0 100644 --- a/packages/platform-node-shared/test/NodeStream.test.ts +++ b/packages/platform-node-shared/test/NodeStream.test.ts @@ -1,8 +1,8 @@ import * as NodeStream from "@effect/platform-node-shared/NodeStream" import { assert, describe, it } from "@effect/vitest" import { Effect } from "effect" +import * as Array from "effect/Array" import * as Channel from "effect/Channel" -import * as Array from "effect/collections/Array" import * as Console from "effect/Console" import * as Stream from "effect/Stream" import { Duplex, Readable, Transform } from "node:stream" diff --git a/packages/platform-node/test/HttpApi.test.ts b/packages/platform-node/test/HttpApi.test.ts index f5a32be752..3133c1d750 100644 --- a/packages/platform-node/test/HttpApi.test.ts +++ b/packages/platform-node/test/HttpApi.test.ts @@ -1,7 +1,6 @@ import { NodeHttpServer } from "@effect/platform-node" import { assert, describe, it } from "@effect/vitest" -import { DateTime, Effect, Filter, Layer, Redacted, Ref, ServiceMap, Stream, Struct } from "effect" -import { Array } from "effect/collections" +import { Array, DateTime, Effect, Filter, Layer, Redacted, Ref, ServiceMap, Stream, Struct } from "effect" import { FileSystem } from "effect/platform" import { Getter, Schema, Transformation } from "effect/schema" import { diff --git a/packages/sql/d1/test/Resolver.test.ts b/packages/sql/d1/test/Resolver.test.ts index 11ea603124..bff800c968 100644 --- a/packages/sql/d1/test/Resolver.test.ts +++ b/packages/sql/d1/test/Resolver.test.ts @@ -1,7 +1,6 @@ import { D1Client } from "@effect/sql-d1" import { assert, describe, it } from "@effect/vitest" -import { Cause, Effect } from "effect" -import { Iterable } from "effect/collections" +import { Cause, Effect, Iterable } from "effect" import * as Schema from "effect/schema/Schema" import { SqlError, SqlResolver } from "effect/unstable/sql" import { D1Miniflare } from "./utils.ts" diff --git a/packages/sql/libsql/test/Resolver.test.ts b/packages/sql/libsql/test/Resolver.test.ts index 93a37f5771..afa726142b 100644 --- a/packages/sql/libsql/test/Resolver.test.ts +++ b/packages/sql/libsql/test/Resolver.test.ts @@ -1,7 +1,6 @@ import { LibsqlClient } from "@effect/sql-libsql" import { assert, describe, layer } from "@effect/vitest" -import { Cause, Effect } from "effect" -import { Iterable } from "effect/collections" +import { Cause, Effect, Iterable } from "effect" import * as Schema from "effect/schema/Schema" import { SqlError, SqlResolver } from "effect/unstable/sql" import { LibsqlContainer } from "./util.ts" diff --git a/packages/sql/pg/src/PgClient.ts b/packages/sql/pg/src/PgClient.ts index b6f8342a5d..fbbe55a417 100644 --- a/packages/sql/pg/src/PgClient.ts +++ b/packages/sql/pg/src/PgClient.ts @@ -1,8 +1,8 @@ /** * @since 1.0.0 */ +import * as Arr from "effect/Array" import * as Channel from "effect/Channel" -import * as Arr from "effect/collections/Array" import * as Config from "effect/Config" import * as Duration from "effect/Duration" import * as Effect from "effect/Effect" diff --git a/packages/sql/sqlite-node/test/Resolver.test.ts b/packages/sql/sqlite-node/test/Resolver.test.ts index 8bd3981491..cdd69a19b4 100644 --- a/packages/sql/sqlite-node/test/Resolver.test.ts +++ b/packages/sql/sqlite-node/test/Resolver.test.ts @@ -1,8 +1,7 @@ import { NodeFileSystem } from "@effect/platform-node" import { SqliteClient } from "@effect/sql-sqlite-node" import { assert, describe, it } from "@effect/vitest" -import { Cause, Effect } from "effect" -import { Iterable } from "effect/collections" +import { Cause, Effect, Iterable } from "effect" import { FileSystem } from "effect/platform" import { Schema } from "effect/schema" import { Reactivity } from "effect/unstable/reactivity" diff --git a/scripts/codemod.mjs b/scripts/codemod.mjs index c14b24b5ea..8c08f93cf8 100644 --- a/scripts/codemod.mjs +++ b/scripts/codemod.mjs @@ -1,6 +1,6 @@ // @ts-check import * as Glob from "glob" -import Jscodeshift from "jscodeshift/src/Runner.js" +import * as Jscodeshift from "jscodeshift/src/Runner.js" import * as Path from "node:path" // Look up files in all workspace packages including those nested in diff --git a/scripts/eslint-examples.ts b/scripts/eslint-examples.ts index b4c2fae21e..fb9418b909 100644 --- a/scripts/eslint-examples.ts +++ b/scripts/eslint-examples.ts @@ -1,9 +1,6 @@ import { NodeRuntime, NodeServices } from "@effect/platform-node" -import { Cause, Effect } from "effect" -import { Array } from "effect/collections" -import { Filter } from "effect/data" +import { Array, Cause, Effect, Filter, Stream } from "effect" import { FileSystem, Path } from "effect/platform" -import { Stream } from "effect/stream" import * as ChildProcess from "node:child_process" const exec = (command: string, options?: ChildProcess.ExecOptions) =>