import { fromPredicate } from "https://deno.land/x/fun@v2.0.0/fn_either.ts";
Create a FnEither from a Predicate or a Refinement. If the Predicate or Refinement returns true then the FnEither returns Right, otherwise it returns Left.
Examples
Example 1
Example 1
import * as FE from "./fn_either.ts";
import { pipe } from "./fn.ts";
const isPositive = (n: number) => n > 0;
const computation = FE.fromPredicate(isPositive);
const result1 = computation(0); // Left(0)
const result2 = computation(1); // Right(1)
Type Parameters
B extends A
Parameters
refinement: Refinement<A, B>