Skip to main content
Module

x/fun/fn_either.ts>FnEither

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
type alias FnEither
import { type FnEither } from "https://deno.land/x/fun@v.2.0.0-alpha.11/fn_either.ts";

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>>