Skip to main content
Module

x/fun/refinement.ts>and

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

Compose two refinements into a new refinement that returns true if both of the two input refinements return true.

Examples

Example 1

import type { Newtype } from "./newtype.ts";

import * as R from "./refinement.ts";
import { pipe } from "./fn.ts";

const isBig = (s: unknown): s is "Big" => s === "Big";
const refine = pipe(R.string, R.and(isBig));

const result1 = refine(null); // false
const result2 = refine("Hello"); // false
const result3 = refine("Big"); // false

Type Parameters

A
C extends A

Returns

<B extends A>(first: Refinement<A, B>) => Refinement<A, B & C>