temochka / enclojure / Enclojure.ValueMap

All Enclojure maps are backed by ValueMap io type. This namespace provides functions for working with this type.

Creating


type alias ValueMap io =
Enclojure.ValueKeyMap.ValueKeyMap io (Enclojure.Located.Located (Enclojure.Common.Value io))

Represents a map of values to located values. Operation complexity depends on the type of the key. For keywords, symbols, strings, floats, and integers, the complexity of insert/remove operations is logarithmic. For other value types, the complexity ranges from linear or worse, depending on the type of key values.


type alias ValueMapEntry io =
Enclojure.ValueKeyMap.ValueKeyMapEntry io (Enclojure.Located.Located (Enclojure.Common.Value io))

Represents a map entry.

empty : ValueMap io

Returns an empty map.

fromList : List (ValueMapEntry io) -> ValueMap io

Creates a map from a given list of map entries.

Accessing values

get : Enclojure.Common.Value io -> ValueMap io -> Maybe (Enclojure.Located.Located (Enclojure.Common.Value io))

Returns the located value at a given key in the map if present.

keys : ValueMap io -> List (Enclojure.Common.Value io)

Returns the list of map keys.

values : ValueMap io -> List (Enclojure.Common.Value io)

Returns the list of map values without their source code locations.

toList : ValueMap io -> List (ValueMapEntry io)

Transforms a given map into a list of map entries.

Modifying

foldl : (Enclojure.Common.Value io -> Enclojure.Located.Located (Enclojure.Common.Value io) -> a -> a) -> a -> ValueMap io -> a

Folds a given map from left to right using a function that accepts the key, the located value, and the accumulator, and is called for each entry in the map.

insert : Enclojure.Common.Value io -> Enclojure.Located.Located (Enclojure.Common.Value io) -> ValueMap io -> ValueMap io

Inserts a located value specified by the second argument to the key specified by the first argument.

map : (ValueMapEntry io -> ValueMapEntry io) -> ValueMap io -> ValueMap io

Applies a function to every mapEntry in the map.

remove : Enclojure.Common.Value io -> ValueMap io -> ValueMap io

Removes the value at a given key from the map.

Predicates

isEmpty : ValueMap io -> Basics.Bool

Returns True if the map is empty.

member : Enclojure.Common.Value io -> ValueMap io -> Basics.Bool

Returns True if the map has a value at a given key.