Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/fun/option.ts>partition

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

Given a refinement or predicate, return a function that splits an Option into a Pair<Option, Option>. Due to the nature of the option type this will always return Pair<Some, None>, Pair<None, None>, or Pair<None, Some>.

Examples

Example 1

import * as O from "./option.ts";

const partition = O.partition((n: number) => n > 0);

const result1 = partition(O.some(1)); // [Some(1), None]
const result2 = partition(O.some(0)); // [None, Some(0)]
const result3 = partition(O.none); // [None, None]

Type Parameters

A
B extends A

Parameters

refinement: Refinement<A, B>