opvasger/comparable/2.0.0

Unavailable. Nobody can download this version any more, with elm or with the Lamdera compiler: github.com/opvasger/comparable is gone (deleted or private); Software Heritage not asked yet (this run's --swh-calls were used up); no fork with tag 2.0.0 found (60 same-name repos checked); no cached copy. Use another version.

Details

Comparable.Set

A set of unique values. The values can be any type.

Sets

type Set value

Represents a set of unique values.

Compare

equals : Set value -> Set value -> Bool

Determine if two sets contain the same values.

Build

empty : Set value

Create an empty set.

singleton : value -> Set value

Create a set with one value.

insert : Comparable value -> value -> Set value -> Set value

Insert a value into a set.

remove : Comparable value -> value -> Set value -> Set value

Remove a value from a set. If the value is not found, no changes are made.

Query

isEmpty : Set value -> Bool

Determine if a set is empty.

member : Comparable value -> value -> Set value -> Bool

Determine if a value is in a set.

size : Set value -> Int

Determine the number of elements in a set.

Combine

union : Comparable value -> Set value -> Set value -> Set value

Get the union of two sets. Keep all values.

intersect : Comparable value -> Set value -> Set value -> Set value

Get the intersection of two sets. Keeps values that appear in both sets.

diff : Comparable value -> Set value -> Set value -> Set value

Get the difference between the first set and the second. Keeps values that do not appear in the second set.

List

toList : Set value -> List value

Convert a set into a list, sorted from lowest to highest.

fromList : Comparable value -> List value -> Set value

Convert a list into a set, removing any duplicates.

Transform

map :
Comparable otherValue
-> (value -> otherValue)
-> Set value
-> Set otherValue

Map a function onto a set, creating a new set with no duplicates.

(value -> accumulator -> accumulator)
-> accumulator
-> Set value
-> accumulator

Fold over the values in a set, in compare from lowest to highest.

(value -> accumulator -> accumulator)
-> accumulator
-> Set value
-> accumulator

Fold over the values in a set, in compare from highest to lowest.

filter : Comparable value -> (value -> Bool) -> Set value -> Set value

Only keep elements that pass the given test.

Comparable value
-> (value -> Bool)
-> Set value
-> ( Set value, Set value )

Create two new sets. The first contains all the elements that passed the given test, and the second contains all the elements that did not.