Skip to main content
Module

x/fun/mod.ts>optic.nil

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

A preconstructed filter that focuses on the the non-null and non-undefined value of A | null | undefined.

Examples

Example 1

import * as O from "./optic.ts";
import { constNone } from "./option.ts";
import { pipe } from "./fn.ts";

type Input = { value?: string | null };

const value = pipe(O.id<Input>(), O.prop("value"), O.nil);

const result1 = pipe(value, O.view({})); // None
const result2 = pipe(value, O.view({ value: "Hello" })); // Some("Hello")

type

<U extends Tag, S, A>(first: Optic<U, S, A>) => Optic<Align<U, AffineTag>, S, NonNullable<A>>