Options
All
  • Public
  • Public/Protected
  • All
Menu

Package either

@typed/either

A useful data-type for operations that have more than one outcome, especially failures.

Index

Type aliases

LEFT

LEFT: typeof LEFT

RIGHT

RIGHT: typeof RIGHT

UnpackArity2A

UnpackArity2A<A, B, C>: { (g: Arity1<B, C>, either: Either<A, B>): C; (g: Arity1<B, C>): (either: Either<A, B>) => C }

Type parameters

  • A

  • B

  • C

Type declaration

UnpackArity2B

UnpackArity2B<A, C>: { <B>(g: Arity1<B, C>, either: Either<A, B>): C; <B>(g: Arity1<B, C>): (either: Either<A, B>) => C }

Type parameters

  • A

  • C

Type declaration

    • Type parameters

      • B

      Parameters

      Returns C

    • Type parameters

      • B

      Parameters

      Returns (either: Either<A, B>) => C

        • Parameters

          Returns C

Variables

Const LEFT

LEFT: "@typed/Left" = '@typed/Left' as const

Const RIGHT

RIGHT: "@typed/Right" = '@typed/Right' as const

Const ap

ap: { <A, B, C>(fn: Either<A, (value: B) => C>, value: Either<A, B>): Either<A, C>; <A, B, C>(fn: Either<A, (value: B) => C>): (value: Either<A, B>) => Either<A, C> } = curry(__ap) as {<A, B, C>(fn: Either<A, (value: B) => C>, value: Either<A, B>): Either<A, C><A, B, C>(fn: Either<A, (value: B) => C>): (value: Either<A, B>) => Either<A, C>}

Applies the function contains in an Either to the value contained in a second Either.

name

ap<A, B, C>(fn: Either<A, (value: B) => C>, value: Either<A, B>): Either<A, C>

Type declaration

Const chain

chain: { <A, B, C>(f: (value: B) => Either<A, C>, either: Either<A, B>): Either<A, C>; <A, B, C>(f: (value: B) => Either<A, C>): (either: Either<A, B>) => Either<A, C> } = curry(__chain) as {<A, B, C>(f: (value: B) => Either<A, C>, either: Either<A, B>): Either<A, C><A, B, C>(f: (value: B) => Either<A, C>): (either: Either<A, B>) => Either<A, C>}

Returns a Either that is the result of calling f with the resolved value of another Either.

name

chain<A, B, C>(f: (value: B) => Either<A, C>, either: Either<A, B>): Either

Type declaration

Const chainLeft

chainLeft: { <A, B, C>(f: (value: A) => Either<C, B>, either: Either<A, B>): Either<C, B>; <A, B, C>(f: (value: A) => Either<C, B>): (either: Either<A, B>) => Either<C, B> } = curry(__chainLeft) as {<A, B, C>(f: (value: A) => Either<C, B>, either: Either<A, B>): Either<C, B><A, B, C>(f: (value: A) => Either<C, B>): (either: Either<A, B>) => Either<C, B>}

Returns a Either that is the result of calling f with the rejected value of another Either.

name

chainLeft<A, B, C>(f: (value: B) => Either<C, B>, either: Either<A, B>): Either

Type declaration

Const map

map: { <A, B, C>(f: (value: B) => C, either: Either<A, B>): Either<A, C>; <A, B, C>(f: (value: B) => C): (either: Either<A, B>) => Either<A, C> } = curry(__map) as {<A, B, C>(f: (value: B) => C, either: Either<A, B>): Either<A, C><A, B, C>(f: (value: B) => C): (either: Either<A, B>) => Either<A, C>}

Returns a Either that is the result of calling f with the resolved value of another Either.

name

map<A, B, C>(f: (value: B) => C, either: Either<A, B>): Either

Type declaration

Const mapLeft

mapLeft: { <A, B, C>(f: (value: A) => C, either: Either<A, B>): Either<C, B>; <A, B, C>(f: (value: A) => C): (either: Either<A, B>) => Either<C, B> } = curry(__mapLeft) as {<A, B, C>(f: (value: A) => C, either: Either<A, B>): Either<C, B><A, B, C>(f: (value: A) => C): (either: Either<A, B>) => Either<C, B>}

Returns a Either that is the result of calling f with the resolved value of another Either.

name

mapLeft<A, B, C>(f: (value: A) => C, either: Either<A, B>): Either

Type declaration

Const orElse

orElse: { <A, B>(value: A, validation: Either<B, A>): A; <A>(value: A): <B>(validation: Either<B, A>) => A } = curry(__orElse) as {<A, B>(value: A, validation: Either<B, A>): A<A>(value: A): <B>(validation: Either<B, A>) => A}

Type declaration

    • <A, B>(value: A, validation: Either<B, A>): A
    • <A>(value: A): <B>(validation: Either<B, A>) => A
    • Type parameters

      • A

      • B

      Parameters

      • value: A
      • validation: Either<B, A>

      Returns A

    • Type parameters

      • A

      Parameters

      • value: A

      Returns <B>(validation: Either<B, A>) => A

        • <B>(validation: Either<B, A>): A
        • Type parameters

          • B

          Parameters

          Returns A

Const unpack

unpack: { <A, B, C>(f: Arity1<A, C>, g: Arity1<B, C>, either: Either<A, B>): C; <A, B, C>(f: Arity1<A, C>, g: Arity1<B, C>): (either: Either<A, B>) => C; <A, B, C>(f: Arity1<A, C>): UnpackArity2A<A, B, C>; <A, C>(f: Arity1<A, C>): UnpackArity2B<A, C> } = curry(__unpack) as {<A, B, C>(f: Arity1<A, C>, g: Arity1<B, C>, either: Either<A, B>): C<A, B, C>(f: Arity1<A, C>, g: Arity1<B, C>): (either: Either<A, B>) => C<A, B, C>(f: Arity1<A, C>): UnpackArity2A<A, B, C><A, C>(f: Arity1<A, C>): UnpackArity2B<A, C>}

Extracts the value from an Either applying function f if the Either<A, B> is Left<A> or function g if Right<B>.

name

unpack<A, B, C>(f: Arity1<A, C>, g: Arity1<B, C>, either: Either<A, B>): C

Type declaration

Functions

fromLeft

  • fromLeft<A>(left: Left<A>): A

fromRight

  • fromRight<A>(right: Right<A>): A

isLeft

  • isLeft<A, B>(either: Either<A, B>): either is Left<A>

isRight

  • isRight<A, B>(either: Either<A, B>): either is Right<B>
  • Returns true if an Either<A, B> is type Right

    name

    isRight<A, B>(either: Either<A, B>): either is Right

    Type parameters

    • A

    • B

    Parameters

    Returns either is Right<B>

swap

tryCatch

  • tryCatch<A, B>(fn: IO<A>): Either<B, A>

Legend

  • Namespace
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Type alias
  • Type alias with type parameter
  • Interface
  • Interface with type parameter
  • Class
  • Class with type parameter
  • Enumeration

Generated using TypeDoc