A set of unique values. The elements can be any type that can be converted to an elm 'comparable'.
This is helpful if you have values that are really just a comparable underneath, but you want to keep them separate using the type system. For instance:
type Kilos
= Kilos Float
type Pounds
= Pounds FloatCreate a TSet with the empty function, which takes two converter functions as arguments.
It can be convenient to create a canonical empty TSet for a certain type:
emptyKiloSet =
TSet.empty
(\(Kilos n) -> n)
KilosThen to do the equivalent of Set.fromList:
TSet.insertList emptyKiloSet mykilolistInsert, remove, and query operations all take O(log n) time, just like Set.
Create an empty TSet. Requires two conversion functions: one from the key to comparable, and the other from comparable to key.
Remove a value from a set. If the value is not found, no changes are made.
Get the union of two sets. Keep all values.
Get the intersection of two sets. Keeps values that appear in both sets.
Get the difference between the first set and the second. Keeps values that do not appear in the second set.
Insert a list of values into a set.
Map a function onto a set, inserting into a second set.
Fold over the values in a set, in order from lowest to highest.
Fold over the values in a set, in order from highest to lowest.
Create a new set consisting only of elements which satisfy a predicate.
Represents a set of unique values. Create with the
emptyfunction.