Skip to main content
Module

x/fun/option.ts>apply

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

Apply a value A wrapped in an option to a function (a: A) => I wrapped in an Option. If either the wrapped value or the wrapped function are None then the result is None, if they are both Some then the result is Some.

Examples

Example 1

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

const result1 = pipe(
  O.some((n: number) => n + 1),
  O.apply(O.some(1)),
); // Some(2)
const result2 = pipe(
  O.some((n: number) => n + 1),
  O.apply(O.none),
); // None

Returns

<I>(ufai: Option<(a: A) => I>) => Option<I>