Skip to main content
Module

x/fun/mod.ts>optics.tree

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

A preconstructed traversal that focuses the values of a Tree.

Examples

Example 1

import type { Tree } from "./tree.ts";
import * as O from "./optics.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>