Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fun/set.ts

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

ReadonlySet is a readonly product structure over objects and it operates on object equality for deduplication.

Variables

The canonical implementation of Applicable for ReadonlySet. It contains the methods wrap, ap, and map.

The canonical implementation of Filterable for ReadonlySet. It contains the methods filter, filterMap, partition, and partitionMap.

The canonical implementation of Flatmappable for ReadonlySet. It contains the methods wrap, ap, map, join, and flatmap.

The canonical implementation of Foldable for ReadonlySet. It contains the method fold.

The canonical implementation of Mappable for ReadonlySet. It contains the method map.

The canonical implementation of Traversable for ReadonlySet. It contains the methods map, fold, and traverse.

Functions

Given a ReadonlySet of functions A -> I and a ReadonlySet return a ReadonlySet by applying every function to every value A.

Given an instance of Comparable create a function that will take a ReadonlySet and return a new ReadonlySet where any members that are equal are deduplicated.

Copies an existing ReadonlySet into a new ReadonlySet, keeping references to the original members.

Given an insuance of Comparable create a function that takes a value A and returns a predicate over ReadonlySet the returns true if there are any members of the set that are equal to the value.

Given an instance of Comparable create a function that uakes a ReadonlySet and returns a predicate over a value A the returns true if the value is a member of the set. This is like elem but with the set and value parameters swapped.

Operates like Array.every, testing values in a ReadonlySet with a Predicate until either the predicate returns false for a value or all of the values have been tested as true. Shortcircuits on the first value that returns false. This is the dual of some.

Given a Refinement or Predicate over A and a ReadonlySet return a new ReadonlySet with only values for which the predicate or refinement return true.

Given a function A -> Option and a ReadonlySet return a ReadonlySet by applying the function to all values A. Any Nones will not enter the resultant set while Some values will. This is effectively filtering and mapping simultaneously.

Given a function A -> ReadonlySet and a ReadonlySet return a ReadonlySet created by applying the function to every value A and joining all the resulting ReadonlySets.

Reduce a ReadonlySet to a value O by iterating over the values of the set and collecting them with the reducing function.

Given an instance of Comparable create a Combinable<ReadonlySet> where combine creates a union of two ReadonlySets.

Given an instance of Comparable return Comparable<ReadonlySet>.

Given an instance of Comparable create a Combinable<ReadonlySet> where combine creates a union of two ReadonlySets.

Given an instance of Showable return an instance of Showable<ReadonlySet>.

Constructs a new ReadonlySet over type A that conuains no values.

Given an instance of Comparable return a function that takes two ReadonlySets and returns a new set with only the elements that exist in both sets.

Given an instance of Comparable return a function second => first => boolean that returns true when every member of first is in second.

Given a ReadonlySet of ReadonlySet, flatten all of the inner sets and return a ReadonlySet.

Given a function A -> I and a ReadonlySet return a new ReadonlySet where the values were created by passing each A through the A -> I function.

Given a Predicate or Refinement over A and a ReadonlySet return a Pair with a first value being a ReadonlySet of values that return true when applied to the refinement or predicate and a second value being a ReadonlySet of values that return false when applied to the predicate.

Given a function A -> Either<J, I> and a ReadonlySet return a Pair(ReadonlySet, ReadonlySet) by applying every value A in the set to the partitioning function.

Constructs a new ReadonlySet from an arbitrary number of values.

Operates like Array.some, testing values in a ReadonlySet with a Predicate until either the predicate returns true for a value or all of the values have been tested. Shortcircuits on the first value that returns true. This is the dual of every.

Traverse a ReadonlySet value by value, applying a function A -> V, then collecting all of the I values into ReadonlySet and returning V<ReadonlySet>. In concrete terms this can take ReadonlySet<Option> and turn it into Option<ReadonlySet> and other ADT inversions.

Given an instance of Comparable return a function that takes two ReadonlySets and merges them into a new ReadonlySet that contains all the elements from both sets.

Given a value A create a new ReadonlySet that contains that value.

Interfaces

Specifies ReadonlySet as a Higher Kinded Type, with covariant parameter A corresponding to the 0th index of any substitutions.

Type Aliases

Extract the inner type of a ReadonlySet