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

x/fun/optic.ts>tree

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

A preconstructed traversal that focuses the values of a Tree.

Examples

Example 1

import type { Tree } from "./tree.ts";
import * as O from "./optic.ts";
import * as T from "./tree.ts";
import { pipe } from "./fn.ts";

const result = pipe(
  O.id<Tree<number>>(),
  O.tree,
  O.view(T.tree(1, [T.tree(2, [T.tree(3)])])),
); // [1, 2, 3]

type

<U extends Tag, S, A>(first: Optic<U, S, Tree<A>>) => Optic<Align<U, FoldTag>, S, A>