flix

0.54.0

Map

enum Map[k: Type, v: Type] with SendableSource
case Map(RedBlackTree[k, v])

The Map type.

A map is currently represented internally as a red-black tree.

Instances

instance CommutativeMonoid[Map[k, v]] with Order[k], CommutativeMonoid[v]Source
instance CommutativeSemiGroup[Map[k, v]] with Order[k], CommutativeSemiGroup[v]Source
instance Eq[Map[k, v]] with Eq[k], Eq[v]Source
instance Filterable[Map[k]] with Order[k]Source
instance Foldable[Map[k]]Source
instance FromJava[Map[k, v]] with Order[k]Source
instance Functor[Map[k]]Source
instance Hash[Map[k, v]] with Hash[k], Hash[v]Source
instance Indexable[Map[k, v]] with Order[k]Source
instance Iterable[Map[k, v]]Source
instance JoinLattice[Map[k, v]] with Order[k], Eq[v], JoinLattice[v]Source
instance LowerBound[Map[k, v]]Source
instance MeetLattice[Map[k, v]] with Order[k], Eq[v], MeetLattice[v]Source
instance Monoid[Map[k, v]] with Order[k], Monoid[v]Source
instance Order[Map[k, v]] with Order[k], Order[v]Source
instance PartialOrder[Map[k, v]] with Order[k], Eq[v]Source
instance SemiGroup[Map[k, v]] with Order[k], SemiGroup[v]Source
instance Sendable[Map[k, v]] with Sendable[k], Sendable[v]Source
instance ToJava[Map[k, v]] with Order[k]Source
instance ToString[Map[k, v]] with ToString[k], ToString[v]Source
instance Traversable[Map[k]]Source
instance UnorderedFoldable[Map[k]]Source
instance Witherable[Map[k]] with Order[k]Source

Definitions

def adjust(f: v -> v \ ef, k: k, m: Map[k, v]): Map[k, v] \ ef with Order[k] Source

Updates m with k => f(v) if k => v is in m.

Otherwise, returns m.

def adjustWithKey(f: k -> (v -> v \ ef), k: k, m: Map[k, v]): Map[k, v] \ ef with Order[k] Source

Updates m with k => f(k, v) if k => v is in m. Otherwise, returns m.

@ParallelWhenPure
def count(f: k -> (v -> Bool \ ef), m: Map[k, v]): Int32 \ ef Source

Returns the number of mappings k => v in m that satisfy the predicate f.

Purity reflective: Runs in parallel when given a pure function f.

def difference(m1: Map[k, v], m2: Map[k, v]): Map[k, v] with Order[k] Source

Returns the difference of m1 and m2, i.e. m1 - m2.

That is, returns the map m1 with the keys removed that are in m2.

def differenceWith(f: v -> (v -> Option[v] \ ef), m1: Map[k, v], m2: Map[k, v]): Map[k, v] \ ef with Order[k] Source

Returns the difference of m1 and m2, i.e. m1 - m2.

When a key k is in both m1 and m2, the associated values are passed to the merge function f. If f returns None the mapping with k is thrown away (proper set difference). If f returns Some(v) the mapping k => v is included in the result.

def differenceWithKey(f: k -> (v -> (v -> Option[v] \ ef)), m1: Map[k, v], m2: Map[k, v]): Map[k, v] \ ef with Order[k] Source

Returns the difference of m1 and m2, i.e. m1 - m2.

When a key k is in both m1 and m2, k and the associated values are passed to the merge function f. If f returns None the mapping with k is thrown away (proper set difference). If f returns Some(v) the mapping k => v is included in the result.

def empty(): Map[k, v] Source

Returns the empty map.

Map#{} is syntactic sugar for empty (Map#{} == empty()).

@ParallelWhenPure
def exists(f: k -> (v -> Bool \ ef), m: Map[k, v]): Bool \ ef Source

Returns true if and only if at least one mapping in m satisfies the predicate f.

Returns false if m is the empty map.

Purity reflective: Runs in parallel when given a pure function f.

def explode(m: Map[k, t[v]]): Set[(k, v)] \ Aef[t] with Foldable[t], Order[k], Order[v] Source

Returns the set of tuples (k, v) where v is a value in t and k => t.

def filter(f: v -> Bool \ ef, m: Map[k, v]): Map[k, v] \ ef with Order[k] Source

Returns a map of all mappings k => v in m where v satisfies the predicate f.

def filterMap(f: a -> Option[b] \ ef, m: Map[k, a]): Map[k, b] \ ef with Order[k] Source

Returns a map of all mappings k => v1 in m where applying the function f to v produces a Some(v1). Elements that produce None are discarded.

def filterMapWithKey(f: k -> (a -> Option[b] \ ef), m: Map[k, a]): Map[k, b] \ ef with Order[k] Source

Returns a map of all mappings k => v1 in m where applying the function f to (k, v) produces Some(v1). Elements that produce None are discarded.

def filterWithKey(f: k -> (v -> Bool \ ef), m: Map[k, v]): Map[k, v] \ ef with Order[k] Source

Returns a map of all mappings k => v in m where (k, v) satisfies the predicate f.

def find(f: k -> (v -> Bool \ ef), m: Map[k, v]): Option[(k, v)] \ ef Source

Alias for findLeft.

def findLeft(f: k -> (v -> Bool \ ef), m: Map[k, v]): Option[(k, v)] \ ef Source

Optionally returns the first mapping of m that satisfies the predicate f when searching from left to right.

def findRight(f: k -> (v -> Bool \ ef), m: Map[k, v]): Option[(k, v)] \ ef Source

Optionally returns the first mapping of m that satisfies the predicate f when searching from right to left.

def foldLeft(f: b -> (v -> b \ ef), s: b, m: Map[k, v]): b \ ef Source

Applies f to a start value s and all values in m going from left to right.

That is, the result is of the form: f(...f(f(s, v1), v2)..., vn).

def foldLeftWithKey(f: b -> (k -> (v -> b \ ef)), s: b, m: Map[k, v]): b \ ef Source

Applies f to a start value s and all key-value pairs in m going from left to right.

That is, the result is of the form: f(...f(f(s, k1, v1), k2, v2)..., vn).

def foldMap(f: v -> b \ ef, m: Map[k, v]): b \ ef with Monoid[b] Source

Returns the result of mapping each value and combining the results.

def foldMapWithKey(f: k -> (v -> b \ ef), m: Map[k, v]): b \ ef with Monoid[b] Source

Returns the result of mapping each key-value pair and combining the results.

def foldRight(f: v -> (b -> b \ ef), s: b, m: Map[k, v]): b \ ef Source

Applies f to a start value s and all values in m going from right to left.

That is, the result is of the form: f(v1, ...f(vn-1, f(vn, s))).

def foldRightWithCont(f: v -> ((Unit -> b \ ef) -> b \ ef), z: b, m: Map[k, v]): b \ ef Source

Applies f to a start value z and all values in m going from right to left.

That is, the result is of the form: f(v1, ...f(vn-1, f(vn, z))). A foldRightWithCont allows early termination by not calling the continuation.

def foldRightWithKey(f: k -> (v -> (b -> b \ ef)), s: b, m: Map[k, v]): b \ ef Source

Applies f to a start value s and all key-value pairs in m going from right to left.

That is, the result is of the form: f(k1, v1, ...f(kn-1, vn-1, f(kn, vn, s))).

def foldRightWithKeyCont(f: k -> (v -> ((Unit -> b \ ef) -> b \ ef)), z: b, m: Map[k, v]): b \ ef Source

Applies f to a start value z and all key-value pairs in m going from right to left.

That is, the result is of the form: f(k1, v1, ...f(kn-1, vn-1, f(kn, vn, z))). A foldRightWithKeyCont allows early termination by not calling the continuation.

def foldWithKey(f: b -> (k -> (v -> b \ ef)), s: b, m: Map[k, v]): b \ ef Source

Alias for foldLeftWithKey.

@ParallelWhenPure
def forAll(f: k -> (v -> Bool \ ef), m: Map[k, v]): Bool \ ef Source

Returns true if and only if all mappings in m satisfy the predicate f.

Returns true if m is the empty map.

Purity reflective: Runs in parallel when given a pure function f.

def forEach(f: k -> (v -> Unit \ ef), m: Map[k, v]): Unit \ ef Source

Applies f to every (key, value) of m.

def forEachWithIndex(f: Int32 -> (k -> (v -> Unit \ ef)), m: Map[k, v]): Unit \ ef Source

Applies f to tuple (index, key, value) formed of the keys and values of Map m and the index of the traversal.

def get(k: k, m: Map[k, v]): Option[v] with Order[k] Source

Returns Some(v) if k => v is in m.

Otherwise returns None.

def getWithDefault(k: k, d: v, m: Map[k, v]): v with Order[k] Source

Returns v if k => v is in m.

Otherwise, returns d.

def insert(k: k, v: v, m: Map[k, v]): Map[k, v] with Order[k] Source

Updates m with k => v.

def insertWith(f: v -> (v -> v \ ef), k: k, v: v, m: Map[k, v]): Map[k, v] \ ef with Order[k] Source

Updates m with k => f(v, v1) if k => v1 is in m.

Otherwise, updates m with k => v.

def insertWithKey(f: k -> (v -> (v -> v \ ef)), k: k, v: v, m: Map[k, v]): Map[k, v] \ ef with Order[k] Source

Updates m with k => f(k, v, v1) if k => v1 is in m.

Otherwise, updates m with k => v.

def intersection(m1: Map[k, v], m2: Map[k, v]): Map[k, v] with Order[k] Source

Returns the left-biased intersection of m1 and m2.

That is, key collisions are resolved by taking the mapping from m1.

def intersectionWith(f: v1 -> (v2 -> v3 \ ef), m1: Map[k, v1], m2: Map[k, v2]): Map[k, v3] \ ef with Order[k] Source

Returns the intersection of m1 and m2 where key collisions are resolved with the merge function f.

def intersectionWithKey(f: k -> (v1 -> (v2 -> v3 \ ef)), m1: Map[k, v1], m2: Map[k, v2]): Map[k, v3] \ ef with Order[k] Source

Returns the intersection of m1 and m2 where key collisions are resolved with the merge function f, taking both the key and values.

def invert(m: Map[k, v]): Map[v, Set[k]] with Order[k], Order[v] Source

Returns the inverse map of m.

That is, given a Map[k, v] returns a map Map[v, Set[k]] where every value is mapped to its key(s) in the original map.

def isEmpty(m: Map[k, v]): Bool Source

Returns true if and only if m is the empty map, i.e. Map(Nil).

def isProperSubmapOf(m1: Map[k, v], m2: Map[k, v]): Bool with Order[k], Eq[v] Source

Returns true if and only if all mappings in m1 occur in m2 and m1 != m2.

def isSubmapOf(m1: Map[k, v], m2: Map[k, v]): Bool with Order[k], Eq[v] Source

Returns true if and only if all mappings in m1 occur in m2.

def iterator(rc: Region[r], m: Map[k, v]): Iterator[(k, v), r, r] \ r Source

Returns an iterator over all key-value pairs in m.

def iteratorKeys(rc: Region[r], m: Map[k, v]): Iterator[k, r, r] \ r Source

Returns an iterator over keys in m.

def iteratorValues(rc: Region[r], m: Map[k, v]): Iterator[v, r, r] \ r Source

Returns an iterator over values in m.

def joinKeys(sep: String, m: Map[k, v]): String with ToString[k] Source

Returns the concatenation of the string representation of each key k in m with sep inserted between each element.

def joinValues(sep: String, m: Map[k, v]): String with ToString[v] Source

Returns the concatenation of the string representation of each value v in m with sep inserted between each element.

def joinWith(f: k -> (v -> String \ ef), sep: String, m: Map[k, v]): String \ ef Source

Returns the concatenation of the string representation of each key-value pair k => v in m according to f with sep inserted between each element.

def keysOf(m: Map[k, v]): Set[k] with Order[k] Source

Returns the keys of m.

@ParallelWhenPure
def map(f: v1 -> v2 \ ef, m: Map[k, v1]): Map[k, v2] \ ef Source

Returns a map with mappings k => f(v) for every k => v in m.

Purity reflective: Runs in parallel when given a pure function f.

@ParallelWhenPure
def mapWithKey(f: k -> (v1 -> v2 \ ef), m: Map[k, v1]): Map[k, v2] \ ef Source

Returns a map with mappings k => f(k, v) for every k => v in m.

Purity reflective: Runs in parallel when given a pure function f.

def maximumKey(m: Map[k, v]): Option[(k, v)] Source

Optionally finds k => v where k is the largest key according to the Order instance of k.

Returns None if m is empty.

@ParallelWhenPure
def maximumKeyBy(cmp: k -> (k -> Comparison \ ef), m: Map[k, v]): Option[(k, v)] \ ef Source

Optionally finds k => v where k is the largest key according to the given comparator cmp.

Returns None if m is empty.

Purity reflective: Runs in parallel when given a pure function cmp.

@Parallel
def maximumValue(m: Map[k, v]): Option[(k, v)] with Order[v] Source

Optionally finds k => v where v is the largest value.

Returns None if m is empty.

@ParallelWhenPure
def maximumValueBy(cmp: v -> (v -> Comparison \ ef), m: Map[k, v]): Option[(k, v)] \ ef Source

Optionally finds k => v where v is the largest value according to the given comparator cmp.

Returns None if m is empty.

Purity reflective: Runs in parallel when given a pure function cmp.

def memberOf(k: k, m: Map[k, v]): Bool with Order[k] Source

Returns true if and only if m contains the key k.

def minimumKey(m: Map[k, v]): Option[(k, v)] Source

Optionally finds k => v where k is the smallest key according to the Order instance of k.

Returns None if m is empty.

@ParallelWhenPure
def minimumKeyBy(cmp: k -> (k -> Comparison \ ef), m: Map[k, v]): Option[(k, v)] \ ef Source

Optionally finds k => v where k is the smallest key according to the given comparator cmp.

Returns None if m is empty.

Purity reflective: Runs in parallel when given a pure function cmp.

@Parallel
def minimumValue(m: Map[k, v]): Option[(k, v)] with Order[v] Source

Optionally finds k => v where v is the smallest value.

Returns None if m is empty.

@ParallelWhenPure
def minimumValueBy(cmp: v -> (v -> Comparison \ ef), m: Map[k, v]): Option[(k, v)] \ ef Source

Optionally finds k => v where v is the smallest value according to the given comparator cmp.

Returns None if m is empty.

Purity reflective: Runs in parallel when given a pure function cmp.

def nonEmpty(m: Map[k, v]): Bool Source

Returns true if and only if m is a non-empty map.

def rangeQuery(p: k -> Comparison \ ef, m: Map[k, v]): List[(k, v)] \ ef Source

Extracts a range of key-value pairs from the map m.

That is, the result is a list of all pairs (k, v) where p(k) returns Equal.

def rangeQueryWith(p: k -> Comparison \ ef1, f: k -> (v -> Unit \ ef2), m: Map[k, v]): Unit \ ef1 + ef2 Source

Applies f to all key-value pairs (k, v) from the map m where p(k) returns EqualTo.

def reduceLeft(f: v -> (v -> v \ ef), m: Map[k, v]): Option[v] \ ef Source

Applies f to all values in m going from left to right until a single value v is obtained. Returns Some(v).

That is, the result is of the form: Some(f(...f(f(v1, v2), v3)..., vn))

Returns None if m is the empty map.

def reduceLeftWithKey(f: k -> (v -> (k -> (v -> (k, v) \ ef))), m: Map[k, v]): Option[(k, v)] \ ef Source

Applies f to all mappings in m going from left to right until a single mapping (k, v) is obtained. Returns Some((k, v)).

That is, the result is of the form: Some(f(...f(f(k1, v1, k2, v2), k3, v3)..., kn, vn))

Returns None if m is the empty map.

def reduceRight(f: v -> (v -> v \ ef), m: Map[k, v]): Option[v] \ ef Source

Applies f to all values in m going from right to left until a single value v is obtained. Returns Some(v).

That is, the result is of the form: Some(f(v1, ...f(vn-2, f(vn-1, vn))...))

Returns None if m is the empty map.

def reduceRightWithKey(f: k -> (v -> (k -> (v -> (k, v) \ ef))), m: Map[k, v]): Option[(k, v)] \ ef Source

Applies f to all mappings in m going from right to left until a single mapping (k, v) is obtained. Returns Some((k, v)).

That is, the result is of the form: Some(f(k1, v1, ...f(kn-2, vn-2, f(kn-1, vn-1, kn, vn))...))

Returns None if m is the empty map.

def remove(k: k, m: Map[k, v]): Map[k, v] with Order[k] Source

Removes the mapping k from the map m.

def sequence(m: Map[k, m[v]]): m[Map[k, v]] with Applicative[m] Source

Returns the result of running all the actions in the map m.

def singleton(k: k, v: v): Map[k, v] with Order[k] Source

Returns the singleton map where key k is mapped to value v.

Map#{k => v} is syntactic sugar for singleton (Map#{k => v} = singleton(k, v)).

def size(m: Map[k, v]): Int32 Source

Returns the number of keys in m.

def sumKeys(m: Map[Int32, v]): Int32 Source

Returns the sum of all keys in the map m.

def sumValues(m: Map[k, Int32]): Int32 Source

Returns the sum of all values in the map m.

@ParallelWhenPure
def sumWith(f: k -> (v -> Int32 \ ef), m: Map[k, v]): Int32 \ ef Source

Returns the sum of all key-value pairs k => v in the map m according to the function f.

Purity reflective: Runs in parallel when given a pure function f.

def toArray(rc: Region[r], m: Map[k, v]): Array[(k, v), r] \ r Source

Returns the map m as an array.

def toChain(m: Map[a, b]): Chain[(a, b)] with Order[a] Source

Returns the map m as a chain of key-value pairs.

def toDelayList(m: Map[k, v]): DelayList[(k, v)] Source

Returns the map m as a DelayList of key-value pairs.

def toDelayMap(m: Map[k, v]): DelayMap[k, v] Source

Returns m as a DelayMap.

def toList(m: Map[k, v]): List[(k, v)] Source

Returns the map m as a list of key-value pairs.

def toMultiMap(m: Map[k, v]): MultiMap[k, v] with Order[k], Order[v] Source

Returns a MultiMap where key k is mapped to the singleton set containing v.

def toMutDeque(rc: Region[r], m: Map[k, v]): MutDeque[(k, v), r] \ r Source

Returns m as a MutDeque.

def toMutMap(rc: Region[r], m: Map[k, v]): MutMap[k, v, r] \ r Source

Returns m as a mutable map.

def toSet(m: Map[k, v]): Set[(k, v)] with Order[k], Order[v] Source

Returns the map m as a set of key-value pairs.

def toString(m: Map[k, v]): String with ToString[k], ToString[v] Source

Returns a string representation of the given map m.

def toVector(m: Map[k, v]): Vector[(k, v)] Source

Returns the map m as a vector.

def traverse(f: v1 -> m[v2] \ ef, m: Map[k, v1]): m[Map[k, v2]] \ ef with Applicative[m] Source

Returns the result of applying the applicative mapping function f to all the values of the map m.

def traverseWithKey(f: k -> (v1 -> m[v2] \ ef), m: Map[k, v1]): m[Map[k, v2]] \ ef with Applicative[m] Source

Returns the result of applying the applicative mapping function f to all the key-value pairs of the map m.

def unfold(f: s -> Option[(k, v, s)] \ ef, st: s): Map[k, v] \ ef with Order[k] Source

Build a map by applying f to the seed value st.

f should return Some(k,v,st1) to signal a new key-value pair k and v and a new seed value st1.

f should return None to signal the end of building the map.

def unfoldWithIter(next: Unit -> Option[(k, v)] \ ef): Map[k, v] \ ef with Order[k] Source

Build a map by applying the function next to (). next is expected to encapsulate a stateful resource such as a file handle that can be iterated.

next should return Some(k,v) to signal a new key-value pair k and v.

next should return None to signal the end of building the map.

def union(m1: Map[k, v], m2: Map[k, v]): Map[k, v] with Order[k] Source

Returns the left-biased union of m1 and m2.

That is, key collisions are resolved by taking the mapping from m1.

def unionWith(f: v -> (v -> v \ ef), m1: Map[k, v], m2: Map[k, v]): Map[k, v] \ ef with Order[k] Source

Returns the union of m1 and m2 where key collisions are resolved with the merge function f.

def unionWithKey(f: k -> (v -> (v -> v \ ef)), m1: Map[k, v], m2: Map[k, v]): Map[k, v] \ ef with Order[k] Source

Returns the union of m1 and m2 where key collisions are resolved with the merge function f, taking both the key and values.

def update(f: v -> Option[v] \ ef, k: k, m: Map[k, v]): Map[k, v] \ ef with Order[k] Source

Updates m with k => v1 if k => v is in m and f(v) = Some(v1). Otherwise, returns m.

def updateWithKey(f: k -> (v -> Option[v] \ ef), k: k, m: Map[k, v]): Map[k, v] \ ef with Order[k] Source

Updates m with k => v1 if k => v is in m and f(k, v) = Some(v1). Otherwise, returns m.

def valuesOf(m: Map[k, v]): List[v] Source

Returns the values of m.