Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fun/examples/natural.ts>Nat

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
interface Nat
implements TypeClass<[U, V]>
import { type Nat } from "https://deno.land/x/fun@v2.0.0/examples/natural.ts";

Here is a definition of NaturalTransformation using fun substitution. For a deep understanding the wikipedia article is pretty good: https://en.wikipedia.org/wiki/Natural_transformation

However, while we are using category there here it's important to note that our choices for categories are small and our "Functors" are really Endofunctors (e.g. meaning that a Functor for Option maps from the Option category back to the Option category).

In a way you can think of NaturalTransformation as a Functor of Functors except that a Functor can be used with any morphism (function) where as a NaturalTransformation only maps from one specific category to another. This is like saying a NaturalTransformation will map Option to Either and not from ANY ADT to ANY other ADT (which it would have to if it were actually a Functor of Functors).

Type Parameters

U extends Kind
V extends Kind

Properties

transform: <A, B, C, D, E, J, K, L, M>(ua: $<U, [A, B, C], [D], [E]>) => $<V, [A, J, K], [L], [M]>