y0hy0h/ordered-containers/1.0.0

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, verified). 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 1.0.0 is there; its commit b079cbc2a79a is from 2018-08-28 21:06 UTC, before the version was published (2018-08-28 21:07 UTC); every file Elm uses matches a copy in a Lamdera package cache from 2021-02-13, from before the change; elm.json is byte-identical to package.elm-lang.org's; the exposed modules match docs.json; the zip's SHA-1 is not the published one (GitHub's zip no longer comes out byte for byte the same), so the contents were checked instead.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

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

OrderedDict

A dictionary type that when iterated or converted to a list, the order of entries will be the same as the order they were inserted.

As it uses Dict under the hood, the keys can only be comparable types, which include Int, Float, Time, Char, String, and tuples or lists of comparable types.

Dictionaries

type OrderedDict comparable v

A type of Dict that is iterated by the order of insertion.

Build

empty : OrderedDict comparable v

Create an empty dictionary.

singleton : comparable -> v -> OrderedDict comparable v

Create a dictionary with one key-value pair.

comparable
-> v
-> OrderedDict comparable v
-> OrderedDict comparable v

Insert a key-value pair into a dictionary. Replace the value if the key already exists.

comparable
-> (Maybe v -> Maybe v)
-> OrderedDict comparable v
-> OrderedDict comparable v

Update the value of a specific key with an updater function.

Since the key may not exist before or after the update, the updater function takes a Maybe v and returns a Maybe v.

remove : comparable -> OrderedDict comparable v -> OrderedDict comparable v

Remove a key-value pair from a dictionary. If the key doesn't exist, no changes are made.

Query

isEmpty : OrderedDict comparable v -> Bool

Check if a dictionary is empty.

member : comparable -> OrderedDict comparable v -> Bool

Check if a key is in a dictionary.

get : comparable -> OrderedDict comparable v -> Maybe v

Get the value associated with a key. Return Nothing if the key is not found.

size : OrderedDict comparable v -> Int

Get the number of key-value pairs in the dictionary.

Lists

keys : OrderedDict comparable v -> List comparable

Get all of the keys in a dictionary, in insertion order.

values : OrderedDict comparable v -> List v

Get all of the values in a dictionary, in insertion order.

toList : OrderedDict comparable v -> List ( comparable, v )

Convert a dictionary into an association list of key-value pairs, in insertion order.

fromList : List ( comparable, v ) -> OrderedDict comparable v

Convert an association list into a dictionary.

Transform

map :
(comparable -> a -> b)
-> OrderedDict comparable a
-> OrderedDict comparable b

Apply a function to all values in a dictionary.

foldl : (comparable -> v -> b -> b) -> b -> OrderedDict comparable v -> b

Fold the key-value pairs in a dictionary, in insertion order.

foldr : (comparable -> v -> b -> b) -> b -> OrderedDict comparable v -> b

Fold the key-value pairs in a dictionary, in reverse insertion order.

(comparable -> v -> Bool)
-> OrderedDict comparable v
-> OrderedDict comparable v

Return a new OrderedDict that only contains entries that satisfy a predicate.

(comparable -> v -> Bool)
-> OrderedDict comparable v
-> ( OrderedDict comparable v, OrderedDict comparable v )

Split a OrderedDict to a tuple of OrderedDict. The first contains all entries that satisfy the predicate, and the second contains the rest.

Combine

OrderedDict comparable v
-> OrderedDict comparable v
-> OrderedDict comparable v

Combine two dictionaries. If there is a collision, preference is given to the first dictionary.

union (singleton "x" 1) (singleton "x" 2) == singleton "x" 1
OrderedDict comparable v
-> OrderedDict comparable v
-> OrderedDict comparable v

Keep a key-value pair when its key appears in the second dictionary. Preference is given to values in the first dictionary.

OrderedDict comparable v
-> OrderedDict comparable v
-> OrderedDict comparable v

Keep a key-value pair when its key does not appear in the second dictionary.