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

Fn

import type { Fn } from "https://raw.githubusercontent.com/baetheus/fun/main/fn.ts";

A Fn, also known as Reader or Environment, is a type over a unary javascript function. ie. (a: number) => string can be a Fn. 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) => string, with only one argument. The purposes of a Fn are many and varied, some common purposes are: computation, reading values from a shared environment, and sub-computations in a modified environment. In many ways Fn is a more powerful abstraction than State, and indeed the State monad in fun is exactly State<S, A> = Fn<[S], [A, S]>.

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

type Fn<D, A> = (d: D) => A;

§Type Parameters

§Type

§
(d: D) => A
[src]