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.Dict

A dictionary mapping unique keys to values. The keys can be any type.

Dictionaries

type Dict key value

A dictionary of keys and values.

Compare

equals : Dict key value -> Dict key value -> Bool

Determine if two dictionaries contain the same entries.

Build

empty : Dict key value

Create an empty dictionary.

singleton : key -> value -> Dict key value

Create a dictionary with one key-value pair.

insert : Comparable key -> key -> value -> Dict key value -> Dict key value

Insert a key-value pair into a dictionary. Replaces value when there is a collision.

Comparable key
-> key
-> (Maybe value -> Maybe value)
-> Dict key value
-> Dict key value

Update the value of a dictionary for a specific key with a given function.

remove : Comparable key -> key -> Dict key value -> Dict key value

Remove a key-value pair from a dictionary. If the key is not found, no changes are made.

Query

isEmpty : Dict key value -> Bool

Determine if a dictionary is empty.

member : Comparable key -> key -> Dict key value -> Bool

Determine if a key is in a dictionary.

get : Comparable key -> key -> Dict key value -> Maybe value

Get the value associated with a key.

size : Dict key value -> Int

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

List

keys : Dict key value -> List key

Get all of the keys in a dictionary, sorted from lowest to highest.

values : Dict key value -> List value

Get all of the values in a dictionary, in the compare of their keys.

toList : Dict key value -> List ( key, value )

Convert a dictionary into an association list of key-value pairs, sorted by keys.

fromList : Comparable key -> List ( key, value ) -> Dict key value

Convert an association list into a dictionary.

Transform

map : (key -> value -> otherValue) -> Dict key value -> Dict key otherValue

Apply a function to all values in a dictionary.

(key -> value -> accumulator -> accumulator)
-> accumulator
-> Dict key value
-> accumulator

Fold over the key-value pairs in a dictionary from lowest key to highest key.

(key -> value -> accumulator -> accumulator)
-> accumulator
-> Dict key value
-> accumulator

Fold over the key-value pairs in a dictionary from highest key to lowest key.

Comparable key
-> (key -> value -> Bool)
-> Dict key value
-> Dict key value

Keep only the key-value pairs that pass the given test.

Comparable key
-> (key -> value -> Bool)
-> Dict key value
-> ( Dict key value, Dict key value )

Partition a dictionary according to some test. The first dictionary contains all key-value pairs which passed the test, and the second contains the pairs that did not.

Combine

union : Comparable key -> Dict key value -> Dict key value -> Dict key value

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

intersect : Comparable key -> Dict key value -> Dict key value -> Dict key value

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

Comparable key
-> Dict key value
-> Dict key otherValue
-> Dict key value

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

Comparable key
-> (key -> value -> result -> result)
-> (key -> value -> otherValue -> result -> result)
-> (key -> otherValue -> result -> result)
-> Dict key value
-> Dict key otherValue
-> result
-> result

The most general way of combining two dictionaries. You provide three accumulators for when a given key appears:

  1. Only in the left dictionary.

  2. In both dictionaries.

  3. Only in the right dictionary. You then traverse all the keys from lowest to highest, building up whatever you want.