Skip to main content Link Search Menu Expand Document (external link)

Either overview

A simple extension to the Effect Either module


Table of contents


Utils

catchTag

Recovers from the specified tagged error.

Signature

export declare const catchTag: <K extends E extends { readonly _tag: string } ? E["_tag"] : never, E, E1>(
  k: K,
  f: (e: Extract<E, { readonly _tag: K }>) => E1
) => <A>(self: Either.Either<A, E>) => Either.Either<A, E1 | Exclude<E, { _tag: K }>>

flatten

Flattens two eithers into a single one

Signature

export declare const flatten: <R, L1, L2>(self: Either.Either<Either.Either<R, L1>, L2>) => Either.Either<R, L1 | L2>

getRightWhenNoLeft

Gets the value of an Either that can never be a left

Signature

export declare const getRightWhenNoLeft: <A>(self: Either.Either<A, never>) => A

optionFromOptional

Same as Effect.optionFromOptional but for Either’s

Signature

export declare const optionFromOptional: <A, E>(
  self: Either.Either<A, E>
) => Either.Either<Option.Option<A>, Exclude<E, Cause.NoSuchElementException>>

traversePair

Transforms an either of a tuple into a tuple of either’s. Useful for instance for error management in reduce or mapAccum

Signature

export declare const traversePair: <A, B, L>(
  self: Either.Either<MTypes.ReadonlyPair<A, B>, L>
) => MTypes.Pair<Either.Either<A, L>, Either.Either<B, L>>