Skip to content

Commit

Permalink
fix(types): reorder generic type parameters in Left and Right usage
Browse files Browse the repository at this point in the history
  • Loading branch information
venusvavadiya committed Sep 21, 2024
1 parent c33d982 commit 7100817
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions packages/effect/src/Micro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,14 @@ export declare namespace MicroExit {
* @experimental
* @category MicroExit
*/
export type Success<A, E = never> = Either.Right<MicroCause<E>, A>
export type Success<A, E = never> = Either.Right<A, MicroCause<E>>

/**
* @since 3.4.6
* @experimental
* @category MicroExit
*/
export type Failure<A, E = never> = Either.Left<MicroCause<E>, A>
export type Failure<A, E = never> = Either.Left<A, MicroCause<E>>
}

/**
Expand Down Expand Up @@ -456,23 +456,23 @@ export const exitIsFailure: <A, E>(self: MicroExit<A, E>) => self is MicroExit.F
* @experimental
* @category MicroExit
*/
export const exitIsInterrupt = <A, E>(self: MicroExit<A, E>): self is Either.Left<MicroCause.Interrupt, A> =>
export const exitIsInterrupt = <A, E>(self: MicroExit<A, E>): self is Either.Left<A, MicroCause.Interrupt> =>
exitIsFailure(self) && self.left._tag === "Interrupt"

/**
* @since 3.4.6
* @experimental
* @category MicroExit
*/
export const exitIsFail = <A, E>(self: MicroExit<A, E>): self is Either.Left<MicroCause.Fail<E>, A> =>
export const exitIsFail = <A, E>(self: MicroExit<A, E>): self is Either.Left<A, MicroCause.Fail<E>> =>
exitIsFailure(self) && self.left._tag === "Fail"

/**
* @since 3.4.6
* @experimental
* @category MicroExit
*/
export const exitIsDie = <A, E>(self: MicroExit<A, E>): self is Either.Left<MicroCause.Die, A> =>
export const exitIsDie = <A, E>(self: MicroExit<A, E>): self is Either.Left<A, MicroCause.Die> =>
exitIsFailure(self) && self.left._tag === "Die"

/**
Expand Down
16 changes: 8 additions & 8 deletions packages/effect/src/internal/either.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ const CommonProto = {
[TypeId]: {
_R: (_: never) => _
},
[NodeInspectSymbol]<L, R>(this: Either.Either<R, L>) {
[NodeInspectSymbol]<R, L>(this: Either.Either<R, L>) {
return this.toJSON()
},
toString<L, R>(this: Either.Left<L, R>) {
toString<R, L>(this: Either.Left<R, L>) {
return format(this.toJSON())
}
}

const RightProto = Object.assign(Object.create(CommonProto), {
_tag: "Right",
_op: "Right",
[Equal.symbol]<L, R>(this: Either.Right<L, R>, that: unknown): boolean {
[Equal.symbol]<R, L>(this: Either.Right<R, L>, that: unknown): boolean {
return isEither(that) && isRight(that) && Equal.equals(this.right, that.right)
},
[Hash.symbol]<L, R>(this: Either.Right<L, R>) {
[Hash.symbol]<R, L>(this: Either.Right<R, L>) {
return Hash.combine(Hash.hash(this._tag))(Hash.hash(this.right))
},
toJSON<L, R>(this: Either.Right<L, R>) {
toJSON<R, L>(this: Either.Right<R, L>) {
return {
_id: "Either",
_tag: this._tag,
Expand All @@ -51,13 +51,13 @@ const RightProto = Object.assign(Object.create(CommonProto), {
const LeftProto = Object.assign(Object.create(CommonProto), {
_tag: "Left",
_op: "Left",
[Equal.symbol]<L, R>(this: Either.Left<L, R>, that: unknown): boolean {
[Equal.symbol]<R, L>(this: Either.Left<R, L>, that: unknown): boolean {
return isEither(that) && isLeft(that) && Equal.equals(this.left, that.left)
},
[Hash.symbol]<L, R>(this: Either.Left<L, R>) {
[Hash.symbol]<R, L>(this: Either.Left<R, L>) {
return Hash.combine(Hash.hash(this._tag))(Hash.hash(this.left))
},
toJSON<E, A>(this: Either.Left<E, A>) {
toJSON<A, E>(this: Either.Left<A, E>) {
return {
_id: "Either",
_tag: this._tag,
Expand Down
2 changes: 1 addition & 1 deletion packages/platform/src/Cookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ export const setAll: {
for (const [name, value, options] of cookies) {
const either = makeCookie(name, value, options)
if (Either.isLeft(either)) {
return either as Either.Left<CookiesError, never>
return either as Either.Left<never, CookiesError>
}
record[name] = either.right
}
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/benchmark/TreeFormatter.formatIssueSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const schema = S.Struct({
const decodeUnknownEither = S.decodeUnknownEither(schema)
const input = { a: { b: { c: "" } } }
const result = decodeUnknownEither(input)
const issue = (result as any as Either.Left<ParseResult.ParseError, unknown>).left.issue
const issue = (result as any as Either.Left<unknown, ParseResult.ParseError>).left.issue

// console.log(issue)

Expand Down

0 comments on commit 7100817

Please sign in to comment.