y0hy0h/ordered-containers/2.0.2

NOTE: the latest version is 2.0.3

Renamed to j-maas/ordered-containers. That is where the repository lives now. It has not been published as a package under the new name.

Versions published as y0hy0h/ordered-containers still install under that name. 5 versions of 5 come from the new location (see their notes).

Rerouted (renamed, needs approval). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/j-maas/ordered-containers.

What we checked: The repo moved to github.com/j-maas/ordered-containers and tag 2.0.2 is there; its commit 5b1eeb1740aa is from 2021-05-12 17:19 UTC, before the version was published (2021-05-12 17:20 UTC); elm.json differs from package.elm-lang.org's; the exposed modules match docs.json; the zip's SHA-1 is not the published one and nothing else confirms its contents.

We could not verify this copy against what was published, so the Lamdera compiler asks before using it (y/n). Without a terminal, as in CI, it stops with an error unless approved:

  • lamdera make --auto-approve-package-rerouting approves rerouted versions for that run,
  • LAMDERA_AUTO_APPROVE_PACKAGE_REROUTING=1 does the same for every run in that environment,
  • LAMDERA_CACHE=off skips the Lamdera package server altogether: packages come from package.elm-lang.org and GitHub only, as with elm, and a rerouted version then fails to download.

Details · package.elm-lang.org's zip: https://github.com/y0hy0h/ordered-containers/zipball/2.0.2/

OrderedSet

A set of unique values that remembers their insertion order. The values can be any comparable type. This includes Int, Float, Time, Char, String, and tuples or lists of comparable types.

The insertion order is reflected in the functions under "Conversions" and "Transform". The list order and the iteration order will be the order of insertion.

The API mirrors the core Set's API, with exception for the functions listed there under "Combine", because these functions do not have an obvious way to handle the order between the combined sets.

Sets

type OrderedSet comparable

Represents a set of unique values that remembers insertion order.

Build

empty : OrderedSet comparable

Create an empty set.

singleton : comparable -> OrderedSet comparable

Create a set with one value.

insert : comparable -> OrderedSet comparable -> OrderedSet comparable

Insert a value into a set. If the key already exists, the old value will be forgotten and the new value will be inserted at the end.

import OrderedSet


OrderedSet.empty
    |> OrderedSet.insert 1
    |> OrderedSet.insert 2
    |> OrderedSet.insert 1
    |> OrderedSet.toList
--> [ 2, 1 ]
remove : comparable -> OrderedSet comparable -> OrderedSet comparable

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

Query

isEmpty : OrderedSet comparable -> Bool

Determine if a set is empty.

member : comparable -> OrderedSet comparable -> Bool

Determine if a value is in a set.

size : OrderedSet comparable -> Int

Determine the number of elements in a set.

Conversions

toList : OrderedSet comparable -> List comparable

Convert a set into a list in insertion order.

fromList : List comparable -> OrderedSet comparable

Convert a list into a set, removing any duplicates.

toSet : OrderedSet comparable -> Set comparable

Convert an ordered set into a regular Set.

Transform

map :
(comparable -> comparable2)
-> OrderedSet comparable
-> OrderedSet comparable2

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

foldl : (comparable -> b -> b) -> b -> OrderedSet comparable -> b

Fold over the values in a set, in insertion order.

foldr : (comparable -> b -> b) -> b -> OrderedSet comparable -> b

Fold over the values in a set, in reverse insertion order.

(comparable -> Bool)
-> OrderedSet comparable
-> OrderedSet comparable

Only keep elements that pass the given test.

(comparable -> Bool)
-> OrderedSet comparable
-> ( OrderedSet comparable, OrderedSet comparable )

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.

The order will be preserved in these new sets in the sense that elements that are inserted after each other will remain ordered after each other.