lamdera/containers/1.0.0

A Lamdera package. It is not on package.elm-lang.org: the Lamdera compiler provides it, from static.lamdera.com, so lamdera install works and elm install does not.

SeqSet

A set of unique values.

Sets

type SeqSet a

Represents a set of unique values. So (Set Int) is a set of integers and (Set String) is a set of strings.

Build

Create an empty set.

singleton : a -> SeqSet a

Create a set with one value.

insert : a -> SeqSet a -> SeqSet a

Insert a value into a set.

remove : a -> SeqSet a -> SeqSet a

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

Query

isEmpty : SeqSet a -> Bool

Determine if a set is empty.

member : a -> SeqSet a -> Bool

Determine if a value is in a set.

size : SeqSet a -> Int

Determine the number of elements in a set.

unorderedEquals : SeqSet k -> SeqSet k -> Bool

Check if two sets are equal regardless what order items were inserted. Note that this is not the same as writing set1 == set2. Insertion order matters when using ==.

set1 = SeqSet.fromList [ ( "A", 1 ), ( "B", 2 ) ]
set2 = SeqSet.fromList [ ( "B", 2 ), ( "A", 1 ) ]


SeqSet.unorderedEquals set1 set2 -- True
set1 == set2 -- False

Combine

union : SeqSet a -> SeqSet a -> SeqSet a

Get the union of two sets. Keep all values.

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

diff : SeqSet a -> SeqSet a -> SeqSet a

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

Lists

toList : SeqSet a -> List a

Convert a set into a list.

fromList : List a -> SeqSet a

Convert a list into a set, removing any duplicates.

Transform

map : (a -> b) -> SeqSet a -> SeqSet b

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

foldl : (a -> b -> b) -> b -> SeqSet a -> b

Fold over the values in a set.

foldr : (a -> b -> b) -> b -> SeqSet a -> b

Fold over the values in a set.

filter : (a -> Bool) -> SeqSet a -> SeqSet a

Create a new set consisting only of elements which satisfy a predicate.

partition : (a -> Bool) -> SeqSet a -> ( SeqSet a, SeqSet a )

Create two new sets; the first consisting of elements which satisfy a predicate, the second consisting of elements which do not.

Internal

encodeSet : (value -> Encoder) -> SeqSet value -> Encoder

The Lamdera compiler relies on this function, it is not intended to be used directly. Vendor this function in your own codebase if you want to use it, as the encoding can change without notice.

decodeSet : Decoder k -> Decoder (SeqSet k)

The Lamdera compiler relies on this function, it is not intended to be used directly. Vendor this function in your own codebase if you want to use it, as the encoding can change without notice.