Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Usage

import * as fun from "https://raw.githubusercontent.com/baetheus/fun/main/set.ts";

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

§Variables

ApplicableSet

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

bind
bindTo
FilterableSet

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

FlatmappableSet

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

FoldableSet

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

MappableSet

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

tap
TraversableSet

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

WrappableSet

§Functions

apply

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

compact

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.

copy

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

elem

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.

elemOf

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.

every

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.

filter

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.

filterMap

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.

flatmap

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.

fold

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

getCombinableSet

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

getComparableSet

Given an instance of Comparable return Comparable<ReadonlySet>.

getInitializableSet

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

getShowableSet

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

init

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

intersection

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.

isSubset

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

join

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

map

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.

partition

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.

partitionMap

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.

set

Constructs a new ReadonlySet from an arbitrary number of values.

some

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

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.

union

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.

wrap

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

§Interfaces

KindReadonlySet

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

§Type Aliases

TypeOf

Extract the inner type of a ReadonlySet