Skip to main content
Module

x/fun/optics.ts>some

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

A preconstructed composed prism that focuses on the Some value of an Option.

Examples

Example 1

import * as O from "./optics.ts";
import { Option, some, none } from "./option.ts";
import { pipe } from "./fn.ts";

type Person = { name: string, talent: Option<string> };
type People = readonly Person[]

const talent = pipe(O.id<People>(), O.array, O.prop("talent"), O.some);

const brandon: Person = { name: "Brandon", talent: none };
const emily: Person = { name: "Emily", talent: some("Knitting") };

const result = pipe(talent, O.view([brandon, emily])); // ["Knitting"];

type

<U extends Tag, S, A>(optic: Optic<U, S, Option<A>>) => Optic<Align<U, AffineTag>, S, A>