Skip to content

Commit

Permalink
Revert removal of custom NoInfer (#2626)
Browse files Browse the repository at this point in the history
  • Loading branch information
fubhy committed Apr 26, 2024
1 parent 8492f5b commit 027418e
Show file tree
Hide file tree
Showing 40 changed files with 95 additions and 62 deletions.
8 changes: 8 additions & 0 deletions .changeset/clever-olives-cheat.md
@@ -0,0 +1,8 @@
---
"effect": patch
"@effect/experimental": patch
"@effect/schema": patch
"@effect/sql": patch
---

Reintroduce custom `NoInfer` type
4 changes: 2 additions & 2 deletions packages/effect/dtslint/Either.ts
Expand Up @@ -120,7 +120,7 @@ declare const error$arrayOfStrings: Either.Either<Array<string>, Error>
pipe(
error$arrayOfStrings,
Either.filterOrLeft(Array.isNonEmptyArray, (
_s // $ExpectType NoInfer<string[]>
_s // $ExpectType string[]
) => "b" as const)
)

Expand All @@ -130,7 +130,7 @@ declare const error$readonlyArrayOfStrings: Either.Either<ReadonlyArray<string>,
pipe(
error$readonlyArrayOfStrings,
Either.filterOrLeft(Array.isNonEmptyReadonlyArray, (
_s // $ExpectType NoInfer<readonly string[]>
_s // $ExpectType readonly string[]
) => "b" as const)
)

Expand Down
1 change: 1 addition & 0 deletions packages/effect/src/Array.ts
Expand Up @@ -20,6 +20,7 @@ import type { Predicate, Refinement } from "./Predicate.js"
import { isBoolean } from "./Predicate.js"
import * as Record from "./Record.js"
import * as Tuple from "./Tuple.js"
import type { NoInfer } from "./Types.js"

/**
* @category type lambdas
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/Cause.ts
Expand Up @@ -36,7 +36,7 @@ import type { Pipeable } from "./Pipeable.js"
import type { Predicate, Refinement } from "./Predicate.js"
import type * as Sink from "./Sink.js"
import type * as Stream from "./Stream.js"
import type { Covariant } from "./Types.js"
import type { Covariant, NoInfer } from "./Types.js"

/**
* @since 2.0.0
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/Chunk.ts
Expand Up @@ -17,7 +17,7 @@ import * as Order from "./Order.js"
import type { Pipeable } from "./Pipeable.js"
import { pipeArguments } from "./Pipeable.js"
import { hasProperty, type Predicate, type Refinement } from "./Predicate.js"
import type { Covariant } from "./Types.js"
import type { Covariant, NoInfer } from "./Types.js"

const TypeId: unique symbol = Symbol.for("effect/Chunk") as TypeId

Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/Effect.ts
Expand Up @@ -56,7 +56,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, MergeRecord, NotFunction } from "./Types.js"
import type { Concurrency, Covariant, MergeRecord, NoInfer, NotFunction } from "./Types.js"
import type * as Unify from "./Unify.js"

// -------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/Either.ts
Expand Up @@ -12,7 +12,7 @@ import type { Option } from "./Option.js"
import type { Pipeable } from "./Pipeable.js"
import type { Predicate, Refinement } from "./Predicate.js"
import { isFunction } from "./Predicate.js"
import type { Covariant, MergeRecord, NotFunction } from "./Types.js"
import type { Covariant, MergeRecord, NoInfer, NotFunction } from "./Types.js"
import type * as Unify from "./Unify.js"
import type * as Gen from "./Utils.js"

Expand Down
1 change: 1 addition & 0 deletions packages/effect/src/Exit.ts
Expand Up @@ -10,6 +10,7 @@ import * as core from "./internal/core.js"
import type * as Option from "./Option.js"
import type { Pipeable } from "./Pipeable.js"
import type { Predicate, Refinement } from "./Predicate.js"
import type { NoInfer } from "./Types.js"
import type * as Unify from "./Unify.js"

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/GroupBy.ts
Expand Up @@ -7,7 +7,7 @@ import type { Predicate } from "./Predicate.js"
import type * as Queue from "./Queue.js"
import type * as Stream from "./Stream.js"
import type * as Take from "./Take.js"
import type { Covariant } from "./Types.js"
import type { Covariant, NoInfer } from "./Types.js"

/**
* @since 2.0.0
Expand Down
1 change: 1 addition & 0 deletions packages/effect/src/HashMap.ts
Expand Up @@ -9,6 +9,7 @@ import * as HM from "./internal/hashMap.js"
import * as _keySet from "./internal/hashMap/keySet.js"
import type { Option } from "./Option.js"
import type { Pipeable } from "./Pipeable.js"
import type { NoInfer } from "./Types.js"

const TypeId: unique symbol = HM.HashMapTypeId as TypeId

Expand Down
1 change: 1 addition & 0 deletions packages/effect/src/HashSet.ts
Expand Up @@ -7,6 +7,7 @@ import type { Inspectable } from "./Inspectable.js"
import * as HS from "./internal/hashSet.js"
import type { Pipeable } from "./Pipeable.js"
import type { Predicate, Refinement } from "./Predicate.js"
import type { NoInfer } from "./Types.js"

const TypeId: unique symbol = HS.HashSetTypeId as TypeId

Expand Down
1 change: 1 addition & 0 deletions packages/effect/src/Iterable.ts
Expand Up @@ -14,6 +14,7 @@ import * as O from "./Option.js"
import { isBoolean } from "./Predicate.js"
import type * as Record from "./Record.js"
import * as Tuple from "./Tuple.js"
import type { NoInfer } from "./Types.js"

/**
* Return a `Iterable` with element `i` initialized with `f(i)`.
Expand Down
1 change: 1 addition & 0 deletions packages/effect/src/List.ts
Expand Up @@ -33,6 +33,7 @@ import * as Option from "./Option.js"
import type { Pipeable } from "./Pipeable.js"
import { pipeArguments } from "./Pipeable.js"
import { hasProperty, type Predicate, type Refinement } from "./Predicate.js"
import type { NoInfer } from "./Types.js"

/**
* Represents an immutable linked list of elements of type `A`.
Expand Down
4 changes: 2 additions & 2 deletions packages/effect/src/Logger.ts
Expand Up @@ -183,12 +183,12 @@ export const map: {
export const batched: {
<Output, R>(
window: DurationInput,
f: (messages: Array<NoInfer<Output>>) => Effect<void, never, R>
f: (messages: Array<Types.NoInfer<Output>>) => Effect<void, never, R>
): <Message>(self: Logger<Message, Output>) => Effect<Logger<Message, void>, never, R | Scope>
<Message, Output, R>(
self: Logger<Message, Output>,
window: DurationInput,
f: (messages: Array<NoInfer<Output>>) => Effect<void, never, R>
f: (messages: Array<Types.NoInfer<Output>>) => Effect<void, never, R>
): Effect<Logger<Message, void>, never, Scope | R>
} = fiberRuntime.batchedLogger

Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/Option.ts
Expand Up @@ -14,7 +14,7 @@ import type { Order } from "./Order.js"
import * as order from "./Order.js"
import type { Pipeable } from "./Pipeable.js"
import type { Predicate, Refinement } from "./Predicate.js"
import type { Covariant, NotFunction } from "./Types.js"
import type { Covariant, NoInfer, NotFunction } from "./Types.js"
import type * as Unify from "./Unify.js"
import type * as Gen from "./Utils.js"

Expand Down
1 change: 1 addition & 0 deletions packages/effect/src/Readable.ts
Expand Up @@ -6,6 +6,7 @@ import { dual } from "./Function.js"
import * as core from "./internal/core.js"
import { type Pipeable, pipeArguments } from "./Pipeable.js"
import { hasProperty } from "./Predicate.js"
import type { NoInfer } from "./Types.js"

/**
* @since 2.0.0
Expand Down
1 change: 1 addition & 0 deletions packages/effect/src/Record.ts
Expand Up @@ -11,6 +11,7 @@ import type { Equivalence } from "./Equivalence.js"
import { dual, identity } from "./Function.js"
import type { TypeLambda } from "./HKT.js"
import * as Option from "./Option.js"
import type { NoInfer } from "./Types.js"

/**
* @category models
Expand Down
8 changes: 4 additions & 4 deletions packages/effect/src/RequestResolver.ts
Expand Up @@ -188,13 +188,13 @@ export const around: {
*/
export const aroundRequests: {
<A, A2, R2, X, R3>(
before: (requests: ReadonlyArray<NoInfer<A>>) => Effect.Effect<A2, never, R2>,
after: (requests: ReadonlyArray<NoInfer<A>>, _: A2) => Effect.Effect<X, never, R3>
before: (requests: ReadonlyArray<Types.NoInfer<A>>) => Effect.Effect<A2, never, R2>,
after: (requests: ReadonlyArray<Types.NoInfer<A>>, _: A2) => Effect.Effect<X, never, R3>
): <R>(self: RequestResolver<A, R>) => RequestResolver<A, R2 | R3 | R>
<A, R, A2, R2, X, R3>(
self: RequestResolver<A, R>,
before: (requests: ReadonlyArray<NoInfer<A>>) => Effect.Effect<A2, never, R2>,
after: (requests: ReadonlyArray<NoInfer<A>>, _: A2) => Effect.Effect<X, never, R3>
before: (requests: ReadonlyArray<Types.NoInfer<A>>) => Effect.Effect<A2, never, R2>,
after: (requests: ReadonlyArray<Types.NoInfer<A>>, _: A2) => Effect.Effect<X, never, R3>
): RequestResolver<A, R | R2 | R3>
} = internal.aroundRequests

Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/STM.ts
Expand Up @@ -14,7 +14,7 @@ import * as stm from "./internal/stm/stm.js"
import type * as Option from "./Option.js"
import type { Pipeable } from "./Pipeable.js"
import type { Predicate, Refinement } from "./Predicate.js"
import type { Covariant, MergeRecord } from "./Types.js"
import type { Covariant, MergeRecord, NoInfer } from "./Types.js"
import type * as Unify from "./Unify.js"

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/SortedSet.ts
Expand Up @@ -14,7 +14,7 @@ import { pipeArguments } from "./Pipeable.js"
import type { Predicate } from "./Predicate.js"
import { hasProperty } from "./Predicate.js"
import * as RBT from "./RedBlackTree.js"
import type { Invariant } from "./Types.js"
import type { Invariant, NoInfer } from "./Types.js"

const TypeId: unique symbol = Symbol.for("effect/SortedSet")

Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/Stream.ts
Expand Up @@ -29,7 +29,7 @@ import type * as Emit from "./StreamEmit.js"
import type * as HaltStrategy from "./StreamHaltStrategy.js"
import type * as Take from "./Take.js"
import type * as Tracer from "./Tracer.js"
import type { Covariant, MergeRecord } from "./Types.js"
import type { Covariant, MergeRecord, NoInfer } from "./Types.js"
import type * as Unify from "./Unify.js"

/**
Expand Down
1 change: 1 addition & 0 deletions packages/effect/src/Subscribable.ts
Expand Up @@ -7,6 +7,7 @@ import { pipeArguments } from "./Pipeable.js"
import { hasProperty } from "./Predicate.js"
import * as Readable from "./Readable.js"
import * as Stream from "./Stream.js"
import type { NoInfer } from "./Types.js"

/**
* @since 2.0.0
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/Trie.ts
Expand Up @@ -20,7 +20,7 @@ import type { Inspectable } from "./Inspectable.js"
import * as TR from "./internal/trie.js"
import type { Option } from "./Option.js"
import type { Pipeable } from "./Pipeable.js"
import type { Covariant } from "./Types.js"
import type { Covariant, NoInfer } from "./Types.js"

const TypeId: unique symbol = TR.TrieTypeId as TypeId

Expand Down
8 changes: 8 additions & 0 deletions packages/effect/src/Types.ts
Expand Up @@ -170,6 +170,14 @@ export type Mutable<T> = {
-readonly [P in keyof T]: T[P]
}

/**
* Avoid inference on a specific parameter
*
* @since 2.0.0
* @category models
*/
export type NoInfer<A> = [A][A extends any ? 0 : never]

/**
* Invariant helper.
*
Expand Down
1 change: 1 addition & 0 deletions packages/effect/src/internal/cause.ts
Expand Up @@ -13,6 +13,7 @@ import { pipeArguments } from "../Pipeable.js"
import { hasProperty, isFunction } from "../Predicate.js"
import type { Predicate, Refinement } from "../Predicate.js"
import type { AnySpan, Span } from "../Tracer.js"
import type { NoInfer } from "../Types.js"
import { getBugErrorMessage } from "./errors.js"
import * as OpCodes from "./opCodes/cause.js"

Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/internal/core-effect.ts
Expand Up @@ -25,7 +25,7 @@ import type * as Random from "../Random.js"
import * as Ref from "../Ref.js"
import type * as runtimeFlagsPatch from "../RuntimeFlagsPatch.js"
import * as Tracer from "../Tracer.js"
import type { MergeRecord } from "../Types.js"
import type { MergeRecord, NoInfer } from "../Types.js"
import * as internalCause from "./cause.js"
import { clockTag } from "./clock.js"
import * as core from "./core.js"
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/internal/core.ts
Expand Up @@ -35,7 +35,7 @@ import type * as RuntimeFlags from "../RuntimeFlags.js"
import * as RuntimeFlagsPatch from "../RuntimeFlagsPatch.js"
import type * as Scope from "../Scope.js"
import type * as Tracer from "../Tracer.js"
import type { NotFunction } from "../Types.js"
import type { NoInfer, NotFunction } from "../Types.js"
import * as _blockedRequests from "./blockedRequests.js"
import * as internalCause from "./cause.js"
import * as deferred from "./deferred.js"
Expand Down
1 change: 1 addition & 0 deletions packages/effect/src/internal/dataSource.ts
Expand Up @@ -7,6 +7,7 @@ import type * as Either from "../Either.js"
import { dual, pipe } from "../Function.js"
import type * as Request from "../Request.js"
import type * as RequestResolver from "../RequestResolver.js"
import type { NoInfer } from "../Types.js"
import * as core from "./core.js"
import { invokeWithInterrupt, zipWithOptions } from "./fiberRuntime.js"
import { complete } from "./request.js"
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/internal/fiberRuntime.ts
Expand Up @@ -41,7 +41,7 @@ import { currentScheduler, type 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 } from "../Types.js"
import type { Concurrency, NoInfer } from "../Types.js"
import * as _RequestBlock from "./blockedRequests.js"
import * as internalCause from "./cause.js"
import * as clock from "./clock.js"
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/internal/groupBy.ts
Expand Up @@ -13,7 +13,7 @@ import * as Queue from "../Queue.js"
import * as Ref from "../Ref.js"
import type * as Stream from "../Stream.js"
import type * as Take from "../Take.js"
import type { MergeRecord } from "../Types.js"
import type { MergeRecord, NoInfer } from "../Types.js"
import * as channel from "./channel.js"
import * as channelExecutor from "./channel/channelExecutor.js"
import * as core from "./core-stream.js"
Expand Down
1 change: 1 addition & 0 deletions packages/effect/src/internal/hashMap.ts
Expand Up @@ -7,6 +7,7 @@ import { format, NodeInspectSymbol, toJSON } from "../Inspectable.js"
import * as Option from "../Option.js"
import { pipeArguments } from "../Pipeable.js"
import { hasProperty } from "../Predicate.js"
import type { NoInfer } from "../Types.js"
import { fromBitmap, hashFragment, toBitmap } from "./hashMap/bitwise.js"
import { SIZE } from "./hashMap/config.js"
import * as Node from "./hashMap/node.js"
Expand Down
1 change: 1 addition & 0 deletions packages/effect/src/internal/hashSet.ts
Expand Up @@ -7,6 +7,7 @@ import { format, NodeInspectSymbol, toJSON } from "../Inspectable.js"
import { pipeArguments } from "../Pipeable.js"
import type { Predicate, Refinement } from "../Predicate.js"
import { hasProperty } from "../Predicate.js"
import type { NoInfer } from "../Types.js"
import * as HM from "./hashMap.js"

const HashSetSymbolKey = "effect/HashSet"
Expand Down
11 changes: 6 additions & 5 deletions packages/effect/src/internal/schedule.ts
Expand Up @@ -18,6 +18,7 @@ import type * as Schedule from "../Schedule.js"
import * as ScheduleDecision from "../ScheduleDecision.js"
import * as Interval from "../ScheduleInterval.js"
import * as Intervals from "../ScheduleIntervals.js"
import type * as Types from "../Types.js"
import * as internalCause from "./cause.js"
import * as effect from "./core-effect.js"
import * as core from "./core.js"
Expand Down Expand Up @@ -1902,7 +1903,7 @@ export const retry_combined: {
self: Effect.Effect<A, E, R>
) => Effect.Retry.Return<R, E, A, O>
<B, E, R1>(
policy: Schedule.Schedule<B, NoInfer<E>, R1>
policy: Schedule.Schedule<B, Types.NoInfer<E>, R1>
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R1 | R>
<A, E, R, O extends Effect.Retry.Options<E>>(
self: Effect.Effect<A, E, R>,
Expand Down Expand Up @@ -1948,13 +1949,13 @@ export const retry_combined: {
/** @internal */
export const retryOrElse_Effect = dual<
<A1, E, R1, A2, E2, R2>(
policy: Schedule.Schedule<A1, NoInfer<E>, R1>,
orElse: (e: NoInfer<E>, out: A1) => Effect.Effect<A2, E2, R2>
policy: Schedule.Schedule<A1, Types.NoInfer<E>, R1>,
orElse: (e: Types.NoInfer<E>, out: A1) => Effect.Effect<A2, E2, R2>
) => <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A | A2, E2, R | R1 | R2>,
<A, E, R, A1, R1, A2, E2, R2>(
self: Effect.Effect<A, E, R>,
policy: Schedule.Schedule<A1, NoInfer<E>, R1>,
orElse: (e: NoInfer<E>, out: A1) => Effect.Effect<A2, E2, R2>
policy: Schedule.Schedule<A1, Types.NoInfer<E>, R1>,
orElse: (e: Types.NoInfer<E>, out: A1) => Effect.Effect<A2, E2, R2>
) => Effect.Effect<A | A2, E2, R | R1 | R2>
>(3, (self, policy, orElse) =>
core.flatMap(
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/internal/stm/stm.ts
Expand Up @@ -12,7 +12,7 @@ import * as Option from "../../Option.js"
import type { Predicate, Refinement } from "../../Predicate.js"
import * as predicate from "../../Predicate.js"
import type * as STM from "../../STM.js"
import type { MergeRecord } from "../../Types.js"
import type { MergeRecord, NoInfer } from "../../Types.js"
import * as effectCore from "../core.js"
import * as core from "./core.js"
import * as Journal from "./stm/journal.js"
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/internal/stream.ts
Expand Up @@ -31,7 +31,7 @@ import * as HaltStrategy from "../StreamHaltStrategy.js"
import type * as Take from "../Take.js"
import type * as Tracer from "../Tracer.js"
import * as Tuple from "../Tuple.js"
import type { MergeRecord } from "../Types.js"
import type { MergeRecord, NoInfer } from "../Types.js"
import * as channel from "./channel.js"
import * as channelExecutor from "./channel/channelExecutor.js"
import * as MergeStrategy from "./channel/mergeStrategy.js"
Expand Down
1 change: 1 addition & 0 deletions packages/effect/src/internal/trie.ts
Expand Up @@ -7,6 +7,7 @@ import type * as Ordering from "../Ordering.js"
import { pipeArguments } from "../Pipeable.js"
import { hasProperty } from "../Predicate.js"
import type * as TR from "../Trie.js"
import type { NoInfer } from "../Types.js"

const TrieSymbolKey = "effect/Trie"

Expand Down

0 comments on commit 027418e

Please sign in to comment.