Skip to main content
Module

x/fun/mod.ts>optics.second

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.second
import { optics } from "https://deno.land/x/fun@v2.0.0-alpha.12/mod.ts";
const { second } = optics;

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

Examples

Example 1

import * as O from "./optics.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>