This module defines a type of maps as balanced 2-3 trees, based on http://www.cs.princeton.edu/~dpw/courses/cos326-12/ass/2-3-trees.pdf
data Map k vMap k v represents maps from keys of type k to values of type v.
instance eqMap :: (Eq k, Eq v) => Eq (Map k v)instance showMap :: (Show k, Show v) => Show (Map k v)instance semigroupMap :: (Ord k) => Semigroup (Map k v)instance monoidMap :: (Ord k) => Monoid (Map k v)instance functorMap :: Functor (Map k)instance foldableMap :: Foldable (Map k)instance traversableMap :: (Ord k) => Traversable (Map k)showTree :: forall k v. (Show k, Show v) => Map k v -> StringRender a Map as a String
empty :: forall k v. Map k vAn empty map
isEmpty :: forall k v. Map k v -> BooleanTest if a map is empty
singleton :: forall k v. k -> v -> Map k vCreate a map with one key/value pair
checkValid :: forall k v. Map k v -> BooleanCheck whether the underlying tree satisfies the 2-3 invariant
This function is provided for internal use.
lookup :: forall k v. (Ord k) => k -> Map k v -> Maybe vLookup a value for the specified key
member :: forall k v. (Ord k) => k -> Map k v -> BooleanTest if a key is a member of a map
insert :: forall k v. (Ord k) => k -> v -> Map k v -> Map k vInsert a key/value pair into a map
delete :: forall k v. (Ord k) => k -> Map k v -> Map k vDelete a key and its corresponding value from a map
alter :: forall k v. (Ord k) => (Maybe v -> Maybe v) -> k -> Map k v -> Map k vInsert the value, delete a value, or update a value for a key in a map
update :: forall k v. (Ord k) => (v -> Maybe v) -> k -> Map k v -> Map k vUpdate or delete the value for a key in a map
toList :: forall k v. Map k v -> [Tuple k v]Convert a map to an array of key/value pairs
fromList :: forall k v. (Ord k) => [Tuple k v] -> Map k vCreate a map from an array of key/value pairs
fromListWith :: forall k v. (Ord k) => (v -> v -> v) -> [Tuple k v] -> Map k vCreate a map from an array of key/value pairs, using the specified function to combine values for duplicate keys.
keys :: forall k v. Map k v -> [k]Get an array of the keys contained in a map
values :: forall k v. Map k v -> [v]Get an array of the values contained in a map
unionWith :: forall k v. (Ord k) => (v -> v -> v) -> Map k v -> Map k v -> Map k vCompute the union of two maps, using the specified function to combine values for duplicate keys.
union :: forall k v. (Ord k) => Map k v -> Map k v -> Map k vCompute the union of two maps, preferring values from the first map in the case of duplicate keys
unions :: forall k v. (Ord k) => [Map k v] -> Map k vCompute the union of a collection of maps
map :: forall k a b. (a -> b) -> Map k a -> Map k bApply a function to the values in a map
size :: forall k v. Map k v -> NumberCalculate the number of key/value pairs in a map
This module defines a type of native Javascript maps which require the keys to be strings.
To maximize performance, Javascript objects are not wrapped, and some native code is used even when it's not necessary.
data StrMap :: * -> *StrMap a represents a map from Strings to values of type a.
thawST :: forall a h r. StrMap a -> Eff (st :: ST.ST h | r) (SM.STStrMap h a)Convert an immutable map into a mutable map
freezeST :: forall a h r. SM.STStrMap h a -> Eff (st :: ST.ST h | r) (StrMap a)Convert a mutable map into an immutable map
runST :: forall a r. (forall h. Eff (st :: ST.ST h | r) (SM.STStrMap h a)) -> Eff r (StrMap a)Freeze a mutable map, creating an immutable map. Use this function as you would use
Prelude.runST to freeze a mutable reference.
The rank-2 type prevents the map from escaping the scope of runST.
instance functorStrMap :: Functor StrMapfold :: forall a z. (z -> String -> a -> z) -> z -> StrMap a -> zFold the keys and values of a map
foldMap :: forall a m. (Monoid m) => (String -> a -> m) -> StrMap a -> mFold the keys and values of a map, accumulating values using
some Monoid.
foldM :: forall a m z. (Monad m) => (z -> String -> a -> m z) -> z -> StrMap a -> m zFold the keys and values of a map, accumulating values and effects in
some Monad.
instance foldableStrMap :: Foldable StrMapinstance traversableStrMap :: Traversable StrMapfoldMaybe :: forall a z. (z -> String -> a -> Maybe z) -> z -> StrMap a -> zFold the keys and values of a map.
This function allows the folding function to terminate the fold early,
using Maybe.
all :: forall a. (String -> a -> Boolean) -> StrMap a -> BooleanTest whether all key/value pairs in a StrMap satisfy a predicate.
instance eqStrMap :: (Eq a) => Eq (StrMap a)instance showStrMap :: (Show a) => Show (StrMap a)empty :: forall a. StrMap aAn empty map
isSubmap :: forall a. (Eq a) => StrMap a -> StrMap a -> BooleanTest whether one map contains all of the keys and values contained in another map
isEmpty :: forall a. StrMap a -> BooleanTest whether a map is empty
size :: forall a. StrMap a -> NumberCalculate the number of key/value pairs in a map
singleton :: forall a. String -> a -> StrMap aCreate a map with one key/value pair
lookup :: forall a. String -> StrMap a -> Maybe aLookup the value for a key in a map
member :: forall a. String -> StrMap a -> BooleanTest whether a String appears as a key in a map
insert :: forall a. String -> a -> StrMap a -> StrMap aInsert a key and value into a map
delete :: forall a. String -> StrMap a -> StrMap aDelete a key and value from a map
alter :: forall a. (Maybe a -> Maybe a) -> String -> StrMap a -> StrMap aInsert, remove or update a value for a key in a map
update :: forall a. (a -> Maybe a) -> String -> StrMap a -> StrMap aRemove or update a value for a key in a map
fromList :: forall a. [Tuple String a] -> StrMap aCreate a map from an array of key/value pairs
fromListWith :: forall a. (a -> a -> a) -> [Tuple String a] -> StrMap aCreate a map from an array of key/value pairs, using the specified function to combine values for duplicate keys.
toList :: forall a. StrMap a -> [Tuple String a]Convert a map into an array of key/value pairs
keys :: forall a. StrMap a -> [String]Get an array of the keys in a map
values :: forall a. StrMap a -> [a]Get an array of the values in a map
union :: forall a. StrMap a -> StrMap a -> StrMap aCompute the union of two maps, preferring the first map in the case of duplicate keys.
unions :: forall a. [StrMap a] -> StrMap aCompute the union of a collection of maps
map :: forall a b. (a -> b) -> StrMap a -> StrMap bMap a function over the values in a map
instance semigroupStrMap :: (Semigroup a) => Semigroup (StrMap a)instance monoidStrMap :: (Semigroup a) => Monoid (StrMap a)Helper functions for working with mutable maps using the ST effect.
This module can be used when performance is important and mutation is a local effect.
data STStrMap :: * -> * -> *A reference to a mutable map
The first type parameter represents the memory region which the map belongs to. The second type parameter defines the type of elements of the mutable array.
The runtime representation of a value of type STStrMap h a is the same as that of StrMap a, except that mutation is allowed.
new :: forall a h r. Eff (st :: ST h | r) (STStrMap h a)Create a new, empty mutable map
peek :: forall a h r. STStrMap h a -> String -> Eff (st :: ST h | r) aGet the value for a key in a mutable map
poke :: forall a h r. STStrMap h a -> String -> a -> Eff (st :: ST h | r) (STStrMap h a)Update the value for a key in a mutable map
delete :: forall a h r. STStrMap h a -> String -> Eff (st :: ST h | r) (STStrMap h a)Remove a key and the corresponding value from a mutable map
unsafeGet :: forall a h r. STStrMap h a -> Eff (st :: ST h | r) (StrMap a)Unsafely get the value for a key in a map.
This function does not check whether the key exists in the map.
unsafeIndex :: forall a. StrMap a -> String -> aUnsafely get the value for a key in a map.
This function does not check whether the key exists in the map.