Skip to main content
Module

x/fun/mod.ts>fn_either.wrap

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

An alias for right. Creates a FnEither from a value. The created FnEither does not require any arguments, but can widen when used in a flatmap.

Examples

Example 1

import * as FE from "./fn_either.ts";
import { pipe } from "./fn.ts";

const computation = pipe(
  FE.id<number>(), // Ask for a number
  FE.map(n => n + 1), // Add one
  FE.flatmap(_ => FE.wrap("Hello")), // Forget about the number
);

const result = computation(1); // Right("Hello")

Type Parameters

A
optional
D = unknown
optional
B = never