import { optic } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { index } = optic;
A composible combinator that focuses on a value in an array at the given index.
Examples
Example 1
Example 1
import * as O from "./optic.ts";
import { pipe } from "./fn.ts";
const second = pipe(
O.id<ReadonlyArray<string>>(),
O.index(1),
);
const result1 = pipe(second, O.view([])); // None
const result2 = pipe(second, O.view(["Hello", "World"])); // Some("World")