Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/fun/mod.ts>async_either.alt

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
function async_either.alt
import { async_either } from "https://deno.land/x/fun@v2.0.0-alpha.6/mod.ts";
const { alt } = async_either;

Provide an alternative for a failed computation. Useful for implementing defaults.

import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
import * as TE from "./async_either.ts";
import * as E from "./either.ts";
import { pipe } from "./fn.ts";

const ta = pipe(
  TE.throwError(1),
  TE.alt(TE.of(2)),
)

assertEquals(await ta(), E.right(2))

Returns

<A, B>(ta: AsyncEither<B, A>) => AsyncEither<B | J, A | I>