Skip to main content
Module

x/fun/mod.ts>fn_either.FnEither

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
type alias fn_either.FnEither
import { type fn_either } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { FnEither } = fn_either;

A FnEither, also known as ReaderEither, is a type over a variadic javascript function that returns an Either. ie. (a: number, b: string) => Either<Error, string> can be a FnEither. As an algebraic data type, the associated type class instances for Fn are limited to single variable inputs so they will look like (a: number) => Either<Error, string>, with only one argument. The purposes of a FnEither are many and varied, some common purposes are: failable computation, reading values from a shared environment, and sub-computations in a modified environment.

Currently, there is no implementation of Chain recursion or trampolining for FnEIther implemented, but it is likely to be a future feature. Once implemented Fn will gain some much needed stack safety.

definition: Fn<D, Either<B, A>>