Skip to main content
Module

x/fun/optic.ts>second

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

A preconstructed composed lens that focuses on the Second value of a Pair.

Examples

Example 1

import * as O from "./optic.ts";
import * as P from "./pair.ts";
import { pipe } from "./fn.ts";

// Pair<numerator, denominator>
type Rational = P.Pair<number, number>

const denominator = pipe(O.id<Rational>(), O.first);

const result = pipe(denominator, O.view(P.pair(1, 2))); // 2

type

<U extends Tag, S, B, A>(optic: Optic<U, S, Pair<A, B>>) => Optic<Align<U, LensTag>, S, B>