Skip to main content
Module

x/fun/optics.ts>first

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

A preconstructed composed lens that focuses on the First 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 numerator = pipe(O.id<Rational>(), O.first);

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

type

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