Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

apply

import { apply } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/either.ts";

Apply a function wrapped in an Either to a value wrapped in an Either. If either is Left, the result is Left. If both are Right, the function is applied to the value.

@example
import * as E from "./either.ts";

const add = (a: number) => (b: number) => a + b;
const addEither = E.right(add);
const valueEither = E.right(5);

const result = E.apply(valueEither)(addEither);
// Right((b: number) => 5 + b)

const result2 = E.apply(E.left("error"))(addEither);
// Left("error")
function apply<A, B>(ua: Either<B, A>): <I, J>(ufai: Either<J, (a: A) => I>) => Either<B | J, I>;
§
apply<A, B>(ua: Either<B, A>): <I, J>(ufai: Either<J, (a: A) => I>) => Either<B | J, I>
[src]

§Type Parameters

§Parameters

§
ua: Either<B, A>
[src]

§Return Type

§
<I, J>(ufai: Either<J, (a: A) => I>) => Either<B | J, I>
[src]