Skip to main content
Module

x/fun/mod.ts>optics.array

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.array
import { optics } from "https://deno.land/x/fun@v.2.0.0-alpha.11/mod.ts";
const { array } = optics;

A preconstructed traversal that focuses the values of a ReadonlyArray.

Examples

Example 1

import * as O from "./optics.ts";
import { pipe } from "./fn.ts";

const result = pipe(
  O.id<ReadonlyArray<number>>(),
  O.array,
  O.filter(n => n % 2 === 0),
  O.view([1, 2, 3]),
); // [2]

type

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