From 02c34615d02f91269ea04036d0306fccf4e39e18 Mon Sep 17 00:00:00 2001 From: Michael Arnaldi Date: Fri, 2 Feb 2024 11:16:54 +0100 Subject: [PATCH] feat: Make Equal an implicit trait, namely remove the type Data.Data (#2023) --- .changeset/mighty-donuts-behave.md | 33 ++++++ packages/cli/src/Options.ts | 4 +- packages/effect/dtslint/Data.ts | 34 +++--- packages/effect/src/Cause.ts | 3 +- packages/effect/src/Data.ts | 99 +++++++---------- packages/effect/src/Effect.ts | 117 ++++++++++----------- packages/effect/src/Either.ts | 5 +- packages/effect/src/Option.ts | 5 +- packages/effect/src/Pool.ts | 3 +- packages/effect/src/Request.ts | 5 +- packages/effect/src/internal/cache.ts | 6 +- packages/effect/src/internal/data.ts | 5 +- packages/effect/src/internal/effectable.ts | 2 +- packages/effect/test/Data.test.ts | 20 ++-- packages/platform/src/Error.ts | 5 +- packages/platform/src/Http/Body.ts | 3 +- packages/platform/src/Http/ClientError.ts | 5 +- packages/platform/src/Http/Multipart.ts | 3 +- packages/platform/src/Http/ServerError.ts | 5 +- packages/platform/src/WorkerError.ts | 3 +- packages/rpc/src/SchemaC.ts | 6 +- packages/rpc/src/internal/resolver.ts | 4 +- packages/schema/src/Schema.ts | 16 +-- 23 files changed, 194 insertions(+), 197 deletions(-) create mode 100644 .changeset/mighty-donuts-behave.md diff --git a/.changeset/mighty-donuts-behave.md b/.changeset/mighty-donuts-behave.md new file mode 100644 index 0000000000..bc052bfd27 --- /dev/null +++ b/.changeset/mighty-donuts-behave.md @@ -0,0 +1,33 @@ +--- +"@effect/platform": minor +"effect": minor +"@effect/schema": minor +"@effect/cli": minor +"@effect/rpc": minor +--- + +With this change we remove the `Data.Data` type and we make `Equal.Equal` & `Hash.Hash` implicit traits. + +The main reason is that `Data.Data` was structurally equivalent to `A & Equal.Equal` but extending `Equal.Equal` doesn't mean that the equality is implemented by-value, so the type was simply adding noise without gaining any level of safety. + +The module `Data` remains unchanged at the value level, all the functions previously available are supposed to work in exactly the same manner. + +At the type level instead the functions return `Readonly` variants, so for example we have: + +```ts +import { Data } from "effect"; + +const obj = Data.struct({ + a: 0, + b: 1, +}); +``` + +will have the `obj` typed as: + +```ts +declare const obj: { + readonly a: number; + readonly b: number; +}; +``` diff --git a/packages/cli/src/Options.ts b/packages/cli/src/Options.ts index a942a828e6..fbb451dab9 100644 --- a/packages/cli/src/Options.ts +++ b/packages/cli/src/Options.ts @@ -177,13 +177,13 @@ export const choice: >( * * export type Animal = Dog | Cat * - * export interface Dog extends Data.Case { + * export interface Dog { * readonly _tag: "Dog" * } * * export const Dog = Data.tagged("Dog") * - * export interface Cat extends Data.Case { + * export interface Cat { * readonly _tag: "Cat" * } * diff --git a/packages/effect/dtslint/Data.ts b/packages/effect/dtslint/Data.ts index ca27947644..b8b7af96db 100644 --- a/packages/effect/dtslint/Data.ts +++ b/packages/effect/dtslint/Data.ts @@ -10,13 +10,13 @@ declare const mutableArray: Array // struct // ------------------------------------------------------------------------------------- -// $ExpectType Data<{ readonly a: string; }> +// $ExpectType { readonly a: string; } const struct1 = Data.struct(mutableStruct) // @ts-expect-error struct1.a = "a" -// $ExpectType Data<{ readonly a: string; }> +// $ExpectType { readonly a: string; } const struct2 = Data.struct(readonlyStruct) // @ts-expect-error @@ -26,13 +26,13 @@ struct2.a = "a" // unsafeStruct // ------------------------------------------------------------------------------------- -// $ExpectType Data<{ readonly a: string; }> +// $ExpectType { readonly a: string; } const struct3 = Data.unsafeStruct(mutableStruct) // @ts-expect-error struct3.a = "a" -// $ExpectType Data<{ readonly a: string; }> +// $ExpectType { readonly a: string; } const struct4 = Data.unsafeStruct(readonlyStruct) // @ts-expect-error @@ -42,7 +42,7 @@ struct4.a = "a" // tuple // ------------------------------------------------------------------------------------- -// $ExpectType Data +// $ExpectType readonly [string, number] const tuple1 = Data.tuple("a", 1) // @ts-expect-error @@ -54,13 +54,13 @@ tuple1[1] = 1 // array // ------------------------------------------------------------------------------------- -// $ExpectType Data +// $ExpectType readonly string[] const array1 = Data.array(mutableArray) // @ts-expect-error array1[0] = "a" -// $ExpectType Data +// $ExpectType readonly string[] const array2 = Data.array(readonlyArray) // @ts-expect-error @@ -70,13 +70,13 @@ array2[0] = "a" // unsafeArray // ------------------------------------------------------------------------------------- -// $ExpectType Data +// $ExpectType readonly string[] const array3 = Data.unsafeArray(mutableArray) // @ts-expect-error array3[0] = "a" -// $ExpectType Data +// $ExpectType readonly string[] const array4 = Data.unsafeArray(readonlyArray) // @ts-expect-error @@ -86,7 +86,7 @@ array4[0] = "a" // case // ------------------------------------------------------------------------------------- -interface Person extends Data.Case { +interface Person { readonly name: string } @@ -96,13 +96,13 @@ const person = Data.case() export type PersonInput = Parameters[0] // @ts-expect-error -person.name = "a" +person({ name: "" }).name = "a" // ------------------------------------------------------------------------------------- // tagged // ------------------------------------------------------------------------------------- -interface TaggedPerson extends Data.Case { +interface TaggedPerson { readonly _tag: "Person" readonly name: string readonly optional?: string @@ -124,9 +124,9 @@ type HttpError = Data.TaggedEnum<{ BadRequest: { readonly status: 400; readonly a: string } NotFound: { readonly status: 404; readonly b: number } }> -// $ExpectType Data<{ readonly _tag: "BadRequest"; readonly status: 400; readonly a: string; }> +// $ExpectType { readonly _tag: "BadRequest"; readonly status: 400; readonly a: string; } export type BadRequest = Extract -// $ExpectType Data<{ readonly _tag: "NotFound"; readonly status: 404; readonly b: number; }> +// $ExpectType { readonly _tag: "NotFound"; readonly status: 404; readonly b: number; } export type NotFound = Extract // @ts-expect-error @@ -140,14 +140,14 @@ export type Err = Data.TaggedEnum<{ // ------------------------------------------------------------------------------------- const { NotFound } = Data.taggedEnum< - | Data.Data<{ readonly _tag: "BadRequest"; readonly status: 400; readonly message: string }> - | Data.Data<{ readonly _tag: "NotFound"; readonly status: 404; readonly message: string }> + | { readonly _tag: "BadRequest"; readonly status: 400; readonly message: string } + | { readonly _tag: "NotFound"; readonly status: 404; readonly message: string } >() // $ExpectType { readonly status: 404; readonly message: string; } export type notFoundInput = Parameters[0] -// $ExpectType Data<{ readonly _tag: "NotFound"; readonly status: 404; readonly message: string; }> +// $ExpectType { readonly _tag: "NotFound"; readonly status: 404; readonly message: string; } export type notFoundOutput = ReturnType const notFound = NotFound({ status: 404, message: "mesage" }) diff --git a/packages/effect/src/Cause.ts b/packages/effect/src/Cause.ts index fd7ae1016f..e42c526f71 100644 --- a/packages/effect/src/Cause.ts +++ b/packages/effect/src/Cause.ts @@ -23,7 +23,6 @@ */ import type * as Channel from "./Channel.js" import type * as Chunk from "./Chunk.js" -import type * as Data from "./Data.js" import type * as Effect from "./Effect.js" import type * as Either from "./Either.js" import type * as Equal from "./Equal.js" @@ -190,7 +189,7 @@ export interface CauseReducer { * @since 2.0.0 * @category models */ -export interface YieldableError extends Data.Case, Pipeable, Inspectable, Readonly { +export interface YieldableError extends Pipeable, Inspectable, Readonly { readonly [Effect.EffectTypeId]: Effect.Effect.VarianceStruct readonly [Stream.StreamTypeId]: Effect.Effect.VarianceStruct readonly [Sink.SinkTypeId]: Sink.Sink.VarianceStruct diff --git a/packages/effect/src/Data.ts b/packages/effect/src/Data.ts index 0fea627013..ccc1f7d442 100644 --- a/packages/effect/src/Data.ts +++ b/packages/effect/src/Data.ts @@ -2,30 +2,11 @@ * @since 2.0.0 */ import type * as Cause from "./Cause.js" -import type * as Equal from "./Equal.js" import * as core from "./internal/core.js" import * as internal from "./internal/data.js" import { StructuralPrototype } from "./internal/effectable.js" import type * as Types from "./Types.js" -/** - * @category models - * @since 2.0.0 - */ -export type Data = - & { readonly [P in keyof A]: A[P] } - & Equal.Equal - -/** - * `Case` represents a datatype similar to a case class in Scala. Namely, a - * datatype created using `Case` will, by default, provide an implementation - * for a constructor, `Hash`, and `Equal`. - * - * @since 2.0.0 - * @category models - */ -export interface Case extends Equal.Equal {} - /** * @since 2.0.0 */ @@ -34,10 +15,10 @@ export declare namespace Case { * @since 2.0.0 * @category models */ - export interface Constructor { + export interface Constructor { ( - args: Types.Equals, {}> extends true ? void - : { readonly [P in keyof A as P extends Tag | keyof Equal.Equal ? never : P]: A[P] } + args: Types.Equals, {}> extends true ? void + : { readonly [P in keyof A as P extends Tag ? never : P]: A[P] } ): A } } @@ -60,13 +41,13 @@ export declare namespace Case { * @category constructors * @since 2.0.0 */ -export const struct: >(a: A) => Data<{ readonly [P in keyof A]: A[P] }> = internal.struct +export const struct: >(a: A) => { readonly [P in keyof A]: A[P] } = internal.struct /** * @category constructors * @since 2.0.0 */ -export const unsafeStruct = >(as: A): Data<{ readonly [P in keyof A]: A[P] }> => +export const unsafeStruct = >(as: A): { readonly [P in keyof A]: A[P] } => Object.setPrototypeOf(as, StructuralPrototype) /** @@ -87,7 +68,7 @@ export const unsafeStruct = >(as: A): Data<{ reado * @category constructors * @since 2.0.0 */ -export const tuple = >(...as: As): Data> => unsafeArray(as) +export const tuple = >(...as: As): Readonly => unsafeArray(as) /** * @example @@ -113,17 +94,16 @@ export const tuple = >(...as: As): Data>(as: As): Data> => - unsafeArray(as.slice(0) as unknown as As) +export const array = >(as: As): Readonly => unsafeArray(as.slice(0) as unknown as As) /** * @category constructors * @since 2.0.0 */ -export const unsafeArray = >(as: As): Data> => +export const unsafeArray = >(as: As): Readonly => Object.setPrototypeOf(as, internal.ArrayProto) -const _case = (): Case.Constructor => (args) => +const _case = (): Case.Constructor => (args) => (args === undefined ? Object.create(StructuralPrototype) : struct(args)) as any export { @@ -134,8 +114,7 @@ export { * import * as Data from "effect/Data" * import * as Equal from "effect/Equal" * - * // Extending Data.Case to implement Equal - * interface Person extends Data.Case { + * interface Person { * readonly name: string * } * @@ -163,7 +142,7 @@ export { * @example * import * as Data from "effect/Data" * - * interface Person extends Data.Case { + * interface Person { * readonly _tag: "Person" // the tag * readonly name: string * } @@ -177,7 +156,7 @@ export { * @since 2.0.0 * @category constructors */ -export const tagged = ( +export const tagged = ( tag: A["_tag"] ): Case.Constructor => (args) => { @@ -208,9 +187,9 @@ export const tagged = ( * @category constructors */ export const Class: new = {}>( - args: Types.Equals, {}> extends true ? void - : { readonly [P in keyof A as P extends keyof Equal.Equal ? never : P]: A[P] } -) => Data> = internal.Structural as any + args: Types.Equals extends true ? void + : { readonly [P in keyof A]: A[P] } +) => Readonly = internal.Structural as any /** * Provides a Tagged constructor for a Case Class. @@ -238,9 +217,9 @@ export const Class: new = {}>( export const TaggedClass = ( tag: Tag ): new = {}>( - args: Types.Equals, {}> extends true ? void - : { readonly [P in keyof A as P extends "_tag" | keyof Equal.Equal ? never : P]: A[P] } -) => Data & { readonly _tag: Tag }> => { + args: Types.Equals extends true ? void + : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] } +) => Readonly & { readonly _tag: Tag } => { class Base extends Class { readonly _tag = tag } @@ -252,9 +231,9 @@ export const TaggedClass = ( * @category constructors */ export const Structural: new( - args: Types.Equals, {}> extends true ? void - : { readonly [P in keyof A as P extends keyof Equal.Equal ? never : P]: A[P] } -) => Case = internal.Structural as any + args: Types.Equals extends true ? void + : { readonly [P in keyof A]: A[P] } +) => {} = internal.Structural as any /** * Create a tagged enum data type, which is a union of `Data` structs. @@ -269,16 +248,16 @@ export const Structural: new( * * // Equivalent to: * type HttpErrorPlain = - * | Data.Data<{ + * | { * readonly _tag: "BadRequest" * readonly status: 400 * readonly message: string - * }> - * | Data.Data<{ + * } + * | { * readonly _tag: "NotFound" * readonly status: 404 * readonly message: string - * }> + * } * ``` * * @since 2.0.0 @@ -286,9 +265,8 @@ export const Structural: new( */ export type TaggedEnum< A extends Record> & UntaggedChildren -> = keyof A extends infer Tag ? Tag extends keyof A ? Data< - Types.Simplify<{ readonly _tag: Tag } & { readonly [K in keyof A[Tag]]: A[Tag][K] }> - > +> = keyof A extends infer Tag ? + Tag extends keyof A ? Types.Simplify<{ readonly _tag: Tag } & { readonly [K in keyof A[Tag]]: A[Tag][K] }> : never : never @@ -310,7 +288,7 @@ export declare namespace TaggedEnum { * @category models */ export interface WithGenerics { - readonly taggedEnum: Data<{ readonly _tag: string }> + readonly taggedEnum: { readonly _tag: string } readonly numberOfGenerics: Count readonly A: unknown @@ -340,18 +318,17 @@ export declare namespace TaggedEnum { * @since 2.0.0 */ export type Args< - A extends { readonly _tag: string } & Equal.Equal, + A extends { readonly _tag: string }, K extends A["_tag"], E = Extract - > = { readonly [K in keyof E as K extends "_tag" | keyof Case ? never : K]: E[K] } extends infer T ? - {} extends T ? void : T + > = { readonly [K in keyof E as K extends "_tag" ? never : K]: E[K] } extends infer T ? {} extends T ? void : T : never /** * @since 2.0.0 */ export type Value< - A extends { readonly _tag: string } & Equal.Equal, + A extends { readonly _tag: string }, K extends A["_tag"] > = Extract } @@ -366,8 +343,8 @@ export declare namespace TaggedEnum { * import * as Data from "effect/Data" * * const { BadRequest, NotFound } = Data.taggedEnum< - * | Data.Data<{ readonly _tag: "BadRequest"; readonly status: 400; readonly message: string }> - * | Data.Data<{ readonly _tag: "NotFound"; readonly status: 404; readonly message: string }> + * | { readonly _tag: "BadRequest"; readonly status: 400; readonly message: string } + * | { readonly _tag: "NotFound"; readonly status: 404; readonly message: string } * >() * * const notFound = NotFound({ status: 404, message: "Not Found" }) @@ -430,7 +407,7 @@ export const taggedEnum: { ) => TaggedEnum.Value, Tag> } - (): { + (): { readonly [Tag in A["_tag"]]: Case.Constructor, "_tag"> } } = () => @@ -447,8 +424,8 @@ export const taggedEnum: { * @category constructors */ export const Error: new = {}>( - args: Types.Equals, {}> extends true ? void - : { readonly [P in keyof A as P extends keyof Equal.Equal ? never : P]: A[P] } + args: Types.Equals extends true ? void + : { readonly [P in keyof A]: A[P] } ) => Cause.YieldableError & Readonly = (function() { return class Base extends core.YieldableError { constructor(args: any) { @@ -465,8 +442,8 @@ export const Error: new = {}>( * @category constructors */ export const TaggedError = (tag: Tag): new = {}>( - args: Types.Equals, {}> extends true ? void - : { readonly [P in keyof A as P extends "_tag" | keyof Equal.Equal ? never : P]: A[P] } + args: Types.Equals extends true ? void + : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] } ) => Cause.YieldableError & { readonly _tag: Tag } & Readonly => { class Base extends Error<{}> { readonly _tag = tag diff --git a/packages/effect/src/Effect.ts b/packages/effect/src/Effect.ts index 493918f291..a688c44d07 100644 --- a/packages/effect/src/Effect.ts +++ b/packages/effect/src/Effect.ts @@ -10,7 +10,6 @@ import type * as Context from "./Context.js" import type * as Deferred from "./Deferred.js" import type * as Duration from "./Duration.js" import type * as Either from "./Either.js" -import type * as Equal from "./Equal.js" import type { Equivalence } from "./Equivalence.js" import type { ExecutionStrategy } from "./ExecutionStrategy.js" import type * as Exit from "./Exit.js" @@ -54,7 +53,7 @@ import * as Scheduler from "./Scheduler.js" import type * as Scope from "./Scope.js" import type * as Supervisor from "./Supervisor.js" import type * as Tracer from "./Tracer.js" -import type { Concurrency, Covariant, NoInfer } from "./Types.js" +import type * as Types from "./Types.js" import type * as Unify from "./Unify.js" // ------------------------------------------------------------------------------------- @@ -99,7 +98,7 @@ export type EffectTypeId = typeof EffectTypeId * @since 2.0.0 * @category models */ -export interface Effect extends Effect.Variance, Equal.Equal, Pipeable { +export interface Effect extends Effect.Variance, Pipeable { readonly [Unify.typeSymbol]?: unknown readonly [Unify.unifySymbol]?: EffectUnify readonly [Unify.ignoreSymbol]?: EffectUnifyIgnore @@ -209,9 +208,9 @@ export declare namespace Effect { */ export interface VarianceStruct { readonly _V: string - readonly _R: Covariant - readonly _E: Covariant - readonly _A: Covariant + readonly _R: Types.Covariant + readonly _E: Types.Covariant + readonly _A: Types.Covariant } /** * @since 2.0.0 @@ -358,7 +357,7 @@ export const once: (self: Effect) => Effect> | Record>, O extends { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined readonly discard?: boolean | undefined readonly mode?: "default" | "validate" | "either" | undefined @@ -377,7 +376,7 @@ export const all: < */ export const allWith: < O extends { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined readonly discard?: boolean | undefined readonly mode?: "default" | "validate" | "either" | undefined @@ -475,7 +474,7 @@ export declare namespace All { export type Return< Arg extends Iterable | Record, O extends { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined readonly discard?: boolean | undefined readonly mode?: "default" | "validate" | "either" | undefined @@ -496,7 +495,7 @@ export declare namespace All { export const allSuccesses: ( elements: Iterable>, options?: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined } ) => Effect> = fiberRuntime.allSuccesses @@ -509,7 +508,7 @@ export const allSuccesses: ( */ export const dropUntil: { ( - predicate: (a: NoInfer, i: number) => Effect + predicate: (a: Types.NoInfer, i: number) => Effect ): (elements: Iterable) => Effect> (elements: Iterable, predicate: (a: A, i: number) => Effect): Effect> } = effect.dropUntil @@ -522,7 +521,7 @@ export const dropUntil: { */ export const dropWhile: { ( - predicate: (a: NoInfer, i: number) => Effect + predicate: (a: Types.NoInfer, i: number) => Effect ): (elements: Iterable) => Effect> (elements: Iterable, predicate: (a: A, i: number) => Effect): Effect> } = effect.dropWhile @@ -550,7 +549,7 @@ export const exists: { ( f: (a: A, i: number) => Effect, options?: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined } ): (elements: Iterable) => Effect @@ -558,7 +557,7 @@ export const exists: { elements: Iterable, f: (a: A, i: number) => Effect, options?: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined } ): Effect @@ -574,7 +573,7 @@ export const filter: { ( f: (a: A, i: number) => Effect, options?: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined readonly negate?: boolean | undefined } @@ -583,7 +582,7 @@ export const filter: { elements: Iterable, f: (a: A, i: number) => Effect, options?: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined readonly negate?: boolean | undefined } @@ -630,7 +629,7 @@ export const forEach: { ( f: (a: A, i: number) => Effect, options?: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined readonly discard?: false | undefined } @@ -638,7 +637,7 @@ export const forEach: { ( f: (a: A, i: number) => Effect, options: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined readonly discard: true } @@ -647,7 +646,7 @@ export const forEach: { self: Iterable, f: (a: A, i: number) => Effect, options?: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined readonly discard?: false | undefined } @@ -656,7 +655,7 @@ export const forEach: { self: Iterable, f: (a: A, i: number) => Effect, options: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined readonly discard: true } @@ -685,7 +684,7 @@ export const mergeAll: { zero: Z, f: (z: Z, a: A, i: number) => Z, options?: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined } ): (elements: Iterable>) => Effect @@ -694,7 +693,7 @@ export const mergeAll: { zero: Z, f: (z: Z, a: A, i: number) => Z, options?: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined } ): Effect @@ -711,12 +710,12 @@ export const partition: { ( f: (a: A) => Effect, options?: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined } ): (elements: Iterable) => Effect, satisfying: Array]> (elements: Iterable, f: (a: A) => Effect, options?: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined }): Effect, satisfying: Array]> } = fiberRuntime.partition @@ -744,7 +743,7 @@ export const reduceEffect: { zero: Effect, f: (acc: A, a: A, i: number) => A, options?: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined } ): (elements: Iterable>) => Effect @@ -753,7 +752,7 @@ export const reduceEffect: { zero: Effect, f: (acc: A, a: A, i: number) => A, options?: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined } ): Effect @@ -817,7 +816,7 @@ export const replicateEffect: { ( n: number, options?: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined readonly discard?: false | undefined } @@ -825,7 +824,7 @@ export const replicateEffect: { ( n: number, options: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined readonly discard: true } @@ -834,7 +833,7 @@ export const replicateEffect: { self: Effect, n: number, options?: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined readonly discard?: false | undefined } @@ -843,7 +842,7 @@ export const replicateEffect: { self: Effect, n: number, options: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined readonly discard: true } @@ -858,7 +857,7 @@ export const replicateEffect: { */ export const takeUntil: { ( - predicate: (a: NoInfer, i: number) => Effect + predicate: (a: Types.NoInfer, i: number) => Effect ): (elements: Iterable) => Effect> (elements: Iterable, predicate: (a: A, i: number) => Effect): Effect> } = effect.takeUntil @@ -871,7 +870,7 @@ export const takeUntil: { */ export const takeWhile: { ( - predicate: (a: NoInfer, i: number) => Effect + predicate: (a: Types.NoInfer, i: number) => Effect ): (elements: Iterable) => Effect> (elements: Iterable, predicate: (a: A, i: number) => Effect): Effect> } = effect.takeWhile @@ -890,7 +889,7 @@ export const validateAll: { ( f: (a: A, i: number) => Effect, options?: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined readonly discard?: false | undefined } @@ -898,7 +897,7 @@ export const validateAll: { ( f: (a: A, i: number) => Effect, options: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined readonly discard: true } @@ -907,7 +906,7 @@ export const validateAll: { elements: Iterable, f: (a: A, i: number) => Effect, options?: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined readonly discard?: false | undefined } @@ -916,7 +915,7 @@ export const validateAll: { elements: Iterable, f: (a: A, i: number) => Effect, options: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined readonly discard: true } @@ -948,7 +947,7 @@ export const validateFirst: { ( f: (a: A, i: number) => Effect, options?: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined } ): (elements: Iterable) => Effect, B> @@ -956,7 +955,7 @@ export const validateFirst: { elements: Iterable, f: (a: A, i: number) => Effect, options?: { - readonly concurrency?: Concurrency | undefined + readonly concurrency?: Types.Concurrency | undefined readonly batching?: boolean | "inherit" | undefined } ): Effect, B> @@ -1560,12 +1559,12 @@ export const catchAllDefect: { */ export const catchIf: { ( - refinement: Refinement, EB>, + refinement: Refinement, EB>, f: (e: EB) => Effect ): (self: Effect) => Effect, A2 | A> ( - predicate: Predicate>, - f: (e: NoInfer) => Effect + predicate: Predicate>, + f: (e: Types.NoInfer) => Effect ): (self: Effect) => Effect ( self: Effect, @@ -3364,12 +3363,12 @@ export { */ export const filterOrDie: { ( - refinement: Refinement, B>, - orDieWith: (a: NoInfer) => unknown + refinement: Refinement, B>, + orDieWith: (a: Types.NoInfer) => unknown ): (self: Effect) => Effect ( - predicate: Predicate>, - orDieWith: (a: NoInfer) => unknown + predicate: Predicate>, + orDieWith: (a: Types.NoInfer) => unknown ): (self: Effect) => Effect ( self: Effect, @@ -3388,10 +3387,10 @@ export const filterOrDie: { */ export const filterOrDieMessage: { ( - refinement: Refinement, B>, + refinement: Refinement, B>, message: string ): (self: Effect) => Effect - (predicate: Predicate>, message: string): (self: Effect) => Effect + (predicate: Predicate>, message: string): (self: Effect) => Effect (self: Effect, refinement: Refinement, message: string): Effect (self: Effect, predicate: Predicate, message: string): Effect } = effect.filterOrDieMessage @@ -3405,12 +3404,12 @@ export const filterOrDieMessage: { */ export const filterOrElse: { ( - refinement: Refinement, B>, - orElse: (a: NoInfer) => Effect + refinement: Refinement, B>, + orElse: (a: Types.NoInfer) => Effect ): (self: Effect) => Effect ( - predicate: Predicate>, - orElse: (a: NoInfer) => Effect + predicate: Predicate>, + orElse: (a: Types.NoInfer) => Effect ): (self: Effect) => Effect ( self: Effect, @@ -3459,12 +3458,12 @@ export const filterOrElse: { */ export const filterOrFail: { ( - refinement: Refinement, B>, - orFailWith: (a: NoInfer) => E2 + refinement: Refinement, B>, + orFailWith: (a: Types.NoInfer) => E2 ): (self: Effect) => Effect ( - predicate: Predicate>, - orFailWith: (a: NoInfer) => E2 + predicate: Predicate>, + orFailWith: (a: Types.NoInfer) => E2 ): (self: Effect) => Effect ( self: Effect, @@ -3622,7 +3621,7 @@ export const flatMap: { */ export const andThen: { ( - f: (a: NoInfer) => X + f: (a: Types.NoInfer) => X ): ( self: Effect ) => [X] extends [Effect] ? Effect @@ -3637,7 +3636,7 @@ export const andThen: { : Effect ( self: Effect, - f: (a: NoInfer) => X + f: (a: Types.NoInfer) => X ): [X] extends [Effect] ? Effect : [X] extends [Promise] ? Effect : Effect @@ -3751,7 +3750,7 @@ export const summarized: { */ export const tap: { ( - f: (a: NoInfer) => X + f: (a: Types.NoInfer) => X ): ( self: Effect ) => [X] extends [Effect] ? Effect @@ -3766,7 +3765,7 @@ export const tap: { : Effect ( self: Effect, - f: (a: NoInfer) => X + f: (a: Types.NoInfer) => X ): [X] extends [Effect] ? Effect : [X] extends [Promise] ? Effect : Effect diff --git a/packages/effect/src/Either.ts b/packages/effect/src/Either.ts index b3f4973016..001d6676a5 100644 --- a/packages/effect/src/Either.ts +++ b/packages/effect/src/Either.ts @@ -2,7 +2,6 @@ * @since 2.0.0 */ -import type * as Data from "./Data.js" import * as Equivalence from "./Equivalence.js" import type { LazyArg } from "./Function.js" import { constNull, constUndefined, dual, identity } from "./Function.js" @@ -39,7 +38,7 @@ export type TypeId = typeof TypeId * @category models * @since 2.0.0 */ -export interface Left extends Data.Case, Pipeable, Inspectable { +export interface Left extends Pipeable, Inspectable { readonly _tag: "Left" readonly _op: "Left" readonly left: E @@ -56,7 +55,7 @@ export interface Left extends Data.Case, Pipeable, Inspectable { * @category models * @since 2.0.0 */ -export interface Right extends Data.Case, Pipeable, Inspectable { +export interface Right extends Pipeable, Inspectable { readonly _tag: "Right" readonly _op: "Right" readonly right: A diff --git a/packages/effect/src/Option.ts b/packages/effect/src/Option.ts index 8daa36c000..61b19ee768 100644 --- a/packages/effect/src/Option.ts +++ b/packages/effect/src/Option.ts @@ -1,7 +1,6 @@ /** * @since 2.0.0 */ -import type * as Data from "./Data.js" import type { Either } from "./Either.js" import * as Equal from "./Equal.js" import * as Equivalence from "./Equivalence.js" @@ -41,7 +40,7 @@ export type TypeId = typeof TypeId * @category models * @since 2.0.0 */ -export interface None extends Data.Case, Pipeable, Inspectable { +export interface None extends Pipeable, Inspectable { readonly _tag: "None" readonly _op: "None" readonly [TypeId]: { @@ -56,7 +55,7 @@ export interface None extends Data.Case, Pipeable, Inspectable { * @category models * @since 2.0.0 */ -export interface Some extends Data.Case, Pipeable, Inspectable { +export interface Some extends Pipeable, Inspectable { readonly _tag: "Some" readonly _op: "Some" readonly value: A diff --git a/packages/effect/src/Pool.ts b/packages/effect/src/Pool.ts index 5689f8b3b2..b36146e88e 100644 --- a/packages/effect/src/Pool.ts +++ b/packages/effect/src/Pool.ts @@ -1,7 +1,6 @@ /** * @since 2.0.0 */ -import type * as Data from "./Data.js" import type * as Duration from "./Duration.js" import type * as Effect from "./Effect.js" import * as internal from "./internal/pool.js" @@ -29,7 +28,7 @@ export type PoolTypeId = typeof PoolTypeId * @since 2.0.0 * @category models */ -export interface Pool extends Data.Case, Pool.Variance, Pipeable { +export interface Pool extends Pool.Variance, Pipeable { /** * Retrieves an item from the pool in a scoped effect. Note that if * acquisition fails, then the returned effect will fail for that same reason. diff --git a/packages/effect/src/Request.ts b/packages/effect/src/Request.ts index 0c21ae3821..3080283775 100644 --- a/packages/effect/src/Request.ts +++ b/packages/effect/src/Request.ts @@ -3,7 +3,6 @@ */ import type * as _Cache from "./Cache.js" import type { Cause } from "./Cause.js" -import type * as Data from "./Data.js" import type { Deferred } from "./Deferred.js" import type { DurationInput } from "./Duration.js" import type * as Effect from "./Effect.js" @@ -36,7 +35,7 @@ export type RequestTypeId = typeof RequestTypeId * @since 2.0.0 * @category models */ -export interface Request extends Request.Variance, Data.Case {} +export interface Request extends Request.Variance {} /** * @since 2.0.0 @@ -58,7 +57,7 @@ export declare namespace Request { * @category models */ export interface Constructor, T extends keyof R = never> { - (args: Omit, Request.Success>)>): R + (args: Omit, Request.Success>)>): R } /** diff --git a/packages/effect/src/internal/cache.ts b/packages/effect/src/internal/cache.ts index c6b59fc36e..c95bb22f5a 100644 --- a/packages/effect/src/internal/cache.ts +++ b/packages/effect/src/internal/cache.ts @@ -65,7 +65,7 @@ export const complete = ( timeToLiveMillis: number ): MapValue => Data.struct({ - _tag: "Complete", + _tag: "Complete" as const, key, exit, entryStats, @@ -78,7 +78,7 @@ export const pending = ( deferred: Deferred.Deferred ): MapValue => Data.struct({ - _tag: "Pending", + _tag: "Pending" as const, key, deferred }) @@ -89,7 +89,7 @@ export const refreshing = ( complete: Complete ): MapValue => Data.struct({ - _tag: "Refreshing", + _tag: "Refreshing" as const, deferred, complete }) diff --git a/packages/effect/src/internal/data.ts b/packages/effect/src/internal/data.ts index 7521cd4d4b..026b373e6a 100644 --- a/packages/effect/src/internal/data.ts +++ b/packages/effect/src/internal/data.ts @@ -1,4 +1,3 @@ -import type * as Data from "../Data.js" import * as Equal from "../Equal.js" import * as Hash from "../Hash.js" import type * as Types from "../Types.js" @@ -22,7 +21,7 @@ export const ArrayProto: Equal.Equal = Object.assign(Object.create(Array.prototy export const Structural: new( args: Types.Equals, {}> extends true ? void : { readonly [P in keyof A as P extends keyof Equal.Equal ? never : P]: A[P] } -) => Data.Case = (function() { +) => {} = (function() { function Structural(this: any, args: any) { if (args) { Object.assign(this, args) @@ -33,5 +32,5 @@ export const Structural: new( })() /** @internal */ -export const struct = >>(as: As): Data.Data => +export const struct = >>(as: As): As => Object.assign(Object.create(StructuralPrototype), as) diff --git a/packages/effect/src/internal/effectable.ts b/packages/effect/src/internal/effectable.ts index 6466bb7b1e..d2eb6785ae 100644 --- a/packages/effect/src/internal/effectable.ts +++ b/packages/effect/src/internal/effectable.ts @@ -64,7 +64,7 @@ const channelVariance = { } /** @internal */ -export const EffectPrototype: Effect.Effect = { +export const EffectPrototype: Effect.Effect & Equal.Equal = { [EffectTypeId]: effectVariance, [StreamTypeId]: effectVariance, [SinkTypeId]: sinkVariance, diff --git a/packages/effect/test/Data.test.ts b/packages/effect/test/Data.test.ts index 4e37e9ffcf..dd57196e26 100644 --- a/packages/effect/test/Data.test.ts +++ b/packages/effect/test/Data.test.ts @@ -14,9 +14,9 @@ describe("Data", () => { expect(Equal.equals(x, Data.struct({ a: 0 }))).toBe(false) // different keys length - expect(Data.struct({ a: 0, b: 1 })[Equal.symbol](Data.struct({ a: 0 }))).toBe(false) + expect(Equal.equals(Data.struct({ a: 0, b: 1 }), Data.struct({ a: 0 }))).toBe(false) // same length but different keys - expect(Data.struct({ a: 0 })[Equal.symbol](Data.struct({ b: 1 }))).toBe(false) + expect(Equal.equals(Data.struct({ a: 0 }), Data.struct({ b: 1 }))).toBe(false) }) it("unsafeStruct", () => { @@ -52,11 +52,11 @@ describe("Data", () => { expect(Equal.equals(x, Data.array([0, 1]))).toBe(false) // different length - expect(Data.array([0, 1, 2])[Equal.symbol](Data.array([0, 1]))).toBe(false) + expect(Equal.equals(Data.array([0, 1, 2]), Data.array([0, 1]))).toBe(false) }) it("case", () => { - interface Person extends Data.Case { + interface Person { readonly name: string } @@ -77,7 +77,7 @@ describe("Data", () => { }) it("tagged", () => { - interface Person extends Data.Case { + interface Person { readonly _tag: "Person" readonly name: string } @@ -111,11 +111,11 @@ describe("Data", () => { // different keys length class D extends Data.Class<{ d: string; e: string }> {} const d = new D({ d: "d", e: "e" }) - expect(a[Equal.symbol](d)).toBe(false) + expect(Equal.equals(a, d)).toBe(false) // same length but different keys class E extends Data.Class<{ e: string }> {} const e = new E({ e: "e" }) - expect(a[Equal.symbol](e)).toBe(false) + expect(Equal.equals(a, e)).toBe(false) }) it("tagged class", () => { @@ -133,7 +133,7 @@ describe("Data", () => { }) it("tagged - empty", () => { - interface Person extends Data.Case { + interface Person { readonly _tag: "Person" } @@ -155,12 +155,12 @@ describe("Data", () => { }) it("tagged - don't override tag", () => { - interface Foo extends Data.Case { + interface Foo { readonly _tag: "Foo" readonly value: string } const Foo = Data.tagged("Foo") - interface Bar extends Data.Case { + interface Bar { readonly _tag: "Bar" readonly value: number } diff --git a/packages/platform/src/Error.ts b/packages/platform/src/Error.ts index d8443a9922..25923d4e32 100644 --- a/packages/platform/src/Error.ts +++ b/packages/platform/src/Error.ts @@ -1,7 +1,6 @@ /** * @since 1.0.0 */ -import type * as Data from "effect/Data" import * as internal from "./internal/error.js" /** @@ -30,7 +29,7 @@ export declare namespace PlatformError { * @since 1.0.0 * @category models */ - export interface Base extends Data.Case { + export interface Base { readonly [PlatformErrorTypeId]: typeof PlatformErrorTypeId readonly _tag: string readonly module: "Clipboard" | "Command" | "FileSystem" | "KeyValueStore" | "Path" | "Stream" | "Terminal" @@ -41,7 +40,7 @@ export declare namespace PlatformError { /** * @since 1.0.0 */ - export type ProvidedFields = PlatformErrorTypeId | "_tag" | keyof Data.Case + export type ProvidedFields = PlatformErrorTypeId | "_tag" } /** diff --git a/packages/platform/src/Http/Body.ts b/packages/platform/src/Http/Body.ts index 72a7828f6b..8b1f777113 100644 --- a/packages/platform/src/Http/Body.ts +++ b/packages/platform/src/Http/Body.ts @@ -3,7 +3,6 @@ */ import type * as ParseResult from "@effect/schema/ParseResult" import type * as Schema from "@effect/schema/Schema" -import type * as Data from "effect/Data" import type * as Effect from "effect/Effect" import type * as Stream_ from "effect/Stream" import type * as PlatformError from "../Error.js" @@ -73,7 +72,7 @@ export type ErrorTypeId = typeof ErrorTypeId * @since 1.0.0 * @category errors */ -export interface BodyError extends Data.Case { +export interface BodyError { readonly [ErrorTypeId]: ErrorTypeId readonly _tag: "BodyError" readonly reason: BodyErrorReason diff --git a/packages/platform/src/Http/ClientError.ts b/packages/platform/src/Http/ClientError.ts index 6d0ea77dfe..0d176ac8f3 100644 --- a/packages/platform/src/Http/ClientError.ts +++ b/packages/platform/src/Http/ClientError.ts @@ -1,7 +1,6 @@ /** * @since 1.0.0 */ -import type * as Data from "effect/Data" import * as internal from "../internal/http/clientError.js" import type * as ClientRequest from "./ClientRequest.js" import type * as ClientResponse from "./ClientResponse.js" @@ -32,7 +31,7 @@ export declare namespace HttpError { * @since 1.0.0 * @category models */ - export interface Proto extends Data.Case { + export interface Proto { readonly [TypeId]: TypeId readonly _tag: string } @@ -40,7 +39,7 @@ export declare namespace HttpError { /** * @since 1.0.0 */ - export type ProvidedFields = TypeId | "_tag" | keyof Data.Case + export type ProvidedFields = TypeId | "_tag" } /** diff --git a/packages/platform/src/Http/Multipart.ts b/packages/platform/src/Http/Multipart.ts index 84c7ebb022..452b0c9e69 100644 --- a/packages/platform/src/Http/Multipart.ts +++ b/packages/platform/src/Http/Multipart.ts @@ -5,7 +5,6 @@ import type * as ParseResult from "@effect/schema/ParseResult" import type * as Schema from "@effect/schema/Schema" import type * as Channel from "effect/Channel" import type * as Chunk from "effect/Chunk" -import type * as Data from "effect/Data" import type * as Effect from "effect/Effect" import type * as FiberRef from "effect/FiberRef" import type * as Option from "effect/Option" @@ -107,7 +106,7 @@ export type ErrorTypeId = typeof ErrorTypeId * @since 1.0.0 * @category errors */ -export interface MultipartError extends Data.Case { +export interface MultipartError { readonly [ErrorTypeId]: ErrorTypeId readonly _tag: "MultipartError" readonly reason: "FileTooLarge" | "FieldTooLarge" | "BodyTooLarge" | "TooManyParts" | "InternalError" | "Parse" diff --git a/packages/platform/src/Http/ServerError.ts b/packages/platform/src/Http/ServerError.ts index 2f51a17530..6d15bdb24d 100644 --- a/packages/platform/src/Http/ServerError.ts +++ b/packages/platform/src/Http/ServerError.ts @@ -2,7 +2,6 @@ * @since 1.0.0 */ import type * as Cause from "effect/Cause" -import type * as Data from "effect/Data" import type * as FiberId from "effect/FiberId" import * as internal from "../internal/http/serverError.js" import type * as ServerRequest from "./ServerRequest.js" @@ -34,7 +33,7 @@ export declare namespace HttpError { * @since 1.0.0 * @category models */ - export interface Proto extends Data.Case { + export interface Proto { readonly [TypeId]: TypeId readonly _tag: string } @@ -42,7 +41,7 @@ export declare namespace HttpError { /** * @since 1.0.0 */ - export type ProvidedFields = TypeId | "_tag" | keyof Data.Case + export type ProvidedFields = TypeId | "_tag" } /** diff --git a/packages/platform/src/WorkerError.ts b/packages/platform/src/WorkerError.ts index 9c5202979e..57abc93c3d 100644 --- a/packages/platform/src/WorkerError.ts +++ b/packages/platform/src/WorkerError.ts @@ -1,7 +1,6 @@ /** * @since 1.0.0 */ -import type * as Data from "effect/Data" import * as internal from "./internal/workerError.js" /** @@ -20,7 +19,7 @@ export type WorkerErrorTypeId = typeof WorkerErrorTypeId * @since 1.0.0 * @category errors */ -export interface WorkerError extends Data.Case { +export interface WorkerError { readonly [WorkerErrorTypeId]: WorkerErrorTypeId readonly _tag: "WorkerError" readonly reason: "spawn" | "decode" | "send" | "unknown" | "encode" diff --git a/packages/rpc/src/SchemaC.ts b/packages/rpc/src/SchemaC.ts index a577734a08..5fd5c5bcf4 100644 --- a/packages/rpc/src/SchemaC.ts +++ b/packages/rpc/src/SchemaC.ts @@ -99,18 +99,18 @@ export const withConstructorTagged: { export const withConstructorDataTagged: { ( tag: A["_tag"] - ): (self: Schema.Schema) => SchemaC, Omit> + ): (self: Schema.Schema) => SchemaC> >( self: Schema.Schema, tag: A["_tag"] - ): SchemaC, Omit> + ): SchemaC> } = dual( 2, >( self: Schema.Schema, tag: A["_tag"] - ): SchemaC, Omit> => withConstructor(Schema.data(self), Data.tagged(tag) as any) + ): SchemaC> => withConstructor(Schema.data(self), Data.tagged(tag) as any) ) /** diff --git a/packages/rpc/src/internal/resolver.ts b/packages/rpc/src/internal/resolver.ts index 6fd822c1bf..d7f9749526 100644 --- a/packages/rpc/src/internal/resolver.ts +++ b/packages/rpc/src/internal/resolver.ts @@ -10,7 +10,7 @@ import type { RpcError, RpcTransportError } from "../Error.js" import type * as resolver from "../Resolver.js" import * as Codec from "./codec.js" -const requestProto: Request.Request = { +const requestProto: Request.Request & Equal.Equal = { [Request.RequestTypeId]: { _E: (_: never) => _, _A: (_: never) => _ @@ -19,7 +19,7 @@ const requestProto: Request.Request = { return this.hash }, [Equal.symbol](this: resolver.RpcRequest, that: Equal.Equal) { - return this.hash === (that as resolver.RpcRequest).hash + return this.hash === (that as resolver.RpcRequest & Equal.Equal).hash } } diff --git a/packages/schema/src/Schema.ts b/packages/schema/src/Schema.ts index 35e254e298..181d46721f 100644 --- a/packages/schema/src/Schema.ts +++ b/packages/schema/src/Schema.ts @@ -4475,22 +4475,22 @@ export const chunk = (item: Schema): Schema, Re Chunk.toReadonlyArray ) -const toData = > | ReadonlyArray>(a: A): Data.Data => +const toData = > | ReadonlyArray>(a: A): A => Array.isArray(a) ? Data.array(a) : Data.struct(a) const dataArbitrary = > | ReadonlyArray>( item: Arbitrary -): Arbitrary> => +): Arbitrary => (fc) => item(fc).map(toData) const dataPretty = > | ReadonlyArray>( item: Pretty.Pretty -): Pretty.Pretty> => +): Pretty.Pretty => (d) => `Data(${item(d)})` const dataParse = > | ReadonlyArray>( decodeUnknown: ParseResult.DecodeUnknown -): ParseResult.DeclarationDecodeUnknown> => +): ParseResult.DeclarationDecodeUnknown => (u, options, ast) => Equal.isEqual(u) ? ParseResult.map(decodeUnknown(u, options), toData) @@ -4506,7 +4506,7 @@ export const dataFromSelf = < A extends Readonly> | ReadonlyArray >( item: Schema -): Schema, Data.Data, R> => { +): Schema => { return declare( [item], (item) => dataParse(ParseResult.decodeUnknown(item)), @@ -4530,7 +4530,7 @@ export const data = < A extends Readonly> | ReadonlyArray >( item: Schema -): Schema, I, R> => +): Schema => transform( item, dataFromSelf(to(item)), @@ -4639,7 +4639,7 @@ export const Class = () => Schema.Context, Simplify>, Self, - Data.Case + {} > => makeClass(struct(fields), fields, Data.Class) /** @@ -4657,7 +4657,7 @@ export const TaggedClass = () => Schema.Context, Simplify>, Self, - Data.Case + {} > => { const fieldsWithTag: StructFields = { ...fields, _tag: literal(tag) }