h&RB,       ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~                                                                                                                                                                                                                                                                                         ,:(c) Clark Gaebel 2012 (c) Johan Tibel 2012 BSD-stylelibraries@haskell.orgportableSafe9 strict-containers0Return a word where only the highest bit is set.  (c) David Feuer 2016 BSD-stylelibraries@haskell.orgportable Safe-Inferred3strict-containersCreate an empty bit queue builder. This is represented as a single guard bit in the most significant position.strict-containersEnqueue a bit. This works by shifting the queue right one bit, then setting the most significant bit as requested.strict-containersConvert a bit queue builder to a bit queue. This shifts in a new guard bit on the left, and shifts right until the old guard bit falls off.strict-containers3Dequeue an element, or discover the queue is empty.strict-containersConvert a bit queue to a list of bits by unconsing. This is used to test that the queue functions properly.   Safe-Inferredd strict-containersCoerce the second argument of a function. Conceptually, can be thought of as:  (f .^# g) x y = f x (g y) :However it is most useful when coercing the arguments to  : ) foldl f b . fmap g = foldl (f .^# g) b   8 9  Safe-Inferred . strict-containersChecks if two pointers are equal. Yes means yes; no means maybe. The values should be forced to at least WHNF before comparison to get moderately reliable results. strict-containersChecks if two pointers are equal, without requiring them to have the same type. The values should be forced to at least WHNF before comparison to get moderately reliable results.  4 4  Safe-Inferred h! Safe-Inferred  Safe!`strict-containers'The same as a regular Haskell pair, but  (x :*: _|_) = (_|_ :*: y) = _|_ strict-containers)Convert a strict pair to a standard pair.1 Safe 1" strict-containersThe constraint Whoops s is unsatisfiable for every   s$. Trying to use a function with a Whoops s constraint will lead to a pretty type error explaining how to fix the problem.Example oldFunction :: Whoops "oldFunction is gone now. Use newFunction." => Int -> IntMap a -> IntMap a    Safe-Inferred),strict-containersCreate a new mutable array of specified size, in the specified state thread, with each element containing the specified initial value..strict-containersWhen   is available, the returned array is the same as the array given, as it is shrunk in place. Otherwise a copy is made.;strict-containersUnsafely copy the elements of an array. Array bounds are not checked.<strict-containersUnsafely copy the elements of an array. Array bounds are not checked.=strict-containersCreate a new array of the n first elements of mary.>strict-containersO(n) Insert an element at the given position in this array, increasing its size by one.?strict-containersO(n) Insert an element at the given position in this array, increasing its size by one.@strict-containersO(n)8 Update the element at the given position in this array. strict-containersO(n)8 Update the element at the given position in this array.Astrict-containersO(n) Update the element at the given positio in this array, by applying a function to it. Evaluates the element to WHNF before inserting it into the array.Bstrict-containersO(1) Update the element at the given position in this array, without copying.Hstrict-containers=Verifies that a predicate holds for all elements of an array.Jstrict-containersO(n) Delete an element at the given position in this array, decreasing its size by one. strict-containersO(n) Delete an element at the given position in this array, decreasing its size by one.Lstrict-containersStrict version of K.Rstrict-containersSstrict-containers0"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQ0%&'"#$,-/012*+34576@AB>?J)=89(:;u strict-containers  values correspond to the level of the tree that we're currently operating at. At the root level the   is 0!. For the subsequent levels the   values are , 2* etc.,Valid values are non-negative and less than bitSize (0 :: Word).\strict-containersA bitmap as contained by a ` node, or a  corresponding to a b node.Only the lower  1 bits are used. The remaining bits must be zeros.]strict-containers?This type is used to store the hash of a key, as produced with f.^strict-containersA map from keys to values. A map cannot contain duplicate keys; each key can map to at most one value.fstrict-containers8A set of values. A set cannot contain duplicate values.Convenience function. Compute a hash value for the given value. strict-containersHelper to get ds and c s as a list. strict-containersHelper function to detect ds and cs.istrict-containersO(1) Construct an empty map.jstrict-containersO(1)' Construct a map with a single element.kstrict-containersO(1) Return   if this map is empty,   otherwise.lstrict-containersO(n)5 Return the number of key-value mappings in this map.mstrict-containers O(\log n) Return  . if the specified key is present in the map,   otherwise.nstrict-containers O(\log n)< Return the value to which the specified key is mapped, or  - if this map contains no mapping for the key.ostrict-containerslookup' is a version of lookup that takes the hash separately. It is used to implement alterF.q strict-containers O(\log n)< Return the value to which the specified key is mapped, or  - if this map contains no mapping for the key.This is a flipped version of n.r strict-containers O(\log n) Return the value to which the specified key is mapped, or the default value if this map contains no mapping for the key.sstrict-containers O(\log n) Return the value to which the specified key is mapped, or the default value if this map contains no mapping for the key.DEPRECATED: lookupDefault is deprecated as of version 0.2.11, replaced by r.tstrict-containers O(\log n)? Return the value to which the specified key is mapped. Calls  - if this map contains no mapping for the key.ustrict-containers Create a c value with two d values.vstrict-containers Create a ` or b node.wstrict-containers O(\log n) Associate the specified value with the specified key in this map. If this map previously contained a mapping for the key, the old value is replaced.{strict-containers!In-place update version of insert|strict-containersCreate a map from two key-value pairs which hashes don't collide. To enhance sharing, the second key-value pair is represented by the hash of its key and a singleton HashMap pairing its key with its value.Note: to avoid silly thunks, this function must be strict in the key. See issue #232. We don't need to force the HashMap argument because it's already in WHNF (having just been matched) and we just put it directly in an array.}strict-containers O(\log n) Associate the value with the key in this map. If this map previously contained a mapping for the key, the old value is replaced by the result of applying the given function to the new and old value. Example: 2insertWith f k v map where f new old = new + old~strict-containersinsertModifying is a lot like insertWith; we use it to implement alterF. It takes a value to insert when the key is absent and a function to apply to calculate a new value when the key is present. Thanks to the unboxed unary tuple, we avoid introducing any unnecessary thunks in the tree. strict-containers%In-place update version of insertWithstrict-containers O(\log n) Remove the mapping for the specified key from this map if present.strict-containersDelete optimized for the case when we know the key is in the map.It is only valid to call this when the key exists in the map and you know the hash collision position if there was one. This information can be obtained from p0. If there is no collision pass (-1) as collPos.We can skip: - the key equality check on the leaf, if we reach a leaf it must be the keystrict-containers O(\log n) Adjust the value tied to a given key in this map only if it is present. Otherwise, leave the map alone.strict-containers Much like , but not inherently leaky.strict-containers O(\log n) The expression ( f k map) updates the value x at k (if it is in the map). If (f x) is  $, the element is deleted. If it is (  y) , the key k is bound to the new value y.strict-containers O(\log n) The expression ( f k map) alters the value x at k, or absence thereof. can be used to insert, delete, or update a value in a map. In short: n k ( f k m) = f (n k m)  strict-containers O(\log n) The expression ( f k map) alters the value x at k, or absence thereof.; can be used to insert, delete, or update a value in a map.Note:  is a flipped version of the at combinator from  https://hackage.haskell.org/package/lens/docs/Control-Lens-At.html#v:atControl.Lens.At. strict-containersThis is the default version of alterF that we use in most non-trivial cases. It's called "eager" because it looks up the given key in the map eagerly, whether or not the given function requires that information. strict-containers O(n \log m) Inclusion of maps. A map is included in another map if the keys are subsets and the corresponding values are equal: isSubmapOf m1 m2 = keys m1 `isSubsetOf` keys m2 && and [ v1 == v2 | (k1,v1) <- toList m1; let v2 = m2 ! k1 ]Examples:fromList [(1,'a')] `isSubmapOf` fromList [(1,'a'),(2,'b')]True:fromList [(1,'a'),(2,'b')] `isSubmapOf` fromList [(1,'a')]False strict-containers O(n \log m) Inclusion of maps with value comparison. A map is included in another map if the keys are subsets and if the comparison function is true for the corresponding values: isSubmapOfBy cmpV m1 m2 = keys m1 `isSubsetOf` keys m2 && and [ v1 `cmpV` v2 | (k1,v1) <- toList m1; let v2 = m2 ! k1 ]ExamplesisSubmapOfBy (<=) (fromList [(1,'a')]) (fromList [(1,'b'),(2,'c')])TrueisSubmapOfBy (<=) (fromList [(1,'b')]) (fromList [(1,'a'),(2,'c')])False strict-containers O(\min n m))8 Checks if a bitmap indexed node is a submap of another.strict-containersO(n+m) The union of two maps. If a key occurs in both maps, the mapping from the first will be the mapping in the result.Examples?union (fromList [(1,'a'),(2,'b')]) (fromList [(2,'c'),(3,'d')])"fromList [(1,'a'),(2,'b'),(3,'d')]strict-containersO(n+m) The union of two maps. If a key occurs in both maps, the provided function (first argument) will be used to compute the result.strict-containersO(n+m) The union of two maps. If a key occurs in both maps, the provided function (first argument) will be used to compute the result.strict-containersStrict in the result of f.strict-containers 1) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")])fromList [(1,"c")]mapKeys (\ _ -> 3) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")])fromList [(3,"c")]strict-containers O(n \log m) Difference of two maps. Return elements of the first map not existing in the second.strict-containers O(n \log m) Difference with a combining function. When two equal keys are encountered, the combining function is applied to the values of these keys. If it returns  , the element is discarded (proper set difference). If it returns (  y+), the element is updated with a new value y.strict-containers O(n \log m) Intersection of two maps. Return elements of the first map for keys existing in the second.strict-containers O(n \log m) Intersection of two maps. If a key occurs in both maps the provided function is used to combine the values from the two maps.strict-containers O(n \log m) Intersection of two maps. If a key occurs in both maps the provided function is used to combine the values from the two maps. strict-containers Say we have  1 2 3 4  and we search for 3#. Then we can mutate the array to  undefined 2 1 4  We don't actually need to write undefined, we just have to make sure that the next search starts 1 after the current one.strict-containersO(n) Reduce this map by applying a binary operator to all elements, using the given starting value (typically the left-identity of the operator). Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.strict-containersO(n) Reduce this map by applying a binary operator to all elements, using the given starting value (typically the right-identity of the operator). Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.strict-containersO(n) Reduce this map by applying a binary operator to all elements, using the given starting value (typically the left-identity of the operator). Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.strict-containersO(n) Reduce this map by applying a binary operator to all elements, using the given starting value (typically the right-identity of the operator). Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.strict-containersO(n) Reduce this map by applying a binary operator to all elements, using the given starting value (typically the right-identity of the operator).strict-containersO(n) Reduce this map by applying a binary operator to all elements, using the given starting value (typically the left-identity of the operator).strict-containersO(n) Reduce this map by applying a binary operator to all elements, using the given starting value (typically the right-identity of the operator).strict-containersO(n) Reduce this map by applying a binary operator to all elements, using the given starting value (typically the left-identity of the operator).strict-containersO(n) Reduce the map by applying a function to each element and combining the results with a monoid operation.strict-containersO(n) Transform this map by applying a function to every value and retaining only some of them.strict-containersO(n) Transform this map by applying a function to every value and retaining only some of them.strict-containersO(n) Filter this map by retaining only elements satisfying a predicate.strict-containersCommon implementation for  and 2, allowing the former to former to reuse terms.strict-containersO(n) Filter this map by retaining only elements which values satisfy a predicate.strict-containersO(n) Return a list of this map's keys. The list is produced lazily.strict-containersO(n) Return a list of this map's values. The list is produced lazily.strict-containersO(n) Return a list of this map's elements. The list is produced lazily. The order of its elements is unspecified.strict-containersO(n) Construct a map with the supplied mappings. If the list contains duplicate mappings, the later mappings take precedence.strict-containers O(n \log n) Construct a map from a list of elements. Uses the provided function f" to merge duplicate entries with (f newVal oldVal).Examples Given a list xs, create a map with the number of occurrences of each element in xs: let xs = ['a', 'b', 'a'] in fromListWith (+) [ (x, 1) | x <- xs ] = fromList [('a', 2), ('b', 1)] Given a list of key-value pairs xs :: [(k, v)]/, group all values by their keys and return a  HashMap k [v]. let xs = [('a', 1), ('b', 2), ('a', 3)] in fromListWith (++) [ (k, [v]) | (k, v) <- xs ] = fromList [('a', [3, 1]), ('b', [2])]Note that the lists in the resulting map contain elements in reverse order from their occurences in the original list.More generally, duplicate entries are accumulated as follows; this matters when f' is not commutative or not associative. fromListWith f [(k, a), (k, b), (k, c), (k, d)] = fromList [(k, f d (f c (f b a)))] strict-containers O(n \log n) Construct a map from a list of elements. Uses the provided function to merge duplicate entries.ExamplesGiven a list of key-value pairs where the keys are of different flavours, e.g: data Key = Div | Suband the values need to be combined differently when there are duplicates, depending on the key: #combine Div = div combine Sub = (-)then fromListWithKey can be used as follows: fromListWithKey combine [(Div, 2), (Div, 6), (Sub, 2), (Sub, 3)] = fromList [(Div, 3), (Sub, 1)]=More generally, duplicate entries are accumulated as follows; fromListWith f [(k, a), (k, b), (k, c), (k, d)] = fromList [(k, f k d (f k c (f k b a)))] strict-containersO(n)> Look up the value associated with the given key in an array. strict-containersO(n) Lookup the value associated with the given key in this array. Returns   if the key wasn't found. strict-containersO(n*m): Check if the first array is a subset of the second array.strict-containersO(n)8 Update the element at the given position in this array.strict-containersO(n)8 Update the element at the given position in this array.strict-containersO(n) Update the element at the given position in this array, by applying a function to it. strict-containersUnsafely clone an array of (2^bitsPerSubkey) elements. The length of the input array is not checked.strict-containersNumber of bits that are inspected at each level of the hash tree.This constant is named t in the original Ideal Hash Trees paper. strict-containersThe size of a b node, i.e. 2 ^ . strict-containersBit mask with the lowest  bits set, i.e. 0b11111.strict-containersGiven a ] and a   that indicates the level in the tree, compute the index into a b node or into the bitmap of a ` node.index 0b0010_0010 0 0b0000_0010strict-containersGiven a ] and a   that indicates the level in the tree, compute the bitmap that contains only the  of the hash at this level.4The result can be used for constructing one-element ` nodes or to check whether a `% node may possibly contain the given ].mask 0b0010_0010 00b0100strict-containersThis array index is computed by counting the number of bits below the  represented by the mask.#sparseIndex 0b0110_0110 0b0010_00002strict-containersA bitmap with the  # least significant bits set, i.e.  0xFF_FF_FF_FF.strict-containersCheck if two the two arguments are the same value. N.B. This function might give false negatives (due to GC moving objects.)strict-containersstrict-containersstrict-containersstrict-containers.The ordering is total and consistent with the   instance. However, nothing else about the ordering is specified, and it may change from version to version of either this package or of hashable.strict-containers5Note that, in the presence of hash collisions, equal HashMap?s may behave differently, i.e. substitutivity may be violated:"data D = A | B deriving (Eq, Show)5instance Hashable D where hashWithSalt salt _d = saltx = fromList [(A,1), (B,2)]y = fromList [(B,2), (A,1)]x == yTruetoList x [(A,1),(B,2)]toList y [(B,2),(A,1)]In general, the lack of substitutivity can be observed with any function that depends on the key ordering, such as folds and traversals.strict-containers  = i  = If a key occurs in both maps, the mapping from the first will be the mapping in the result.Examplesmappend (fromList [(1,'a'),(2,'b')]) (fromList [(2,'c'),(3,'d')])"fromList [(1,'a'),(2,'b'),(3,'d')]strict-containers  = If a key occurs in both maps, the mapping from the first will be the mapping in the result.Examples8fromList [(1,'a'),(2,'b')] <> fromList [(2,'c'),(3,'d')]"fromList [(1,'a'),(2,'b'),(3,'d')] strict-containersstrict-containersstrict-containersstrict-containersrstrict-containersDefault value to return.sstrict-containersDefault value to return.strict-containers Bitmap of a ` nodestrict-containersOne-bit  corresponding to the  of a hashstrict-containersIndex into the array of the ` nodeYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~^_`abcdeijklmnqrstw}{]\vuf|hgpYZ[xoyz~t9 "2010-2012 Johan Tibell BSD-stylejohan.tibell@gmail.comportable Trustworthy/strict-containersO(1)' Construct a map with a single element.strict-containers O(\log n) Associate the specified value with the specified key in this map. If this map previously contained a mapping for the key, the old value is replaced.strict-containers O(\log n) Associate the value with the key in this map. If this map previously contained a mapping for the key, the old value is replaced by the result of applying the given function to the new and old value. Example: 2insertWith f k v map where f new old = new + old strict-containers%In-place update version of insertWithstrict-containers O(\log n) Adjust the value tied to a given key in this map only if it is present. Otherwise, leave the map alone.strict-containers O(\log n) The expression ( f k map) updates the value x at k (if it is in the map). If (f x) is  $, the element is deleted. If it is (  y) , the key k is bound to the new value y.strict-containers O(\log n) The expression ( f k map) alters the value x at k, or absence thereof. can be used to insert, delete, or update a value in a map. In short: lookup k ( f k m) = f (lookup k m)  strict-containers O(\log n) The expression ( f k map) alters the value x at k, or absence thereof.; can be used to insert, delete, or update a value in a map.Note:  is a flipped version of the at combinator from  https://hackage.haskell.org/package/lens/docs/Control-Lens-At.html#v:atControl.Lens.At. strict-containersThis is the default version of alterF that we use in most non-trivial cases. It's called "eager" because it looks up the given key in the map eagerly, whether or not the given function requires that information.strict-containersO(n+m) The union of two maps. If a key occurs in both maps, the provided function (first argument) will be used to compute the result.strict-containersO(n+m) The union of two maps. If a key occurs in both maps, the provided function (first argument) will be used to compute the result.strict-containersO(n): Transform this map by applying a function to every value.strict-containersO(n): Transform this map by applying a function to every value.strict-containersO(n) Transform this map by applying a function to every value and retaining only some of them.strict-containersO(n) Transform this map by applying a function to every value and retaining only some of them.strict-containersO(n) Perform an  & action for each key-value pair in a ^ and produce a ^ of all the results. Each ^# will be strict in all its values. traverseWithKey f = fmap ( id) .  Data.Strict.HashMap.Autogen.Lazy.#$ f Note: the order in which the actions occur is unspecified. In particular, when the map contains hash collisions, the order in which the actions associated with the keys involved will depend in an unspecified way on their insertion order.strict-containers O(n \log m) Difference with a combining function. When two equal keys are encountered, the combining function is applied to the values of these keys. If it returns  , the element is discarded (proper set difference). If it returns (  y+), the element is updated with a new value y.strict-containersO(n+m) Intersection of two maps. If a key occurs in both maps the provided function is used to combine the values from the two maps.strict-containersO(n+m) Intersection of two maps. If a key occurs in both maps the provided function is used to combine the values from the two maps.strict-containers O(n \log n) Construct a map with the supplied mappings. If the list contains duplicate mappings, the later mappings take precedence.strict-containers O(n \log n) Construct a map from a list of elements. Uses the provided function f" to merge duplicate entries with (f newVal oldVal).Examples Given a list xs, create a map with the number of occurrences of each element in xs: let xs = ['a', 'b', 'a'] in fromListWith (+) [ (x, 1) | x <- xs ] = fromList [('a', 2), ('b', 1)] Given a list of key-value pairs xs :: [(k, v)]/, group all values by their keys and return a  HashMap k [v]. let xs = ('a', 1), ('b', 2), ('a', 3)] in fromListWith (++) [ (k, [v]) | (k, v) <- xs ] = fromList [('a', [3, 1]), ('b', [2])]Note that the lists in the resulting map contain elements in reverse order from their occurences in the original list.More generally, duplicate entries are accumulated as follows; this matters when f' is not commutative or not associative. fromListWith f [(k, a), (k, b), (k, c), (k, d)] = fromList [(k, f d (f c (f b a)))] strict-containers O(n \log n) Construct a map from a list of elements. Uses the provided function to merge duplicate entries.ExamplesGiven a list of key-value pairs where the keys are of different flavours, e.g: data Key = Div | Suband the values need to be combined differently when there are duplicates, depending on the key: #combine Div = div combine Sub = (-)then fromListWithKey can be used as follows: fromListWithKey combine [(Div, 2), (Div, 6), (Sub, 2), (Sub, 3)] = fromList [(Div, 3), (Sub, 1)]=More generally, duplicate entries are accumulated as follows; fromListWith f [(k, a), (k, b), (k, c), (k, d)] = fromList [(k, f k d (f k c (f k b a)))] strict-containersAppend the given key and value to the array. If the key is already present, instead update the value of the key by applying the given function to the new and old value (in that order). The value is always evaluated to WHNF before being inserted into the array. strict-containersAppend the given key and value to the array. If the key is already present, instead update the value of the key by applying the given function to the new and old value (in that order). The value is always evaluated to WHNF before being inserted into the array.5^iklmnqrst5^iklmnqrst 2010-2012 Johan Tibell BSD-stylejohan.tibell@gmail.com provisionalportableSafeX5^iklmnqrst5^iklmnqrst Safe-InferredD% Safe-Inferredj5^iklmnqrst& Safe-Inferred (c) Daan Leijen 2002 (c) Andriy Palamarchuk 2008 (c) wren romano 2016 BSD-stylelibraries@haskell.orgportable Trustworthy 5>K. strict-containers7A tactic for dealing with keys present in both maps in .A tactic of type SimpleWhenMatched x y z6 is an abstract representation of a function of type Key -> x -> y -> Maybe z. strict-containers7A tactic for dealing with keys present in both maps in  or .A tactic of type WhenMatched f x y z6 is an abstract representation of a function of type Key -> x -> y -> f (Maybe z). strict-containersA tactic for dealing with keys present in one map but not the other in .A tactic of type SimpleWhenMissing x z6 is an abstract representation of a function of type Key -> x -> Maybe z. strict-containersA tactic for dealing with keys present in one map but not the other in  or .A tactic of type WhenMissing f k x z6 is an abstract representation of a function of type Key -> x -> f (Maybe z).strict-containersA map of integers to values a.strict-containers O(\min(n,W))". Find the value at a key. Calls  # when the element can not be found. fromList [(5,'a'), (3,'b')] ! 1 Error: element not in the map fromList [(5,'a'), (3,'b')] ! 5 == 'a' strict-containers O(\min(n,W))$. Find the value at a key. Returns  # when the element can not be found. fromList [(5,'a'), (3,'b')] !? 1 == Nothing fromList [(5,'a'), (3,'b')] !? 5 == Just 'a'strict-containersSame as .strict-containersO(1). Is the map empty? Data.Strict.IntMap.Autogen.null (empty) == True Data.Strict.IntMap.Autogen.null (singleton 1 'a') == Falsestrict-containersO(n) . Number of elements in the map. size empty == 0 size (singleton 1 'a') == 1 size (fromList([(1,'a'), (2,'c'), (3,'b')])) == 3strict-containers O(\min(n,W))!. Is the key a member of the map? member 5 (fromList [(5,'a'), (3,'b')]) == True member 1 (fromList [(5,'a'), (3,'b')]) == Falsestrict-containers O(\min(n,W))%. Is the key not a member of the map? notMember 5 (fromList [(5,'a'), (3,'b')]) == False notMember 1 (fromList [(5,'a'), (3,'b')]) == Truestrict-containers O(\min(n,W))1. Lookup the value at a key in the map. See also '(.strict-containers O(\min(n,W)). The expression ( def k map) returns the value at key k or returns def, when the key is not an element of the map. findWithDefault 'x' 1 (fromList [(5,'a'), (3,'b')]) == 'x' findWithDefault 'x' 5 (fromList [(5,'a'), (3,'b')]) == 'a'strict-containers O(\log n). Find largest key smaller than the given one and return the corresponding (key, value) pair. lookupLT 3 (fromList [(3,'a'), (5,'b')]) == Nothing lookupLT 4 (fromList [(3,'a'), (5,'b')]) == Just (3, 'a')strict-containers O(\log n). Find smallest key greater than the given one and return the corresponding (key, value) pair. lookupGT 4 (fromList [(3,'a'), (5,'b')]) == Just (5, 'b') lookupGT 5 (fromList [(3,'a'), (5,'b')]) == Nothingstrict-containers O(\log n). Find largest key smaller or equal to the given one and return the corresponding (key, value) pair. lookupLE 2 (fromList [(3,'a'), (5,'b')]) == Nothing lookupLE 4 (fromList [(3,'a'), (5,'b')]) == Just (3, 'a') lookupLE 5 (fromList [(3,'a'), (5,'b')]) == Just (5, 'b')strict-containers O(\log n). Find smallest key greater or equal to the given one and return the corresponding (key, value) pair. lookupGE 3 (fromList [(3,'a'), (5,'b')]) == Just (3, 'a') lookupGE 4 (fromList [(3,'a'), (5,'b')]) == Just (5, 'b') lookupGE 6 (fromList [(3,'a'), (5,'b')]) == Nothingstrict-containersO(n+m). Check whether the key sets of two maps are disjoint (i.e. their  is empty). disjoint (fromList [(2,'a')]) (fromList [(1,()), (3,())]) == True disjoint (fromList [(2,'a')]) (fromList [(1,'a'), (2,'b')]) == False disjoint (fromList []) (fromList []) == True 'disjoint a b == null (intersection a b)strict-containersRelate the keys of one map to the values of the other, by using the values of the former as keys for lookups in the latter. Complexity:  O(n * \min(m,W)) , where m" is the size of the first argument compose (fromList [('a', "A"), ('b', "B")]) (fromList [(1,'a'),(2,'b'),(3,'z')]) = fromList [(1,"A"),(2,"B")] ( bc ab ) = (bc  ) <=< (ab ) Note: Prior to v0.6.4, !Data.Strict.IntMap.Autogen.Strict exposed a version of & that forced the values of the output ,. This version does not force these values.strict-containersO(1). The empty map. )empty == fromList [] size empty == 0strict-containersO(1). A map of one element. singleton 1 'a' == fromList [(1, 'a')] size (singleton 1 'a') == 1strict-containers O(\min(n,W)). Insert a new key/value pair in the map. If the key is already present in the map, the associated value is replaced with the supplied value, i.e.  is equivalent to   . insert 5 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'x')] insert 7 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'a'), (7, 'x')] insert 5 'x' empty == singleton 5 'x'strict-containers O(\min(n,W))%. Insert with a combining function.  f key value mp) will insert the pair (key, value) into mp if key does not exist in the map. If the key does exist, the function will insert f new_value old_value. insertWith (++) 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "xxxa")] insertWith (++) 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")] insertWith (++) 5 "xxx" empty == singleton 5 "xxx"strict-containers O(\min(n,W))%. Insert with a combining function.  f key value mp) will insert the pair (key, value) into mp if key does not exist in the map. If the key does exist, the function will insert f key new_value old_value. let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value insertWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:xxx|a")] insertWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")] insertWithKey f 5 "xxx" empty == singleton 5 "xxx"strict-containers O(\min(n,W)). The expression ( f k x map2) is a pair where the first element is equal to ( k map$) and the second element equal to ( f k x map). let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value insertLookupWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "5:xxx|a")]) insertLookupWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "xxx")]) insertLookupWithKey f 5 "xxx" empty == (Nothing, singleton 5 "xxx")This is how to define  insertLookup using insertLookupWithKey: let insertLookup kx x t = insertLookupWithKey (\_ a _ -> a) kx x t insertLookup 5 "x" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "x")]) insertLookup 7 "x" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "x")])strict-containers O(\min(n,W)). Delete a key and its value from the map. When the key is not a member of the map, the original map is returned. delete 5 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" delete 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] delete 5 empty == emptystrict-containers O(\min(n,W)). Adjust a value at a specific key. When the key is not a member of the map, the original map is returned. adjust ("new " ++) 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")] adjust ("new " ++) 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] adjust ("new " ++) 7 empty == emptystrict-containers O(\min(n,W)). Adjust a value at a specific key. When the key is not a member of the map, the original map is returned. let f key x = (show key) ++ ":new " ++ x adjustWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")] adjustWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] adjustWithKey f 7 empty == emptystrict-containers O(\min(n,W)). The expression ( f k map) updates the value x at k (if it is in the map). If (f x) is  %, the element is deleted. If it is (  y ), the key k is bound to the new value y. let f x = if x == "a" then Just "new a" else Nothing update f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")] update f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] update f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"strict-containers O(\min(n,W)). The expression ( f k map) updates the value x at k (if it is in the map). If (f k x) is  %, the element is deleted. If it is (  y ), the key k is bound to the new value y. let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing updateWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")] updateWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] updateWithKey f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"strict-containers O(\min(n,W)). Lookup and update. The function returns original value, if it is updated. This is different behavior than ')>. Returns the original key value if the map entry is deleted. let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing updateLookupWithKey f 5 (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "5:new a")]) updateLookupWithKey f 7 (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a")]) updateLookupWithKey f 3 (fromList [(5,"a"), (3,"b")]) == (Just "b", singleton 5 "a")strict-containers O(\min(n,W)). The expression ( f k map) alters the value x at k, or absence thereof. 8 can be used to insert, delete, or update a value in an . In short :  k ( f k m) = f ( k m).strict-containers O(\log n). The expression ( f k map) alters the value x at k, or absence thereof.  can be used to inspect, insert, delete, or update a value in an . In short :  k  $  f k m = f ( k m).Example: interactiveAlter :: Int -> IntMap String -> IO (IntMap String) interactiveAlter k m = alterF f k m where f Nothing = do putStrLn $ show k ++ " was not found in the map. Would you like to add it?" getUserResponse1 :: IO (Maybe String) f (Just old) = do putStrLn $ "The key is currently bound to " ++ show old ++ ". Would you like to change or delete it?" getUserResponse2 :: IO (Maybe String)  is the most general operation for working with an individual key that may or may not be in a given map.Note:  is a flipped version of the at combinator from Control.Lens.At.strict-containersThe union of a list of maps. unions [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])] == fromList [(3, "b"), (5, "a"), (7, "C")] unions [(fromList [(5, "A3"), (3, "B3")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "a"), (3, "b")])] == fromList [(3, "B3"), (5, "A3"), (7, "C")]strict-containers8The union of a list of maps, with a combining operation. unionsWith (++) [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])] == fromList [(3, "bB3"), (5, "aAA3"), (7, "C")]strict-containersO(n+m). The (left-biased) union of two maps. It prefers the first map when duplicate keys are encountered, i.e. ( ==   ). union (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "a"), (7, "C")]strict-containersO(n+m)&. The union with a combining function. unionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "aA"), (7, "C")]strict-containersO(n+m)&. The union with a combining function. let f key left_value right_value = (show key) ++ ":" ++ left_value ++ "|" ++ right_value unionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "5:a|A"), (7, "C")]strict-containersO(n+m).. Difference between two maps (based on keys). difference (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 3 "b"strict-containersO(n+m)'. Difference with a combining function. let f al ar = if al == "b" then Just (al ++ ":" ++ ar) else Nothing differenceWith f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (7, "C")]) == singleton 3 "b:B"strict-containersO(n+m). Difference with a combining function. When two equal keys are encountered, the combining function is applied to the key and both values. If it returns  , the element is discarded (proper set difference). If it returns (  y+), the element is updated with a new value y. let f k al ar = if al == "b" then Just ((show k) ++ ":" ++ al ++ "|" ++ ar) else Nothing differenceWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (10, "C")]) == singleton 3 "3:b|B"strict-containersO(n+m)0. Remove all the keys in a given set from a map. m `withoutKeys` s =  (k _ -> k   s) m strict-containersO(n+m)=. The (left-biased) intersection of two maps (based on keys). intersection (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "a"strict-containersO(n+m)0. The restriction of a map to the keys in a set. m `restrictKeys` s =  (k _ -> k   s) m strict-containers O(\min(n,W))?. Restrict to the sub-map with all keys matching a key prefix.strict-containersO(n+m)-. The intersection with a combining function. intersectionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "aA"strict-containersO(n+m)-. The intersection with a combining function. let f k al ar = (show k) ++ ":" ++ al ++ "|" ++ ar intersectionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "5:a|A"strict-containersO(n+m):. A high-performance universal combining function. Using , all combining functions can be defined without any loss of efficiency (with exception of ,  and ,, where sharing of some nodes is lost with ).6Please make sure you know what is going on when using , otherwise you can be surprised by unexpected code growth or even corruption of the data structure.When  is given three arguments, it is inlined to the call site. You should therefore use  only to define your custom combining functions. For example, you could define ,  and  as myUnionWithKey f m1 m2 = mergeWithKey (\k x1 x2 -> Just (f k x1 x2)) id id m1 m2 myDifferenceWithKey f m1 m2 = mergeWithKey f id (const empty) m1 m2 myIntersectionWithKey f m1 m2 = mergeWithKey (\k x1 x2 -> Just (f k x1 x2)) (const empty) (const empty) m1 m2 When calling  combine only1 only2, a function combining two s is created, such thatif a key is present in both maps, it is passed with both corresponding values to the combine function. Depending on the result, the key is either present in the result with specified value, or is left out;>a nonempty subtree present only in the first map is passed to only1* and the output is added to the result;?a nonempty subtree present only in the second map is passed to only2* and the output is added to the result.The only1 and only2 methods must return a map with a subset (possibly empty) of the keys of the given map. The values can be modified arbitrarily. Most common variants of only1 and only2 are   and   , but for example  f or  f could be used for any f. strict-containersMap covariantly over a  f x.strict-containersMap covariantly over a  f x', using only a 'Functor f' constraint.strict-containersMap covariantly over a  f k x', using only a 'Functor f' constraint. strict-containersMap contravariantly over a  f _ x. strict-containersMap contravariantly over a  f _ y z. strict-containersMap contravariantly over a  f x _ z. strict-containersAlong with zipWithMaybeAMatched, witnesses the isomorphism between WhenMatched f x y z and Key -> x -> y -> f (Maybe z). strict-containersAlong with traverseMaybeMissing, witnesses the isomorphism between WhenMissing f x y and Key -> x -> f (Maybe y). strict-containersMap covariantly over a  f x y. strict-containersWhen a key is found in both maps, apply a function to the key and values and use the result in the merged map. zipWithMatched :: (Key -> x -> y -> z) -> SimpleWhenMatched x y z strict-containersWhen a key is found in both maps, apply a function to the key and values to produce an action and use its result in the merged map. strict-containersWhen a key is found in both maps, apply a function to the key and values and maybe use the result in the merged map. zipWithMaybeMatched :: (Key -> x -> y -> Maybe z) -> SimpleWhenMatched x y z strict-containersWhen a key is found in both maps, apply a function to the key and values, perform the resulting action, and maybe use the result in the merged map.This is the fundamental  tactic. strict-containersDrop all the entries whose keys are missing from the other map. $dropMissing :: SimpleWhenMissing x y/dropMissing = mapMaybeMissing (\_ _ -> Nothing)but  dropMissing is much faster. strict-containersPreserve, unchanged, the entries whose keys are missing from the other map. (preserveMissing :: SimpleWhenMissing x x=preserveMissing = Merge.Lazy.mapMaybeMissing (\_ x -> Just x)but preserveMissing is much faster. strict-containers?Map over the entries whose keys are missing from the other map. 4mapMissing :: (k -> x -> y) -> SimpleWhenMissing x y5mapMissing f = mapMaybeMissing (\k x -> Just $ f k x)but  mapMissing is somewhat faster. strict-containersMap over the entries whose keys are missing from the other map, optionally removing some. This is the most powerful / tactic, but others are usually more efficient. mapMaybeMissing :: (Key -> x -> Maybe y) -> SimpleWhenMissing x y?mapMaybeMissing f = traverseMaybeMissing (\k x -> pure (f k x))but mapMaybeMissing uses fewer unnecessary   operations. strict-containers=Filter the entries whose keys are missing from the other map. :filterMissing :: (k -> x -> Bool) -> SimpleWhenMissing x xfilterMissing f = Merge.Lazy.mapMaybeMissing $ \k x -> guard (f k x) *> Just x#but this should be a little faster. strict-containersFilter the entries whose keys are missing from the other map using some   action. filterAMissing f = Merge.Lazy.traverseMaybeMissing $ \k x -> (\b -> guard b *> Just x) <$> f k x#but this should be a little faster. strict-containersO(n)". Filter keys and values using an   predicate. strict-containers:This wasn't in Data.Bool until 4.7.0, so we define it here strict-containersTraverse over the entries whose keys are missing from the other map. strict-containersTraverse over the entries whose keys are missing from the other map, optionally producing values to put in the result. This is the most powerful 0 tactic, but others are usually more efficient.strict-containersO(n)'. Traverse keys/values and collect the   results. strict-containersMerge two maps. takes two  tactics, a  tactic and two maps. It uses the tactics to merge the maps. Its behavior is best understood via its fundamental tactics,  and .Consider merge (mapMaybeMissing g1) (mapMaybeMissing g2) (zipWithMaybeMatched f) m1 m2 Take, for example, m1 = [(0, 'a'), (1, 'b'), (3, 'c'), (4, 'd')] m2 = [(1, "one"), (2, "two"), (4, "three")] & will first "align" these maps by key: m1 = [(0, 'a'), (1, 'b'), (3, 'c'), (4, 'd')] m2 = [(1, "one"), (2, "two"), (4, "three")] It will then pass the individual entries and pairs of entries to g1, g2, or f as appropriate: maybes = [g1 0 'a', f 1 'b' "one", g2 2 "two", g1 3 'c', f 4 'd' "three"] This produces a   for each key: keys = 0 1 2 3 4 results = [Nothing, Just True, Just False, Nothing, Just True]  Finally, the Just" results are collected into a map: 2return value = [(1, True), (2, False), (4, True)] The other tactics below are optimizations or simplifications of % for special cases. Most importantly, drops all the keys. leaves all the entries alone.When  is given three arguments, it is inlined at the call site. To prevent excessive inlining, you should typically use + to define your custom combining functions. Examples:unionWithKey f = merge preserveMissing preserveMissing (zipWithMatched f)intersectionWithKey f = merge dropMissing dropMissing (zipWithMatched f)0differenceWith f = merge diffPreserve diffDrop fsymmetricDifference = merge diffPreserve diffPreserve (\ _ _ _ -> Nothing)mapEachPiece f g h = merge (diffMapWithKey f) (diffMapWithKey g) strict-containersAn applicative version of . takes two  tactics, a  tactic and two maps. It uses the tactics to merge the maps. Its behavior is best understood via its fundamental tactics,  and .Consider mergeA (traverseMaybeMissing g1) (traverseMaybeMissing g2) (zipWithMaybeAMatched f) m1 m2 Take, for example, m1 = [(0, 'a'), (1, 'b'), (3,'c'), (4, 'd')] m2 = [(1, "one"), (2, "two"), (4, "three")] & will first "align" these maps by key: m1 = [(0, 'a'), (1, 'b'), (3, 'c'), (4, 'd')] m2 = [(1, "one"), (2, "two"), (4, "three")] It will then pass the individual entries and pairs of entries to g1, g2, or f as appropriate: actions = [g1 0 'a', f 1 'b' "one", g2 2 "two", g1 3 'c', f 4 'd' "three"] )Next, it will perform the actions in the actions# list in order from left to right. keys = 0 1 2 3 4 results = [Nothing, Just True, Just False, Nothing, Just True]  Finally, the Just" results are collected into a map: 2return value = [(1, True), (2, False), (4, True)] The other tactics below are optimizations or simplifications of % for special cases. Most importantly, drops all the keys. leaves all the entries alone. does not use the   context.When  is given three arguments, it is inlined at the call site. To prevent excessive inlining, you should generally only use & to define custom combining functions.strict-containers O(\min(n,W))&. Update the value at the minimal key. updateMinWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"3:b"), (5,"a")] updateMinWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"strict-containers O(\min(n,W))&. Update the value at the maximal key. updateMaxWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"b"), (5,"5:a")] updateMaxWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"strict-containers O(\min(n,W)). Retrieves the maximal (key,value) pair of the map, and the map stripped of that element, or   if passed an empty map. maxViewWithKey (fromList [(5,"a"), (3,"b")]) == Just ((5,"a"), singleton 3 "b") maxViewWithKey empty == Nothingstrict-containers O(\min(n,W)). Retrieves the minimal (key,value) pair of the map, and the map stripped of that element, or   if passed an empty map. minViewWithKey (fromList [(5,"a"), (3,"b")]) == Just ((3,"b"), singleton 5 "a") minViewWithKey empty == Nothingstrict-containers O(\min(n,W))&. Update the value at the maximal key. updateMax (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "Xa")] updateMax (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"strict-containers O(\min(n,W))&. Update the value at the minimal key. updateMin (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "Xb"), (5, "a")] updateMin (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"strict-containers O(\min(n,W)). Retrieves the maximal key of the map, and the map stripped of that element, or   if passed an empty map.strict-containers O(\min(n,W)). Retrieves the minimal key of the map, and the map stripped of that element, or   if passed an empty map.strict-containers O(\min(n,W)). Delete and find the maximal element. This function throws an error if the map is empty. Use  if the map may be empty.strict-containers O(\min(n,W)). Delete and find the minimal element. This function throws an error if the map is empty. Use  if the map may be empty.strict-containers O(\min(n,W))&. The minimal key of the map. Returns   if the map is empty.strict-containers O(\min(n,W))$. The minimal key of the map. Calls   if the map is empty. Use  if the map may be empty.strict-containers O(\min(n,W))&. The maximal key of the map. Returns   if the map is empty.strict-containers O(\min(n,W))$. The maximal key of the map. Calls   if the map is empty. Use  if the map may be empty.strict-containers O(\min(n,W)). Delete the minimal key. Returns an empty map if the map is empty.=Note that this is a change of behaviour for consistency with '*0 @ versions prior to 0.5 threw an error if the  was already empty.strict-containers O(\min(n,W)). Delete the maximal key. Returns an empty map if the map is empty.=Note that this is a change of behaviour for consistency with '*0 @ versions prior to 0.5 threw an error if the  was already empty.strict-containersO(n+m). Is this a proper submap? (ie. a submap but not equal). Defined as ( =  (==)).strict-containersO(n+m). Is this a proper submap? (ie. a submap but not equal). The expression ( f m1 m2 ) returns   when keys m1 and keys m2 are not equal, all keys in m1 are in m2 , and when f returns   when applied to their respective values. For example, the following expressions are all  : isProperSubmapOfBy (==) (fromList [(1,1)]) (fromList [(1,1),(2,2)]) isProperSubmapOfBy (<=) (fromList [(1,1)]) (fromList [(1,1),(2,2)])But the following are all  : isProperSubmapOfBy (==) (fromList [(1,1),(2,2)]) (fromList [(1,1),(2,2)]) isProperSubmapOfBy (==) (fromList [(1,1),(2,2)]) (fromList [(1,1)]) isProperSubmapOfBy (<) (fromList [(1,1)]) (fromList [(1,1),(2,2)])strict-containersO(n+m)!. Is this a submap? Defined as ( =  (==)).strict-containersO(n+m). The expression ( f m1 m2 ) returns   if all keys in m1 are in m2 , and when f returns   when applied to their respective values. For example, the following expressions are all  : isSubmapOfBy (==) (fromList [(1,1)]) (fromList [(1,1),(2,2)]) isSubmapOfBy (<=) (fromList [(1,1)]) (fromList [(1,1),(2,2)]) isSubmapOfBy (==) (fromList [(1,1),(2,2)]) (fromList [(1,1),(2,2)])But the following are all  : isSubmapOfBy (==) (fromList [(1,2)]) (fromList [(1,1),(2,2)]) isSubmapOfBy (<) (fromList [(1,1)]) (fromList [(1,1),(2,2)]) isSubmapOfBy (==) (fromList [(1,1),(2,2)]) (fromList [(1,1)])strict-containersO(n),. Map a function over all values in the map. map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]strict-containersO(n),. Map a function over all values in the map. let f key x = (show key) ++ ":" ++ x mapWithKey f (fromList [(5,"a"), (3,"b")]) == fromList [(3, "3:b"), (5, "5:a")]strict-containersO(n).  f s ==   $   ((k, v) -> (,) k  $ f k v) ( m)* That is, behaves exactly like a regular   except that the traversing function also has access to the key associated with a value. traverseWithKey (\k v -> if odd k then Just (succ v) else Nothing) (fromList [(1, 'a'), (5, 'e')]) == Just (fromList [(1, 'b'), (5, 'f')]) traverseWithKey (\k v -> if odd k then Just (succ v) else Nothing) (fromList [(2, 'c')]) == Nothingstrict-containersO(n). The function  threads an accumulating argument through the map in ascending order of keys. let f a b = (a ++ b, b ++ "X") mapAccum f "Everything: " (fromList [(5,"a"), (3,"b")]) == ("Everything: ba", fromList [(3, "bX"), (5, "aX")])strict-containersO(n). The function  threads an accumulating argument through the map in ascending order of keys. let f a k b = (a ++ " " ++ (show k) ++ "-" ++ b, b ++ "X") mapAccumWithKey f "Everything:" (fromList [(5,"a"), (3,"b")]) == ("Everything: 3-b 5-a", fromList [(3, "bX"), (5, "aX")]) strict-containersO(n). The function   threads an accumulating argument through the map in ascending order of keys.strict-containersO(n). The function  threads an accumulating argument through the map in descending order of keys.strict-containersO(n \min(n,W)).  f s! is the map obtained by applying f to each key of s.)The size of the result may be smaller if f maps two or more distinct keys to the same new key. In this case the value at the greatest of the original keys is retained. mapKeys (+ 1) (fromList [(5,"a"), (3,"b")]) == fromList [(4, "b"), (6, "a")] mapKeys (\ _ -> 1) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 1 "c" mapKeys (\ _ -> 3) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 3 "c"strict-containersO(n \min(n,W)).  c f s! is the map obtained by applying f to each key of s.)The size of the result may be smaller if f maps two or more distinct keys to the same new key. In this case the associated values will be combined using c. mapKeysWith (++) (\ _ -> 1) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 1 "cdab" mapKeysWith (++) (\ _ -> 3) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 3 "cdab"strict-containersO(n \min(n,W)).  f s ==  f s, but works only when f2 is strictly monotonic. That is, for any values x and y, if x < y then f x < f y.  The precondition is not checked. Semi-formally, we have: and [x < y ==> f x < f y | x <- ls, y <- ls] ==> mapKeysMonotonic f s == mapKeys f s where ls = keys sThis means that f maps distinct original keys to distinct resulting keys. This function has slightly better performance than . mapKeysMonotonic (\ k -> k * 2) (fromList [(5,"a"), (3,"b")]) == fromList [(6, "b"), (10, "a")]strict-containersO(n)0. Filter all values that satisfy some predicate. filter (> "a") (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" filter (> "x") (fromList [(5,"a"), (3,"b")]) == empty filter (< "a") (fromList [(5,"a"), (3,"b")]) == emptystrict-containersO(n)5. Filter all keys/values that satisfy some predicate. filterWithKey (\k _ -> k > 4) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"strict-containersO(n). Partition the map according to some predicate. The first map contains all elements that satisfy the predicate, the second all elements that fail the predicate. See also . partition (> "a") (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a") partition (< "x") (fromList [(5,"a"), (3,"b")]) == (fromList [(3, "b"), (5, "a")], empty) partition (> "x") (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3, "b"), (5, "a")])strict-containersO(n). Partition the map according to some predicate. The first map contains all elements that satisfy the predicate, the second all elements that fail the predicate. See also . partitionWithKey (\ k _ -> k > 3) (fromList [(5,"a"), (3,"b")]) == (singleton 5 "a", singleton 3 "b") partitionWithKey (\ k _ -> k < 7) (fromList [(5,"a"), (3,"b")]) == (fromList [(3, "b"), (5, "a")], empty) partitionWithKey (\ k _ -> k > 7) (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3, "b"), (5, "a")])strict-containersO(n). Map values and collect the   results. let f x = if x == "a" then Just "new a" else Nothing mapMaybe f (fromList [(5,"a"), (3,"b")]) == singleton 5 "new a"strict-containersO(n)". Map keys/values and collect the   results. let f k _ = if k < 5 then Just ("key : " ++ (show k)) else Nothing mapMaybeWithKey f (fromList [(5,"a"), (3,"b")]) == singleton 3 "key : 3"strict-containersO(n). Map values and separate the   and   results. let f a = if a < "c" then Left a else Right a mapEither f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (fromList [(3,"b"), (5,"a")], fromList [(1,"x"), (7,"z")]) mapEither (\ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (empty, fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])strict-containersO(n)#. Map keys/values and separate the   and   results. let f k a = if k < 5 then Left (k * 2) else Right (a ++ a) mapEitherWithKey f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (fromList [(1,2), (3,6)], fromList [(5,"aa"), (7,"zz")]) mapEitherWithKey (\_ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (empty, fromList [(1,"x"), (3,"b"), (5,"a"), (7,"z")])strict-containers O(\min(n,W)). The expression ( k map ) is a pair  (map1,map2) where all keys in map1 are lower than k and all keys in map2 larger than k. Any key equal to k is found in neither map1 nor map2. split 2 (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3,"b"), (5,"a")]) split 3 (fromList [(5,"a"), (3,"b")]) == (empty, singleton 5 "a") split 4 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a") split 5 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", empty) split 6 (fromList [(5,"a"), (3,"b")]) == (fromList [(3,"b"), (5,"a")], empty)strict-containers O(\min(n,W)) . Performs a  but also returns whether the pivot key was found in the original map. splitLookup 2 (fromList [(5,"a"), (3,"b")]) == (empty, Nothing, fromList [(3,"b"), (5,"a")]) splitLookup 3 (fromList [(5,"a"), (3,"b")]) == (empty, Just "b", singleton 5 "a") splitLookup 4 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", Nothing, singleton 5 "a") splitLookup 5 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", Just "a", empty) splitLookup 6 (fromList [(5,"a"), (3,"b")]) == (fromList [(3,"b"), (5,"a")], Nothing, empty)strict-containersO(n). Fold the values in the map using the given right-associative binary operator, such that  f z == +, f z . . For example, elems map = foldr (:) [] map let f a len = len + (length a) foldr f 0 (fromList [(5,"a"), (3,"bbb")]) == 4strict-containersO(n). A strict version of . Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.strict-containersO(n). Fold the values in the map using the given left-associative binary operator, such that  f z == +- f z . . For example, %elems = reverse . foldl (flip (:)) [] let f len a = len + (length a) foldl f 0 (fromList [(5,"a"), (3,"bbb")]) == 4strict-containersO(n). A strict version of . Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.strict-containersO(n). Fold the keys and values in the map using the given right-associative binary operator, such that  f z == +, (  f) z . . For example, 0keys map = foldrWithKey (\k x ks -> k:ks) [] map let f k a result = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")" foldrWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (5:a)(3:b)"strict-containersO(n). A strict version of . Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.strict-containersO(n). Fold the keys and values in the map using the given left-associative binary operator, such that  f z == +- (\z' (kx, x) -> f z' kx x) z . . For example, 2keys = reverse . foldlWithKey (\ks k x -> k:ks) [] let f result k a = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")" foldlWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (3:b)(5:a)"strict-containersO(n). A strict version of . Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.strict-containersO(n). Fold the keys and values in the map using the given monoid, such that  f = +. .  f*This can be an asymptotically faster than  or  for some monoids.strict-containersO(n). Return all elements of the map in the ascending order of their keys. Subject to list fusion. elems (fromList [(5,"a"), (3,"b")]) == ["b","a"] elems empty == []strict-containersO(n). Return all keys of the map in ascending order. Subject to list fusion.  replicate k 'a') (Data.IntSet.fromList [3, 5]) == fromList [(5,"aaaaa"), (3,"aaa")] fromSet undefined Data.IntSet.empty == emptystrict-containersO(n). Convert the map to a list of key/value pairs. Subject to list fusion. toList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")] toList empty == []strict-containersO(n). Convert the map to a list of key/value pairs where the keys are in ascending order. Subject to list fusion. =toAscList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]strict-containersO(n). Convert the map to a list of key/value pairs where the keys are in descending order. Subject to list fusion. >toDescList (fromList [(5,"a"), (3,"b")]) == [(5,"a"), (3,"b")]strict-containersO(n \min(n,W)).. Create a map from a list of key/value pairs. fromList [] == empty fromList [(5,"a"), (3,"b"), (5, "c")] == fromList [(5,"c"), (3,"b")] fromList [(5,"c"), (3,"b"), (5, "a")] == fromList [(5,"a"), (3,"b")]strict-containersO(n \min(n,W)). Create a map from a list of key/value pairs with a combining function. See also . fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"c")] == fromList [(3, "ab"), (5, "cba")] fromListWith (++) [] == emptystrict-containersO(n \min(n,W)). Build a map from a list of key/value pairs with a combining function. See also fromAscListWithKey'. let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value fromListWithKey f [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"c")] == fromList [(3, "3:a|b"), (5, "5:c|5:b|a")] fromListWithKey f [] == emptystrict-containersO(n). Build a map from a list of key/value pairs where the keys are in ascending order. fromAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")] fromAscList [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "b")]strict-containersO(n). Build a map from a list of key/value pairs where the keys are in ascending order, with a combining function on equal keys. :The precondition (input list is ascending) is not checked. fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "ba")]strict-containersO(n). Build a map from a list of key/value pairs where the keys are in ascending order, with a combining function on equal keys. :The precondition (input list is ascending) is not checked. let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value fromAscListWithKey f [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "5:b|a")]strict-containersO(n). Build a map from a list of key/value pairs where the keys are in ascending order and all distinct. The precondition (input list is strictly ascending) is not checked. fromDistinctAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")] strict-containersO(n). Build a map from a list of key/value pairs with monotonic keys and a combining function.The precise conditions under which this function works are subtle: For any branch mask, keys with the same prefix w.r.t. the branch mask must occur consecutively in the list.strict-containers-Should this key follow the left subtree of a  with switching bit m&? N.B., the answer is only valid when  match i p m is true.strict-containers Does the key i differ from the prefix p& before getting to the switching bit m?strict-containers Does the key i match the prefix p (up to but not including bit m)?strict-containersThe prefix of key i. up to (but not including) the switching bit m.strict-containersThe prefix of key i. up to (but not including) the switching bit m.strict-containers5Does the left switching bit specify a shorter prefix?strict-containers8The first switching bit where the two prefixes disagree.strict-containersO(1). Decompose a map into pieces based on the structure of the underlying tree. This function is useful for consuming a map in parallel.No guarantee is made as to the sizes of the pieces; an internal, but deterministic process determines this. However, it is guaranteed that the pieces returned will be in ascending order (all elements in the first submap less than all elements in the second, and so on). Examples: splitRoot (fromList (zip [1..6::Int] ['a'..])) == [fromList [(1,'a'),(2,'b'),(3,'c')],fromList [(4,'d'),(5,'e'),(6,'f')]] splitRoot empty == []Note that the current implementation does not return more than two submaps, but you should not depend on this behaviour because it can change in the future without notice.strict-containersO(n). Show the tree that implements the map. The tree is shown in a compressed, hanging format.strict-containersO(n). The expression ( hang wide map.) shows the tree that implements the map. If hang is  , a hanging6 tree is shown otherwise a rotated tree is shown. If wide is  !, an extra wide version is shown. strict-containers strict-containers strict-containers strict-containersstrict-containersstrict-containers%Traverses in order of increasing key.strict-containers!Folds in order of increasing key.strict-containers strict-containersEquivalent to  ReaderT k (ReaderT x (MaybeT f)). strict-containersEquivalent to  ReaderT k (ReaderT x (MaybeT f)). strict-containers strict-containers strict-containersEquivalent to .ReaderT Key (ReaderT x (ReaderT y (MaybeT f))) strict-containersEquivalent to .ReaderT Key (ReaderT x (ReaderT y (MaybeT f))) strict-containers strict-containersstrict-containers @since FIXMEstrict-containersWhat to do with keys in m1 but not m2strict-containersWhat to do with keys in m2 but not m1strict-containersWhat to do with keys in both m1 and m2strict-containersMap m1strict-containersMap m2strict-containersWhat to do with keys in m1 but not m2strict-containersWhat to do with keys in m2 but not m1strict-containersWhat to do with keys in both m1 and m2strict-containersMap m1strict-containersMap m2  9 9  Safe-InferredM Safe-Inferred1Nstrict-containers has moved to /strict-containers has moved to 0(c) Daan Leijen 2002 (c) Andriy Palamarchuk 2008 BSD-stylelibraries@haskell.orgportable Safe-Inferred/strict-containers O(\min(n,W)). The expression ( def k map) returns the value at key k or returns def, when the key is not an element of the map. findWithDefault 'x' 1 (fromList [(5,'a'), (3,'b')]) == 'x' findWithDefault 'x' 5 (fromList [(5,'a'), (3,'b')]) == 'a'strict-containersO(1). A map of one element. singleton 1 'a' == fromList [(1, 'a')] size (singleton 1 'a') == 1strict-containers O(\min(n,W)). Insert a new key/value pair in the map. If the key is already present in the map, the associated value is replaced with the supplied value, i.e.  is equivalent to   . insert 5 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'x')] insert 7 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'a'), (7, 'x')] insert 5 'x' empty == singleton 5 'x'strict-containers O(\min(n,W))%. Insert with a combining function.  f key value mp) will insert the pair (key, value) into mp if key does not exist in the map. If the key does exist, the function will insert f new_value old_value. insertWith (++) 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "xxxa")] insertWith (++) 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")] insertWith (++) 5 "xxx" empty == singleton 5 "xxx"strict-containers O(\min(n,W))%. Insert with a combining function.  f key value mp) will insert the pair (key, value) into mp if key does not exist in the map. If the key does exist, the function will insert f key new_value old_value. let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value insertWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:xxx|a")] insertWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")] insertWithKey f 5 "xxx" empty == singleton 5 "xxx"7If the key exists in the map, this function is lazy in value but strict in the result of f.strict-containers O(\min(n,W)). The expression ( f k x map2) is a pair where the first element is equal to ( k map$) and the second element equal to ( f k x map). let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value insertLookupWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "5:xxx|a")]) insertLookupWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "xxx")]) insertLookupWithKey f 5 "xxx" empty == (Nothing, singleton 5 "xxx")This is how to define  insertLookup using insertLookupWithKey: let insertLookup kx x t = insertLookupWithKey (\_ a _ -> a) kx x t insertLookup 5 "x" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "x")]) insertLookup 7 "x" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "x")])strict-containers O(\min(n,W)). Adjust a value at a specific key. When the key is not a member of the map, the original map is returned. adjust ("new " ++) 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")] adjust ("new " ++) 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] adjust ("new " ++) 7 empty == emptystrict-containers O(\min(n,W)). Adjust a value at a specific key. When the key is not a member of the map, the original map is returned. let f key x = (show key) ++ ":new " ++ x adjustWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")] adjustWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] adjustWithKey f 7 empty == emptystrict-containers O(\min(n,W)). The expression ( f k map) updates the value x at k (if it is in the map). If (f x) is  %, the element is deleted. If it is (  y ), the key k is bound to the new value y. let f x = if x == "a" then Just "new a" else Nothing update f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")] update f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] update f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"strict-containers O(\min(n,W)). The expression ( f k map) updates the value x at k (if it is in the map). If (f k x) is  %, the element is deleted. If it is (  y ), the key k is bound to the new value y. let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing updateWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")] updateWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] updateWithKey f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"strict-containers O(\min(n,W)). Lookup and update. The function returns original value, if it is updated. This is different behavior than ')>. Returns the original key value if the map entry is deleted. let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing updateLookupWithKey f 5 (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "5:new a")]) updateLookupWithKey f 7 (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a")]) updateLookupWithKey f 3 (fromList [(5,"a"), (3,"b")]) == (Just "b", singleton 5 "a")strict-containers O(\min(n,W)). The expression ( f k map) alters the value x at k, or absence thereof. 8 can be used to insert, delete, or update a value in an . In short :  k ( f k m) = f ( k m).strict-containers O(\log n). The expression ( f k map) alters the value x at k, or absence thereof.  can be used to inspect, insert, delete, or update a value in an . In short :  k  $  f k m = f ( k m).Example: interactiveAlter :: Int -> IntMap String -> IO (IntMap String) interactiveAlter k m = alterF f k m where f Nothing = do putStrLn $ show k ++ " was not found in the map. Would you like to add it?" getUserResponse1 :: IO (Maybe String) f (Just old) = do putStrLn $ "The key is currently bound to " ++ show old ++ ". Would you like to change or delete it?" getUserResponse2 :: IO (Maybe String)  is the most general operation for working with an individual key that may or may not be in a given map.strict-containers8The union of a list of maps, with a combining operation. unionsWith (++) [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])] == fromList [(3, "bB3"), (5, "aAA3"), (7, "C")]strict-containersO(n+m)&. The union with a combining function. unionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "aA"), (7, "C")]strict-containersO(n+m)&. The union with a combining function. let f key left_value right_value = (show key) ++ ":" ++ left_value ++ "|" ++ right_value unionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "5:a|A"), (7, "C")]strict-containersO(n+m)'. Difference with a combining function. let f al ar = if al == "b" then Just (al ++ ":" ++ ar) else Nothing differenceWith f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (7, "C")]) == singleton 3 "b:B"strict-containersO(n+m). Difference with a combining function. When two equal keys are encountered, the combining function is applied to the key and both values. If it returns  , the element is discarded (proper set difference). If it returns (  y+), the element is updated with a new value y. let f k al ar = if al == "b" then Just ((show k) ++ ":" ++ al ++ "|" ++ ar) else Nothing differenceWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (10, "C")]) == singleton 3 "3:b|B"strict-containersO(n+m)-. The intersection with a combining function. intersectionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "aA"strict-containersO(n+m)-. The intersection with a combining function. let f k al ar = (show k) ++ ":" ++ al ++ "|" ++ ar intersectionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "5:a|A"strict-containersO(n+m):. A high-performance universal combining function. Using , all combining functions can be defined without any loss of efficiency (with exception of ,  and ,, where sharing of some nodes is lost with ).6Please make sure you know what is going on when using , otherwise you can be surprised by unexpected code growth or even corruption of the data structure.When  is given three arguments, it is inlined to the call site. You should therefore use  only to define your custom combining functions. For example, you could define ,  and  as myUnionWithKey f m1 m2 = mergeWithKey (\k x1 x2 -> Just (f k x1 x2)) id id m1 m2 myDifferenceWithKey f m1 m2 = mergeWithKey f id (const empty) m1 m2 myIntersectionWithKey f m1 m2 = mergeWithKey (\k x1 x2 -> Just (f k x1 x2)) (const empty) (const empty) m1 m2 When calling  combine only1 only2, a function combining two s is created, such thatif a key is present in both maps, it is passed with both corresponding values to the combine function. Depending on the result, the key is either present in the result with specified value, or is left out;>a nonempty subtree present only in the first map is passed to only1* and the output is added to the result;?a nonempty subtree present only in the second map is passed to only2* and the output is added to the result.The only1 and only2 methods must return a map with a subset (possibly empty) of the keys of the given map. The values can be modified arbitrarily. Most common variants of only1 and only2 are   and   , but for example  f or  f could be used for any f.strict-containers O(\log n)&. Update the value at the minimal key. updateMinWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"3:b"), (5,"a")] updateMinWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"strict-containers O(\log n)&. Update the value at the maximal key. updateMaxWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"b"), (5,"5:a")] updateMaxWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"strict-containers O(\log n)&. Update the value at the maximal key. updateMax (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "Xa")] updateMax (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"strict-containers O(\log n)&. Update the value at the minimal key. updateMin (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "Xb"), (5, "a")] updateMin (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"strict-containersO(n),. Map a function over all values in the map. map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]strict-containersO(n),. Map a function over all values in the map. let f key x = (show key) ++ ":" ++ x mapWithKey f (fromList [(5,"a"), (3,"b")]) == fromList [(3, "3:b"), (5, "5:a")]strict-containersO(n).  f s ==   $   ((k, v) -> (,) k  $ f k v) ( m)* That is, behaves exactly like a regular   except that the traversing function also has access to the key associated with a value. traverseWithKey (\k v -> if odd k then Just (succ v) else Nothing) (fromList [(1, 'a'), (5, 'e')]) == Just (fromList [(1, 'b'), (5, 'f')]) traverseWithKey (\k v -> if odd k then Just (succ v) else Nothing) (fromList [(2, 'c')]) == Nothingstrict-containersO(n)'. Traverse keys/values and collect the   results.strict-containersO(n). The function  threads an accumulating argument through the map in ascending order of keys. let f a b = (a ++ b, b ++ "X") mapAccum f "Everything: " (fromList [(5,"a"), (3,"b")]) == ("Everything: ba", fromList [(3, "bX"), (5, "aX")])strict-containersO(n). The function  threads an accumulating argument through the map in ascending order of keys. let f a k b = (a ++ " " ++ (show k) ++ "-" ++ b, b ++ "X") mapAccumWithKey f "Everything:" (fromList [(5,"a"), (3,"b")]) == ("Everything: 3-b 5-a", fromList [(3, "bX"), (5, "aX")]) strict-containersO(n). The function   threads an accumulating argument through the map in ascending order of keys. Strict in the accumulating argument and the both elements of the result of the function.strict-containersO(n). The function  threads an accumulating argument through the map in descending order of keys.strict-containers O(n \log n).  c f s! is the map obtained by applying f to each key of s.)The size of the result may be smaller if f maps two or more distinct keys to the same new key. In this case the associated values will be combined using c. mapKeysWith (++) (\ _ -> 1) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 1 "cdab" mapKeysWith (++) (\ _ -> 3) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 3 "cdab"strict-containersO(n). Map values and collect the   results. let f x = if x == "a" then Just "new a" else Nothing mapMaybe f (fromList [(5,"a"), (3,"b")]) == singleton 5 "new a"strict-containersO(n)". Map keys/values and collect the   results. let f k _ = if k < 5 then Just ("key : " ++ (show k)) else Nothing mapMaybeWithKey f (fromList [(5,"a"), (3,"b")]) == singleton 3 "key : 3"strict-containersO(n). Map values and separate the   and   results. let f a = if a < "c" then Left a else Right a mapEither f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (fromList [(3,"b"), (5,"a")], fromList [(1,"x"), (7,"z")]) mapEither (\ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (empty, fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])strict-containersO(n)#. Map keys/values and separate the   and   results. let f k a = if k < 5 then Left (k * 2) else Right (a ++ a) mapEitherWithKey f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (fromList [(1,2), (3,6)], fromList [(5,"aa"), (7,"zz")]) mapEitherWithKey (\_ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (empty, fromList [(1,"x"), (3,"b"), (5,"a"), (7,"z")])strict-containersO(n). Build a map from a set of keys and a function which for each key computes its value. fromSet (\k -> replicate k 'a') (Data.IntSet.fromList [3, 5]) == fromList [(5,"aaaaa"), (3,"aaa")] fromSet undefined Data.IntSet.empty == emptystrict-containersO(n \min(n,W)).. Create a map from a list of key/value pairs. fromList [] == empty fromList [(5,"a"), (3,"b"), (5, "c")] == fromList [(5,"c"), (3,"b")] fromList [(5,"c"), (3,"b"), (5, "a")] == fromList [(5,"a"), (3,"b")]strict-containersO(n \min(n,W)). Create a map from a list of key/value pairs with a combining function. See also . fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "ab"), (5, "aba")] fromListWith (++) [] == emptystrict-containersO(n \min(n,W)). Build a map from a list of key/value pairs with a combining function. See also fromAscListWithKey'. fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "ab"), (5, "aba")] fromListWith (++) [] == emptystrict-containersO(n). Build a map from a list of key/value pairs where the keys are in ascending order. fromAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")] fromAscList [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "b")]strict-containersO(n). Build a map from a list of key/value pairs where the keys are in ascending order, with a combining function on equal keys. :The precondition (input list is ascending) is not checked. fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "ba")]strict-containersO(n). Build a map from a list of key/value pairs where the keys are in ascending order, with a combining function on equal keys. :The precondition (input list is ascending) is not checked. fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "ba")]strict-containersO(n). Build a map from a list of key/value pairs where the keys are in ascending order and all distinct. The precondition (input list is strictly ascending) is not checked. fromDistinctAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")] strict-containersO(n). Build a map from a list of key/value pairs with monotonic keys and a combining function.The precise conditions under which this function works are subtle: For any branch mask, keys with the same prefix w.r.t. the branch mask must occur consecutively in the list.1(c) Daan Leijen 2002 (c) Andriy Palamarchuk 2008 BSD-stylelibraries@haskell.orgportable Trustworthy(c) wren romano 2016 BSD-stylelibraries@haskell.orgportable Trustworthy strict-containersMap covariantly over a  f k x.strict-containersMap covariantly over a  f k x y.strict-containersWhen a key is found in both maps, apply a function to the key and values and maybe use the result in the merged map. zipWithMaybeMatched :: (k -> x -> y -> Maybe z) -> SimpleWhenMatched k x y z strict-containersWhen a key is found in both maps, apply a function to the key and values, perform the resulting action, and maybe use the result in the merged map.This is the fundamental  tactic.strict-containersWhen a key is found in both maps, apply a function to the key and values to produce an action and use its result in the merged map.strict-containersWhen a key is found in both maps, apply a function to the key and values and use the result in the merged map. zipWithMatched :: (k -> x -> y -> z) -> SimpleWhenMatched k x y z strict-containersMap over the entries whose keys are missing from the other map, optionally removing some. This is the most powerful 0 tactic, but others are usually more efficient. mapMaybeMissing :: (k -> x -> Maybe y) -> SimpleWhenMissing k x y ?mapMaybeMissing f = traverseMaybeMissing (\k x -> pure (f k x))but mapMaybeMissing uses fewer unnecessary   operations.strict-containers?Map over the entries whose keys are missing from the other map. 7mapMissing :: (k -> x -> y) -> SimpleWhenMissing k x y 5mapMissing f = mapMaybeMissing (\k x -> Just $ f k x)but  mapMissing is somewhat faster.strict-containersTraverse over the entries whose keys are missing from the other map, optionally producing values to put in the result. This is the most powerful 0 tactic, but others are usually more efficient.strict-containersTraverse over the entries whose keys are missing from the other map. Safe-Inferred/2 Safe-InferredU3 Safe-Inferred[4 (c) Daan Leijen 2002 (c) Andriy Palamarchuk 2008 BSD-stylelibraries@haskell.orgportable Trustworthy 5> strict-containers7A tactic for dealing with keys present in both maps in .A tactic of type  SimpleWhenMatched k x y z 6 is an abstract representation of a function of type  k -> x -> y -> Maybe z . strict-containers8A tactic for dealing with keys present in both maps in  or .A tactic of type  WhenMatched f k x y z 6 is an abstract representation of a function of type  k -> x -> y -> f (Maybe z) . strict-containersA tactic for dealing with keys present in one map but not the other in .A tactic of type  SimpleWhenMissing k x z 6 is an abstract representation of a function of type  k -> x -> Maybe z . strict-containersA tactic for dealing with keys present in one map but not the other in  or .A tactic of type  WhenMissing f k x z 6 is an abstract representation of a function of type  k -> x -> f (Maybe z) .strict-containersA Map from keys k to values a.The   operation for  is 2, which prefers values from the left operand. If m1 maps a key k to a value a1, and m2( maps the same key to a different value a2, then their union m1 <> m2 maps k to a1.strict-containers O(\log n)". Find the value at a key. Calls  # when the element can not be found. fromList [(5,'a'), (3,'b')] ! 1 Error: element not in the map fromList [(5,'a'), (3,'b')] ! 5 == 'a' strict-containers O(\log n)$. Find the value at a key. Returns  # when the element can not be found.-fromList [(5, 'a'), (3, 'b')] !? 1 == Nothing.fromList [(5, 'a'), (3, 'b')] !? 5 == Just 'a'strict-containersSame as .strict-containersO(1). Is the map empty? Data.Strict.Map.Autogen.null (empty) == True Data.Strict.Map.Autogen.null (singleton 1 'a') == Falsestrict-containersO(1)$. The number of elements in the map. size empty == 0 size (singleton 1 'a') == 1 size (fromList([(1,'a'), (2,'c'), (3,'b')])) == 3strict-containers O(\log n)'. Lookup the value at a key in the map.4The function will return the corresponding value as (  value), or   if the key isn't in the map.An example of using lookup: import Prelude hiding (lookup) import Data.Strict.Map.Autogen employeeDept = fromList([("John","Sales"), ("Bob","IT")]) deptCountry = fromList([("IT","USA"), ("Sales","France")]) countryCurrency = fromList([("USA", "Dollar"), ("France", "Euro")]) employeeCurrency :: String -> Maybe String employeeCurrency name = do dept <- lookup name employeeDept country <- lookup dept deptCountry lookup country countryCurrency main = do putStrLn $ "John's currency: " ++ (show (employeeCurrency "John")) putStrLn $ "Pete's currency: " ++ (show (employeeCurrency "Pete"))The output of this program: 9 John's currency: Just "Euro" Pete's currency: Nothingstrict-containers O(\log n)+. Is the key a member of the map? See also . member 5 (fromList [(5,'a'), (3,'b')]) == True member 1 (fromList [(5,'a'), (3,'b')]) == Falsestrict-containers O(\log n)/. Is the key not a member of the map? See also . notMember 5 (fromList [(5,'a'), (3,'b')]) == False notMember 1 (fromList [(5,'a'), (3,'b')]) == True strict-containers O(\log n)". Find the value at a key. Calls  # when the element can not be found.strict-containers O(\log n). The expression ( def k map) returns the value at key k or returns default value def! when the key is not in the map. findWithDefault 'x' 1 (fromList [(5,'a'), (3,'b')]) == 'x' findWithDefault 'x' 5 (fromList [(5,'a'), (3,'b')]) == 'a'strict-containers O(\log n). Find largest key smaller than the given one and return the corresponding (key, value) pair. lookupLT 3 (fromList [(3,'a'), (5,'b')]) == Nothing lookupLT 4 (fromList [(3,'a'), (5,'b')]) == Just (3, 'a')strict-containers O(\log n). Find smallest key greater than the given one and return the corresponding (key, value) pair. lookupGT 4 (fromList [(3,'a'), (5,'b')]) == Just (5, 'b') lookupGT 5 (fromList [(3,'a'), (5,'b')]) == Nothingstrict-containers O(\log n). Find largest key smaller or equal to the given one and return the corresponding (key, value) pair. lookupLE 2 (fromList [(3,'a'), (5,'b')]) == Nothing lookupLE 4 (fromList [(3,'a'), (5,'b')]) == Just (3, 'a') lookupLE 5 (fromList [(3,'a'), (5,'b')]) == Just (5, 'b')strict-containers O(\log n). Find smallest key greater or equal to the given one and return the corresponding (key, value) pair. lookupGE 3 (fromList [(3,'a'), (5,'b')]) == Just (3, 'a') lookupGE 4 (fromList [(3,'a'), (5,'b')]) == Just (5, 'b') lookupGE 6 (fromList [(3,'a'), (5,'b')]) == Nothingstrict-containersO(1). The empty map. )empty == fromList [] size empty == 0strict-containersO(1). A map with a single element. singleton 1 'a' == fromList [(1, 'a')] size (singleton 1 'a') == 1strict-containers O(\log n). Insert a new key and value in the map. If the key is already present in the map, the associated value is replaced with the supplied value.  is equivalent to   . insert 5 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'x')] insert 7 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'a'), (7, 'x')] insert 5 'x' empty == singleton 5 'x'strict-containers O(\log n)>. Insert with a function, combining new value and old value.  f key value mp) will insert the pair (key, value) into mp if key does not exist in the map. If the key does exist, the function will insert the pair (key, f new_value old_value). insertWith (++) 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "xxxa")] insertWith (++) 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")] insertWith (++) 5 "xxx" empty == singleton 5 "xxx" strict-containersA helper function for . When the key is already in the map, the key is left alone, not replaced. The combining function is flipped--it is applied to the old value and then the new value.strict-containers O(\log n). Insert with a function, combining key, new value and old value.  f key value mp) will insert the pair (key, value) into mp if key does not exist in the map. If the key does exist, the function will insert the pair (key,f key new_value old_value);. Note that the key passed to f is the same key passed to . let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value insertWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:xxx|a")] insertWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")] insertWithKey f 5 "xxx" empty == singleton 5 "xxx" strict-containersA helper function for . When the key is already in the map, the key is left alone, not replaced. The combining function is flipped--it is applied to the old value and then the new value.strict-containers O(\log n). Combines insert operation with old value retrieval. The expression ( f k x map2) is a pair where the first element is equal to ( k map$) and the second element equal to ( f k x map). let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value insertLookupWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "5:xxx|a")]) insertLookupWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "xxx")]) insertLookupWithKey f 5 "xxx" empty == (Nothing, singleton 5 "xxx")This is how to define  insertLookup using insertLookupWithKey: let insertLookup kx x t = insertLookupWithKey (\_ a _ -> a) kx x t insertLookup 5 "x" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "x")]) insertLookup 7 "x" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "x")])strict-containers O(\log n). Delete a key and its value from the map. When the key is not a member of the map, the original map is returned. delete 5 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" delete 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] delete 5 empty == emptystrict-containers O(\log n). Update a value at a specific key with the result of the provided function. When the key is not a member of the map, the original map is returned. adjust ("new " ++) 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")] adjust ("new " ++) 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] adjust ("new " ++) 7 empty == emptystrict-containers O(\log n). Adjust a value at a specific key. When the key is not a member of the map, the original map is returned. let f key x = (show key) ++ ":new " ++ x adjustWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")] adjustWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] adjustWithKey f 7 empty == emptystrict-containers O(\log n). The expression ( f k map) updates the value x at k (if it is in the map). If (f x) is  %, the element is deleted. If it is (  y ), the key k is bound to the new value y. let f x = if x == "a" then Just "new a" else Nothing update f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")] update f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] update f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"strict-containers O(\log n). The expression ( f k map) updates the value x at k (if it is in the map). If (f k x) is  %, the element is deleted. If it is (  y ), the key k is bound to the new value y. let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing updateWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")] updateWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] updateWithKey f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"strict-containers O(\log n). Lookup and update. See also . The function returns changed value, if it is updated. Returns the original key value if the map entry is deleted. let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing updateLookupWithKey f 5 (fromList [(5,"a"), (3,"b")]) == (Just "5:new a", fromList [(3, "b"), (5, "5:new a")]) updateLookupWithKey f 7 (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a")]) updateLookupWithKey f 3 (fromList [(5,"a"), (3,"b")]) == (Just "b", singleton 5 "a")strict-containers O(\log n). The expression ( f k map) alters the value x at k, or absence thereof. 7 can be used to insert, delete, or update a value in a . In short :  k ( f k m) = f ( k m). let f _ = Nothing alter f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] alter f 5 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" let f _ = Just "c" alter f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "c")] alter f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "c")] Note that  = alter . fmap.strict-containers O(\log n). The expression ( f k map) alters the value x at k, or absence thereof.  can be used to inspect, insert, delete, or update a value in a  . In short:  k <$>  f k m = f ( k m).Example: interactiveAlter :: Int -> Map Int String -> IO (Map Int String) interactiveAlter k m = alterF f k m where f Nothing = do putStrLn $ show k ++ " was not found in the map. Would you like to add it?" getUserResponse1 :: IO (Maybe String) f (Just old) = do putStrLn $ "The key is currently bound to " ++ show old ++ ". Would you like to change or delete it?" getUserResponse2 :: IO (Maybe String)  is the most general operation for working with an individual key that may or may not be in a given map. When used with trivial functors like  and  , it is often slightly slower than more specialized combinators like  and . However, when the functor is non-trivial and key comparison is not particularly cheap, it is the fastest way.Note on rewrite rules:3This module includes GHC rewrite rules to optimize  for the   and  functors. In general, these rules improve performance. The sole exception is that when using , deleting a key that is already absent takes longer than it would without the rules. If you expect this to occur a very large fraction of the time, you might consider using a private copy of the  type.Note:  is a flipped version of the at combinator from Control.Lens.At.strict-containers O(\log n) . Return the index of a key, which is its zero-based index in the sequence sorted by keys. The index is a number from 0 up to, but not including, the  of the map. Calls   when the key is not a  of the map. findIndex 2 (fromList [(5,"a"), (3,"b")]) Error: element is not in the map findIndex 3 (fromList [(5,"a"), (3,"b")]) == 0 findIndex 5 (fromList [(5,"a"), (3,"b")]) == 1 findIndex 6 (fromList [(5,"a"), (3,"b")]) Error: element is not in the mapstrict-containers O(\log n) . Lookup the index of a key, which is its zero-based index in the sequence sorted by keys. The index is a number from 0 up to, but not including, the  of the map. isJust (lookupIndex 2 (fromList [(5,"a"), (3,"b")])) == False fromJust (lookupIndex 3 (fromList [(5,"a"), (3,"b")])) == 0 fromJust (lookupIndex 5 (fromList [(5,"a"), (3,"b")])) == 1 isJust (lookupIndex 6 (fromList [(5,"a"), (3,"b")])) == Falsestrict-containers O(\log n). Retrieve an element by its index, i.e. by its zero-based index in the sequence sorted by keys. If the index7 is out of range (less than zero, greater or equal to  of the map),   is called. elemAt 0 (fromList [(5,"a"), (3,"b")]) == (3,"b") elemAt 1 (fromList [(5,"a"), (3,"b")]) == (5, "a") elemAt 2 (fromList [(5,"a"), (3,"b")]) Error: index out of rangestrict-containersTake a given number of entries in key order, beginning with the smallest keys.  take n =  . +4 n .  strict-containersDrop a given number of entries in key order, beginning with the smallest keys.  drop n =  . +5 n .  strict-containers O(\log n)$. Split a map at a particular index. splitAt !n !xs = ( n xs,  n xs) strict-containers O(\log n). Update the element at index, i.e. by its zero-based index in the sequence sorted by keys. If the index7 is out of range (less than zero, greater or equal to  of the map),   is called. updateAt (\ _ _ -> Just "x") 0 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "x"), (5, "a")] updateAt (\ _ _ -> Just "x") 1 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "x")] updateAt (\ _ _ -> Just "x") 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range updateAt (\ _ _ -> Just "x") (-1) (fromList [(5,"a"), (3,"b")]) Error: index out of range updateAt (\_ _ -> Nothing) 0 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a" updateAt (\_ _ -> Nothing) 1 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" updateAt (\_ _ -> Nothing) 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range updateAt (\_ _ -> Nothing) (-1) (fromList [(5,"a"), (3,"b")]) Error: index out of rangestrict-containers O(\log n). Delete the element at index, i.e. by its zero-based index in the sequence sorted by keys. If the index7 is out of range (less than zero, greater or equal to  of the map),   is called. deleteAt 0 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a" deleteAt 1 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" deleteAt 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range deleteAt (-1) (fromList [(5,"a"), (3,"b")]) Error: index out of range strict-containers O(\log n)&. The minimal key of the map. Returns   if the map is empty. lookupMin (fromList [(5,"a"), (3,"b")]) == Just (3,"b") lookupMin empty = Nothingstrict-containers O(\log n)$. The minimal key of the map. Calls   if the map is empty. findMin (fromList [(5,"a"), (3,"b")]) == (3,"b") findMin empty Error: empty map has no minimal element strict-containers O(\log n)$. The maximal key of the map. Calls   if the map is empty. findMax (fromList [(5,"a"), (3,"b")]) == (5,"a") findMax empty Error: empty map has no maximal element strict-containers O(\log n)&. The maximal key of the map. Returns   if the map is empty. lookupMax (fromList [(5,"a"), (3,"b")]) == Just (5,"a") lookupMax empty = Nothingstrict-containers O(\log n). Delete the minimal key. Returns an empty map if the map is empty. deleteMin (fromList [(5,"a"), (3,"b"), (7,"c")]) == fromList [(5,"a"), (7,"c")] deleteMin empty == emptystrict-containers O(\log n). Delete the maximal key. Returns an empty map if the map is empty. deleteMax (fromList [(5,"a"), (3,"b"), (7,"c")]) == fromList [(3,"b"), (5,"a")] deleteMax empty == emptystrict-containers O(\log n)&. Update the value at the minimal key. updateMin (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "Xb"), (5, "a")] updateMin (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"strict-containers O(\log n)&. Update the value at the maximal key. updateMax (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "Xa")] updateMax (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"strict-containers O(\log n)&. Update the value at the minimal key. updateMinWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"3:b"), (5,"a")] updateMinWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"strict-containers O(\log n)&. Update the value at the maximal key. updateMaxWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"b"), (5,"5:a")] updateMaxWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"strict-containers O(\log n). Retrieves the minimal (key,value) pair of the map, and the map stripped of that element, or   if passed an empty map. minViewWithKey (fromList [(5,"a"), (3,"b")]) == Just ((3,"b"), singleton 5 "a") minViewWithKey empty == Nothingstrict-containers O(\log n). Retrieves the maximal (key,value) pair of the map, and the map stripped of that element, or   if passed an empty map. maxViewWithKey (fromList [(5,"a"), (3,"b")]) == Just ((5,"a"), singleton 3 "b") maxViewWithKey empty == Nothingstrict-containers O(\log n). Retrieves the value associated with minimal key of the map, and the map stripped of that element, or   if passed an empty map. minView (fromList [(5,"a"), (3,"b")]) == Just ("b", singleton 5 "a") minView empty == Nothingstrict-containers O(\log n). Retrieves the value associated with maximal key of the map, and the map stripped of that element, or   if passed an empty map. maxView (fromList [(5,"a"), (3,"b")]) == Just ("a", singleton 3 "b") maxView empty == Nothingstrict-containers!The union of a list of maps: ( == +-  ). unions [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])] == fromList [(3, "b"), (5, "a"), (7, "C")] unions [(fromList [(5, "A3"), (3, "B3")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "a"), (3, "b")])] == fromList [(3, "B3"), (5, "A3"), (7, "C")]strict-containers=The union of a list of maps, with a combining operation: ( f == +- ( f) ). unionsWith (++) [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])] == fromList [(3, "bB3"), (5, "aAA3"), (7, "C")]strict-containers;O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n. The expression ( t1 t2!) takes the left-biased union of t1 and t2. It prefers t1- when duplicate keys are encountered, i.e. ( ==   ). union (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "a"), (7, "C")]strict-containers;O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n". Union with a combining function. unionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "aA"), (7, "C")]strict-containers;O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n#. Union with a combining function. let f key left_value right_value = (show key) ++ ":" ++ left_value ++ "|" ++ right_value unionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "5:a|A"), (7, "C")]strict-containers;O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n. Difference of two maps. Return elements of the first map not existing in the second map. difference (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 3 "b"strict-containers;O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n. Remove all keys in a   from a . m `withoutKeys` s =  (k _ -> k   s) m m `withoutKeys` s = m   (const ()) s strict-containersO(n+m). Difference with a combining function. When two equal keys are encountered, the combining function is applied to the values of these keys. If it returns  , the element is discarded (proper set difference). If it returns (  y+), the element is updated with a new value y. let f al ar = if al == "b" then Just (al ++ ":" ++ ar) else Nothing differenceWith f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (7, "C")]) == singleton 3 "b:B"strict-containersO(n+m). Difference with a combining function. When two equal keys are encountered, the combining function is applied to the key and both values. If it returns  , the element is discarded (proper set difference). If it returns (  y+), the element is updated with a new value y. let f k al ar = if al == "b" then Just ((show k) ++ ":" ++ al ++ "|" ++ ar) else Nothing differenceWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (10, "C")]) == singleton 3 "3:b|B"strict-containers;O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n. Intersection of two maps. Return data in the first map for the keys existing in both maps. ( m1 m2 ==    m1 m2). intersection (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "a"strict-containers;O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n . Restrict a  to only those keys found in a  . m `restrictKeys` s =  (k _ -> k   s) m m `restrictKeys` s = m   (const ()) s strict-containers;O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n). Intersection with a combining function. intersectionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "aA"strict-containers;O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n). Intersection with a combining function. let f k al ar = (show k) ++ ":" ++ al ++ "|" ++ ar intersectionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "5:a|A"strict-containers;O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n. Check whether the key sets of two maps are disjoint (i.e., their  is empty). disjoint (fromList [(2,'a')]) (fromList [(1,()), (3,())]) == True disjoint (fromList [(2,'a')]) (fromList [(1,'a'), (2,'b')]) == False disjoint (fromList []) (fromList []) == True xs  ys = null (xs  ys) strict-containersRelate the keys of one map to the values of the other, by using the values of the former as keys for lookups in the latter. Complexity:  O (n * \log(m)) , where m" is the size of the first argument compose (fromList [('a', "A"), ('b', "B")]) (fromList [(1,'a'),(2,'b'),(3,'z')]) = fromList [(1,"A"),(2,"B")] ( bc ab ) = (bc  ) <=< (ab ) Note: Prior to v0.6.4, Data.Strict.Map.Autogen.Strict exposed a version of & that forced the values of the output ,. This version does not force these values. strict-containersMap covariantly over a  f k x.strict-containersMap covariantly over a  f k x', using only a 'Functor f' constraint.strict-containersMap covariantly over a  f k x', using only a 'Functor f' constraint. strict-containersMap contravariantly over a  f k _ x. strict-containersMap contravariantly over a  f k _ y z. strict-containersMap contravariantly over a  f k x _ z. strict-containersAlong with zipWithMaybeAMatched, witnesses the isomorphism between WhenMatched f k x y z and k -> x -> y -> f (Maybe z). strict-containersAlong with traverseMaybeMissing, witnesses the isomorphism between WhenMissing f k x y and k -> x -> f (Maybe y). strict-containersMap covariantly over a  f k x y. strict-containersWhen a key is found in both maps, apply a function to the key and values and use the result in the merged map. zipWithMatched :: (k -> x -> y -> z) -> SimpleWhenMatched k x y z  strict-containersWhen a key is found in both maps, apply a function to the key and values to produce an action and use its result in the merged map. strict-containersWhen a key is found in both maps, apply a function to the key and values and maybe use the result in the merged map. zipWithMaybeMatched :: (k -> x -> y -> Maybe z) -> SimpleWhenMatched k x y z  strict-containersWhen a key is found in both maps, apply a function to the key and values, perform the resulting action, and maybe use the result in the merged map.This is the fundamental  tactic. strict-containersDrop all the entries whose keys are missing from the other map. 'dropMissing :: SimpleWhenMissing k x y /dropMissing = mapMaybeMissing (\_ _ -> Nothing)but  dropMissing is much faster. strict-containersPreserve, unchanged, the entries whose keys are missing from the other map. +preserveMissing :: SimpleWhenMissing k x x =preserveMissing = Merge.Lazy.mapMaybeMissing (\_ x -> Just x)but preserveMissing is much faster. strict-containersForce the entries whose keys are missing from the other map and otherwise preserve them unchanged. ,preserveMissing' :: SimpleWhenMissing k x x preserveMissing' = Merge.Lazy.mapMaybeMissing (\_ x -> Just $! x)but preserveMissing' is quite a bit faster. strict-containers?Map over the entries whose keys are missing from the other map. 7mapMissing :: (k -> x -> y) -> SimpleWhenMissing k x y 5mapMissing f = mapMaybeMissing (\k x -> Just $ f k x)but  mapMissing is somewhat faster. strict-containersMap over the entries whose keys are missing from the other map, optionally removing some. This is the most powerful 0 tactic, but others are usually more efficient. mapMaybeMissing :: (k -> x -> Maybe y) -> SimpleWhenMissing k x y ?mapMaybeMissing f = traverseMaybeMissing (\k x -> pure (f k x))but mapMaybeMissing uses fewer unnecessary   operations. strict-containers=Filter the entries whose keys are missing from the other map. =filterMissing :: (k -> x -> Bool) -> SimpleWhenMissing k x x filterMissing f = Merge.Lazy.mapMaybeMissing $ \k x -> guard (f k x) *> Just x#but this should be a little faster. strict-containersFilter the entries whose keys are missing from the other map using some   action. filterAMissing f = Merge.Lazy.traverseMaybeMissing $ k x -> (b -> guard b *> Just x)  $ f k x #but this should be a little faster. strict-containers:This wasn't in Data.Bool until 4.7.0, so we define it here strict-containersTraverse over the entries whose keys are missing from the other map. strict-containersTraverse over the entries whose keys are missing from the other map, optionally producing values to put in the result. This is the most powerful 0 tactic, but others are usually more efficient. strict-containersMerge two maps. takes two  tactics, a  tactic and two maps. It uses the tactics to merge the maps. Its behavior is best understood via its fundamental tactics,  and .Consider merge (mapMaybeMissing g1) (mapMaybeMissing g2) (zipWithMaybeMatched f) m1 m2 Take, for example, m1 = [(0, 'a'), (1, 'b'), (3, 'c'), (4, 'd')] m2 = [(1, "one"), (2, "two"), (4, "three")] & will first "align" these maps by key: m1 = [(0, 'a'), (1, 'b'), (3, 'c'), (4, 'd')] m2 = [(1, "one"), (2, "two"), (4, "three")] It will then pass the individual entries and pairs of entries to g1, g2, or f as appropriate: maybes = [g1 0 'a', f 1 'b' "one", g2 2 "two", g1 3 'c', f 4 'd' "three"] This produces a   for each key: keys = 0 1 2 3 4 results = [Nothing, Just True, Just False, Nothing, Just True]  Finally, the Just" results are collected into a map: 2return value = [(1, True), (2, False), (4, True)] The other tactics below are optimizations or simplifications of % for special cases. Most importantly, drops all the keys. leaves all the entries alone.When  is given three arguments, it is inlined at the call site. To prevent excessive inlining, you should typically use , to define your custom combining functions. Examples:unionWithKey f = merge preserveMissing preserveMissing (zipWithMatched f)intersectionWithKey f = merge dropMissing dropMissing (zipWithMatched f)differenceWith f = merge preserveMissing dropMissing (zipWithMatched f)symmetricDifference = merge preserveMissing preserveMissing (zipWithMaybeMatched $ \ _ _ _ -> Nothing)mapEachPiece f g h = merge (mapMissing f) (mapMissing g) (zipWithMatched h) strict-containersAn applicative version of . takes two  tactics, a  tactic and two maps. It uses the tactics to merge the maps. Its behavior is best understood via its fundamental tactics,  and .Consider mergeA (traverseMaybeMissing g1) (traverseMaybeMissing g2) (zipWithMaybeAMatched f) m1 m2 Take, for example, m1 = [(0, 'a'), (1, 'b'), (3, 'c'), (4, 'd')] m2 = [(1, "one"), (2, "two"), (4, "three")] mergeA& will first "align" these maps by key: m1 = [(0, 'a'), (1, 'b'), (3, 'c'), (4, 'd')] m2 = [(1, "one"), (2, "two"), (4, "three")] It will then pass the individual entries and pairs of entries to g1, g2, or f as appropriate: actions = [g1 0 'a', f 1 'b' "one", g2 2 "two", g1 3 'c', f 4 'd' "three"] )Next, it will perform the actions in the actions# list in order from left to right. keys = 0 1 2 3 4 results = [Nothing, Just True, Just False, Nothing, Just True]  Finally, the Just" results are collected into a map: 2return value = [(1, True), (2, False), (4, True)] The other tactics below are optimizations or simplifications of % for special cases. Most importantly, drops all the keys. leaves all the entries alone. does not use the   context.When  is given three arguments, it is inlined at the call site. To prevent excessive inlining, you should generally only use & to define custom combining functions.strict-containersO(n+m)'. An unsafe general combining function.WARNING: This function can produce corrupt maps and its results may depend on the internal structures of its inputs. Users should prefer  or .When  is given three arguments, it is inlined to the call site. You should therefore use  only to define custom combining functions. For example, you could define ,  and  as myUnionWithKey f m1 m2 = mergeWithKey (\k x1 x2 -> Just (f k x1 x2)) id id m1 m2 myDifferenceWithKey f m1 m2 = mergeWithKey f id (const empty) m1 m2 myIntersectionWithKey f m1 m2 = mergeWithKey (\k x1 x2 -> Just (f k x1 x2)) (const empty) (const empty) m1 m2 When calling  combine only1 only2, a function combining two s is created, such thatif a key is present in both maps, it is passed with both corresponding values to the combine function. Depending on the result, the key is either present in the result with specified value, or is left out;>a nonempty subtree present only in the first map is passed to only1* and the output is added to the result;?a nonempty subtree present only in the second map is passed to only2* and the output is added to the result.The only1 and only2 methods must return a map with a subset (possibly empty) of the keys of the given map. The values can be modified arbitrarily. Most common variants of only1 and only2 are   and   , but for example  f,  f, or  f could be used for any f.strict-containers;O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n . This function is defined as ( =  (==)).strict-containers;O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n. The expression ( f t1 t2 ) returns   if all keys in t1 are in tree t2 , and when f returns   when applied to their respective values. For example, the following expressions are all  : isSubmapOfBy (==) (fromList [('a',1)]) (fromList [('a',1),('b',2)]) isSubmapOfBy (<=) (fromList [('a',1)]) (fromList [('a',1),('b',2)]) isSubmapOfBy (==) (fromList [('a',1),('b',2)]) (fromList [('a',1),('b',2)])But the following are all  : isSubmapOfBy (==) (fromList [('a',2)]) (fromList [('a',1),('b',2)]) isSubmapOfBy (<) (fromList [('a',1)]) (fromList [('a',1),('b',2)]) isSubmapOfBy (==) (fromList [('a',1),('b',2)]) (fromList [('a',1)]) Note that  isSubmapOfBy (_ _ -> True) m1 m2 tests whether all the keys in m1 are also keys in m2.strict-containers;O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n. Is this a proper submap? (ie. a submap but not equal). Defined as ( =  (==)).strict-containers;O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n. Is this a proper submap? (ie. a submap but not equal). The expression ( f m1 m2 ) returns   when keys m1 and keys m2 are not equal, all keys in m1 are in m2 , and when f returns   when applied to their respective values. For example, the following expressions are all  : isProperSubmapOfBy (==) (fromList [(1,1)]) (fromList [(1,1),(2,2)]) isProperSubmapOfBy (<=) (fromList [(1,1)]) (fromList [(1,1),(2,2)])But the following are all  : isProperSubmapOfBy (==) (fromList [(1,1),(2,2)]) (fromList [(1,1),(2,2)]) isProperSubmapOfBy (==) (fromList [(1,1),(2,2)]) (fromList [(1,1)]) isProperSubmapOfBy (<) (fromList [(1,1)]) (fromList [(1,1),(2,2)])strict-containersO(n)/. Filter all values that satisfy the predicate. filter (> "a") (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" filter (> "x") (fromList [(5,"a"), (3,"b")]) == empty filter (< "a") (fromList [(5,"a"), (3,"b")]) == emptystrict-containersO(n)4. Filter all keys/values that satisfy the predicate. filterWithKey (\k _ -> k > 4) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a" strict-containersO(n)". Filter keys and values using an   predicate.strict-containers O(\log n). Take while a predicate on the keys holds. The user is responsible for ensuring that for all keys j and k in the map, j < k ==> p j >= p k. See note at . takeWhileAntitone p =  . 67 (p . fst) .  takeWhileAntitone p =  (k _ -> p k) strict-containers O(\log n). Drop while a predicate on the keys holds. The user is responsible for ensuring that for all keys j and k in the map, j < k ==> p j >= p k. See note at . dropWhileAntitone p =  . 68 (p . fst) .  dropWhileAntitone p =  (k -> not (p k)) strict-containers O(\log n). Divide a map at the point where a predicate on the keys stops holding. The user is responsible for ensuring that for all keys j and k in the map, j < k ==> p j >= p k. spanAntitone p xs = ( p xs, < p xs) spanAntitone p xs = partitionWithKey (k _ -> p k) xs  Note: if p is not actually antitone, then  spanAntitone will split the map at some  unspecified point where the predicate switches from holding to not holding (where the predicate is seen to hold before the first key and to fail after the last key).strict-containersO(n). Partition the map according to a predicate. The first map contains all elements that satisfy the predicate, the second all elements that fail the predicate. See also . partition (> "a") (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a") partition (< "x") (fromList [(5,"a"), (3,"b")]) == (fromList [(3, "b"), (5, "a")], empty) partition (> "x") (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3, "b"), (5, "a")])strict-containersO(n). Partition the map according to a predicate. The first map contains all elements that satisfy the predicate, the second all elements that fail the predicate. See also . partitionWithKey (\ k _ -> k > 3) (fromList [(5,"a"), (3,"b")]) == (singleton 5 "a", singleton 3 "b") partitionWithKey (\ k _ -> k < 7) (fromList [(5,"a"), (3,"b")]) == (fromList [(3, "b"), (5, "a")], empty) partitionWithKey (\ k _ -> k > 7) (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3, "b"), (5, "a")])strict-containersO(n). Map values and collect the   results. let f x = if x == "a" then Just "new a" else Nothing mapMaybe f (fromList [(5,"a"), (3,"b")]) == singleton 5 "new a"strict-containersO(n)". Map keys/values and collect the   results. let f k _ = if k < 5 then Just ("key : " ++ (show k)) else Nothing mapMaybeWithKey f (fromList [(5,"a"), (3,"b")]) == singleton 3 "key : 3"strict-containersO(n)'. Traverse keys/values and collect the   results.strict-containersO(n). Map values and separate the   and   results. let f a = if a < "c" then Left a else Right a mapEither f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (fromList [(3,"b"), (5,"a")], fromList [(1,"x"), (7,"z")]) mapEither (\ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (empty, fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])strict-containersO(n)#. Map keys/values and separate the   and   results. let f k a = if k < 5 then Left (k * 2) else Right (a ++ a) mapEitherWithKey f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (fromList [(1,2), (3,6)], fromList [(5,"aa"), (7,"zz")]) mapEitherWithKey (\_ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (empty, fromList [(1,"x"), (3,"b"), (5,"a"), (7,"z")])strict-containersO(n),. Map a function over all values in the map. map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]strict-containersO(n),. Map a function over all values in the map. let f key x = (show key) ++ ":" ++ x mapWithKey f (fromList [(5,"a"), (3,"b")]) == fromList [(3, "3:b"), (5, "5:a")]strict-containersO(n).  f m ==   $   ((k, v) -> (,) k  $ f k v) ( m)* That is, behaves exactly like a regular   except that the traversing function also has access to the key associated with a value. traverseWithKey (\k v -> if odd k then Just (succ v) else Nothing) (fromList [(1, 'a'), (5, 'e')]) == Just (fromList [(1, 'b'), (5, 'f')]) traverseWithKey (\k v -> if odd k then Just (succ v) else Nothing) (fromList [(2, 'c')]) == Nothingstrict-containersO(n). The function  threads an accumulating argument through the map in ascending order of keys. let f a b = (a ++ b, b ++ "X") mapAccum f "Everything: " (fromList [(5,"a"), (3,"b")]) == ("Everything: ba", fromList [(3, "bX"), (5, "aX")])strict-containersO(n). The function  threads an accumulating argument through the map in ascending order of keys. let f a k b = (a ++ " " ++ (show k) ++ "-" ++ b, b ++ "X") mapAccumWithKey f "Everything:" (fromList [(5,"a"), (3,"b")]) == ("Everything: 3-b 5-a", fromList [(3, "bX"), (5, "aX")]) strict-containersO(n). The function   threads an accumulating argument through the map in ascending order of keys.strict-containersO(n). The function  threads an accumulating argument through the map in descending order of keys.strict-containers O(n \log n).  f s! is the map obtained by applying f to each key of s.)The size of the result may be smaller if f maps two or more distinct keys to the same new key. In this case the value at the greatest of the original keys is retained. mapKeys (+ 1) (fromList [(5,"a"), (3,"b")]) == fromList [(4, "b"), (6, "a")] mapKeys (\ _ -> 1) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 1 "c" mapKeys (\ _ -> 3) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 3 "c"strict-containers O(n \log n).  c f s! is the map obtained by applying f to each key of s.)The size of the result may be smaller if f maps two or more distinct keys to the same new key. In this case the associated values will be combined using c. The value at the greater of the two original keys is used as the first argument to c. mapKeysWith (++) (\ _ -> 1) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 1 "cdab" mapKeysWith (++) (\ _ -> 3) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 3 "cdab"strict-containersO(n).  f s ==  f s, but works only when f2 is strictly monotonic. That is, for any values x and y, if x < y then f x < f y.  The precondition is not checked. Semi-formally, we have: and [x < y ==> f x < f y | x <- ls, y <- ls] ==> mapKeysMonotonic f s == mapKeys f s where ls = keys sThis means that f maps distinct original keys to distinct resulting keys. This function has better performance than . mapKeysMonotonic (\ k -> k * 2) (fromList [(5,"a"), (3,"b")]) == fromList [(6, "b"), (10, "a")] valid (mapKeysMonotonic (\ k -> k * 2) (fromList [(5,"a"), (3,"b")])) == True valid (mapKeysMonotonic (\ _ -> 1) (fromList [(5,"a"), (3,"b")])) == Falsestrict-containersO(n). Fold the values in the map using the given right-associative binary operator, such that  f z == +, f z . . For example, elems map = foldr (:) [] map let f a len = len + (length a) foldr f 0 (fromList [(5,"a"), (3,"bbb")]) == 4strict-containersO(n). A strict version of . Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.strict-containersO(n). Fold the values in the map using the given left-associative binary operator, such that  f z == +- f z . . For example, %elems = reverse . foldl (flip (:)) [] let f len a = len + (length a) foldl f 0 (fromList [(5,"a"), (3,"bbb")]) == 4strict-containersO(n). A strict version of . Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.strict-containersO(n). Fold the keys and values in the map using the given right-associative binary operator, such that  f z == +, (  f) z . . For example, 0keys map = foldrWithKey (\k x ks -> k:ks) [] map let f k a result = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")" foldrWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (5:a)(3:b)"strict-containersO(n). A strict version of . Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.strict-containersO(n). Fold the keys and values in the map using the given left-associative binary operator, such that  f z == +- (\z' (kx, x) -> f z' kx x) z . . For example, 2keys = reverse . foldlWithKey (\ks k x -> k:ks) [] let f result k a = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")" foldlWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (3:b)(5:a)"strict-containersO(n). A strict version of . Each application of the operator is evaluated before using the result in the next application. This function is strict in the starting value.strict-containersO(n). Fold the keys and values in the map using the given monoid, such that  f = +. .  f*This can be an asymptotically faster than  or  for some monoids.strict-containersO(n). Return all elements of the map in the ascending order of their keys. Subject to list fusion. elems (fromList [(5,"a"), (3,"b")]) == ["b","a"] elems empty == []strict-containersO(n). Return all keys of the map in ascending order. Subject to list fusion.  replicate k 'a') (Data.Set.fromList [3, 5]) == fromList [(5,"aaaaa"), (3,"aaa")] fromSet undefined Data.Set.empty == emptystrict-containersO(n)6. Build a map from a set of elements contained inside  s. fromArgSet (Data.Set.fromList [Arg 3 "aaa", Arg 5 "aaaaa"]) == fromList [(5,"aaaaa"), (3,"aaa")] fromArgSet Data.Set.empty == emptystrict-containers O(n \log n)7. Build a map from a list of key/value pairs. See also . If the list contains more than one value for the same key, the last value for the key is retained.If the keys of the list are ordered, linear-time implementation is used, with the performance equal to . fromList [] == empty fromList [(5,"a"), (3,"b"), (5, "c")] == fromList [(5,"c"), (3,"b")] fromList [(5,"c"), (3,"b"), (5, "a")] == fromList [(5,"a"), (3,"b")]strict-containers O(n \log n). Build a map from a list of key/value pairs with a combining function. See also . fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "ab"), (5, "aba")] fromListWith (++) [] == emptystrict-containers O(n \log n). Build a map from a list of key/value pairs with a combining function. See also . let f k a1 a2 = (show k) ++ a1 ++ a2 fromListWithKey f [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "3ab"), (5, "5a5ba")] fromListWithKey f [] == emptystrict-containersO(n). Convert the map to a list of key/value pairs. Subject to list fusion. toList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")] toList empty == []strict-containersO(n). Convert the map to a list of key/value pairs where the keys are in ascending order. Subject to list fusion. =toAscList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]strict-containersO(n). Convert the map to a list of key/value pairs where the keys are in descending order. Subject to list fusion. >toDescList (fromList [(5,"a"), (3,"b")]) == [(5,"a"), (3,"b")]strict-containersO(n)6. Build a map from an ascending list in linear time. :The precondition (input list is ascending) is not checked. fromAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")] fromAscList [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "b")] valid (fromAscList [(3,"b"), (5,"a"), (5,"b")]) == True valid (fromAscList [(5,"a"), (3,"b"), (5,"b")]) == Falsestrict-containersO(n)6. Build a map from a descending list in linear time. ;The precondition (input list is descending) is not checked. fromDescList [(5,"a"), (3,"b")] == fromList [(3, "b"), (5, "a")] fromDescList [(5,"a"), (5,"b"), (3,"b")] == fromList [(3, "b"), (5, "b")] valid (fromDescList [(5,"a"), (5,"b"), (3,"b")]) == True valid (fromDescList [(5,"a"), (3,"b"), (5,"b")]) == Falsestrict-containersO(n). Build a map from an ascending list in linear time with a combining function for equal keys. :The precondition (input list is ascending) is not checked. fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "ba")] valid (fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")]) == True valid (fromAscListWith (++) [(5,"a"), (3,"b"), (5,"b")]) == Falsestrict-containersO(n). Build a map from a descending list in linear time with a combining function for equal keys. ;The precondition (input list is descending) is not checked. fromDescListWith (++) [(5,"a"), (5,"b"), (3,"b")] == fromList [(3, "b"), (5, "ba")] valid (fromDescListWith (++) [(5,"a"), (5,"b"), (3,"b")]) == True valid (fromDescListWith (++) [(5,"a"), (3,"b"), (5,"b")]) == Falsestrict-containersO(n). Build a map from an ascending list in linear time with a combining function for equal keys. :The precondition (input list is ascending) is not checked. let f k a1 a2 = (show k) ++ ":" ++ a1 ++ a2 fromAscListWithKey f [(3,"b"), (5,"a"), (5,"b"), (5,"b")] == fromList [(3, "b"), (5, "5:b5:ba")] valid (fromAscListWithKey f [(3,"b"), (5,"a"), (5,"b"), (5,"b")]) == True valid (fromAscListWithKey f [(5,"a"), (3,"b"), (5,"b"), (5,"b")]) == Falsestrict-containersO(n). Build a map from a descending list in linear time with a combining function for equal keys. ;The precondition (input list is descending) is not checked. let f k a1 a2 = (show k) ++ ":" ++ a1 ++ a2 fromDescListWithKey f [(5,"a"), (5,"b"), (5,"b"), (3,"b")] == fromList [(3, "b"), (5, "5:b5:ba")] valid (fromDescListWithKey f [(5,"a"), (5,"b"), (5,"b"), (3,"b")]) == True valid (fromDescListWithKey f [(5,"a"), (3,"b"), (5,"b"), (5,"b")]) == Falsestrict-containersO(n). Build a map from an ascending list of distinct elements in linear time.  The precondition is not checked. fromDistinctAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")] valid (fromDistinctAscList [(3,"b"), (5,"a")]) == True valid (fromDistinctAscList [(3,"b"), (5,"a"), (5,"b")]) == Falsestrict-containersO(n). Build a map from a descending list of distinct elements in linear time.  The precondition is not checked. fromDistinctDescList [(5,"a"), (3,"b")] == fromList [(3, "b"), (5, "a")] valid (fromDistinctDescList [(5,"a"), (3,"b")]) == True valid (fromDistinctDescList [(5,"a"), (5,"b"), (3,"b")]) == Falsestrict-containers O(\log n). The expression ( k map ) is a pair  (map1,map2) where the keys in map1 are smaller than k and the keys in map2 larger than k. Any key equal to k is found in neither map1 nor map2. split 2 (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3,"b"), (5,"a")]) split 3 (fromList [(5,"a"), (3,"b")]) == (empty, singleton 5 "a") split 4 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a") split 5 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", empty) split 6 (fromList [(5,"a"), (3,"b")]) == (fromList [(3,"b"), (5,"a")], empty)strict-containers O(\log n). The expression ( k map) splits a map just like  but also returns  k map. splitLookup 2 (fromList [(5,"a"), (3,"b")]) == (empty, Nothing, fromList [(3,"b"), (5,"a")]) splitLookup 3 (fromList [(5,"a"), (3,"b")]) == (empty, Just "b", singleton 5 "a") splitLookup 4 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", Nothing, singleton 5 "a") splitLookup 5 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", Just "a", empty) splitLookup 6 (fromList [(5,"a"), (3,"b")]) == (fromList [(3,"b"), (5,"a")], Nothing, empty) strict-containers A variant of  that indicates only whether the key was present, rather than producing its value. This is used to implement ! to avoid allocating unnecessary   constructors.strict-containers O(\log n)&. Delete and find the minimal element. deleteFindMin (fromList [(5,"a"), (3,"b"), (10,"c")]) == ((3,"b"), fromList[(5,"a"), (10,"c")]) deleteFindMin empty Error: can not return the minimal element of an empty mapstrict-containers O(\log n)&. Delete and find the maximal element. deleteFindMax (fromList [(5,"a"), (3,"b"), (10,"c")]) == ((10,"c"), fromList [(3,"b"), (5,"a")]) deleteFindMax empty Error: can not return the maximal element of an empty mapstrict-containersO(1). Decompose a map into pieces based on the structure of the underlying tree. This function is useful for consuming a map in parallel.No guarantee is made as to the sizes of the pieces; an internal, but deterministic process determines this. However, it is guaranteed that the pieces returned will be in ascending order (all elements in the first submap less than all elements in the second, and so on). Examples: splitRoot (fromList (zip [1..6] ['a'..])) == [fromList [(1,'a'),(2,'b'),(3,'c')],fromList [(4,'d')],fromList [(5,'e'),(6,'f')]] splitRoot empty == []Note that the current implementation does not return more than three submaps, but you should not depend on this behaviour because it can change in the future without notice.strict-containersstrict-containers!Folds in order of increasing key.strict-containers%Traverses in order of increasing key. strict-containers strict-containers strict-containers strict-containers strict-containers strict-containers strict-containersstrict-containers strict-containersEquivalent to " ReaderT k (ReaderT x (MaybeT f)) . strict-containersEquivalent to " ReaderT k (ReaderT x (MaybeT f)) . strict-containers strict-containers strict-containersEquivalent to . ReaderT k (ReaderT x (ReaderT y (MaybeT f)))  strict-containersEquivalent to . ReaderT k (ReaderT x (ReaderT y (MaybeT f)))  strict-containers strict-containersstrict-containers @since FIXMEstrict-containersWhat to do with keys in m1 but not m2strict-containersWhat to do with keys in m2 but not m1strict-containersWhat to do with keys in both m1 and m2strict-containersMap m1strict-containersMap m2strict-containersWhat to do with keys in m1 but not m2strict-containersWhat to do with keys in m2 but not m1strict-containersWhat to do with keys in both m1 and m2strict-containersMap m1strict-containersMap m29 9 9  Safe-Inferredstrict-containersO(n). Show the tree that implements the map. The tree is shown in a compressed, hanging format. See .strict-containersO(n). The expression ( showelem hang wide map) shows the tree that implements the map. Elements are shown using the showElem function. If hang is  , a hanging6 tree is shown otherwise a rotated tree is shown. If wide is  !, an extra wide version is shown.  Map> let t = fromDistinctAscList [(x,()) | x <- [1..5]] Map> putStrLn $ showTreeWith (\k x -> show (k,x)) True False t (4,()) +--(2,()) | +--(1,()) | +--(3,()) +--(5,()) Map> putStrLn $ showTreeWith (\k x -> show (k,x)) True True t (4,()) | +--(2,()) | | | +--(1,()) | | | +--(3,()) | +--(5,()) Map> putStrLn $ showTreeWith (\k x -> show (k,x)) False True t +--(5,()) | (4,()) | | +--(3,()) | | +--(2,()) | +--(1,())strict-containersO(n).. Test if the internal map structure is valid. valid (fromAscList [(3,"b"), (5,"a")]) == True valid (fromAscList [(5,"a"), (3,"b")]) == Falsestrict-containers'Test if the keys are ordered correctly.strict-containers+Test if a map obeys the balance invariants.strict-containers6Test if each node of a map reports its size correctly.   Safe-Inferred1strict-containersThis function has moved to /.strict-containersThis function has moved to 0.(c) Daan Leijen 2002 (c) Andriy Palamarchuk 2008 BSD-stylelibraries@haskell.orgportable Trustworthy^>strict-containers O(\log n). The expression ( def k map) returns the value at key k or returns default value def! when the key is not in the map. findWithDefault 'x' 1 (fromList [(5,'a'), (3,'b')]) == 'x' findWithDefault 'x' 5 (fromList [(5,'a'), (3,'b')]) == 'a'strict-containersO(1). A map with a single element. singleton 1 'a' == fromList [(1, 'a')] size (singleton 1 'a') == 1strict-containers O(\log n). Insert a new key and value in the map. If the key is already present in the map, the associated value is replaced with the supplied value.  is equivalent to   . insert 5 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'x')] insert 7 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'a'), (7, 'x')] insert 5 'x' empty == singleton 5 'x'strict-containers O(\log n)>. Insert with a function, combining new value and old value.  f key value mp) will insert the pair (key, value) into mp if key does not exist in the map. If the key does exist, the function will insert the pair (key, f new_value old_value). insertWith (++) 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "xxxa")] insertWith (++) 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")] insertWith (++) 5 "xxx" empty == singleton 5 "xxx"strict-containers O(\log n). Insert with a function, combining key, new value and old value.  f key value mp) will insert the pair (key, value) into mp if key does not exist in the map. If the key does exist, the function will insert the pair (key,f key new_value old_value);. Note that the key passed to f is the same key passed to . let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value insertWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:xxx|a")] insertWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")] insertWithKey f 5 "xxx" empty == singleton 5 "xxx"strict-containers O(\log n). Combines insert operation with old value retrieval. The expression ( f k x map2) is a pair where the first element is equal to ( k map$) and the second element equal to ( f k x map). let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value insertLookupWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "5:xxx|a")]) insertLookupWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "xxx")]) insertLookupWithKey f 5 "xxx" empty == (Nothing, singleton 5 "xxx")This is how to define  insertLookup using insertLookupWithKey: let insertLookup kx x t = insertLookupWithKey (\_ a _ -> a) kx x t insertLookup 5 "x" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "x")]) insertLookup 7 "x" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "x")])strict-containers O(\log n). Update a value at a specific key with the result of the provided function. When the key is not a member of the map, the original map is returned. adjust ("new " ++) 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")] adjust ("new " ++) 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] adjust ("new " ++) 7 empty == emptystrict-containers O(\log n). Adjust a value at a specific key. When the key is not a member of the map, the original map is returned. let f key x = (show key) ++ ":new " ++ x adjustWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")] adjustWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] adjustWithKey f 7 empty == emptystrict-containers O(\log n). The expression ( f k map) updates the value x at k (if it is in the map). If (f x) is  %, the element is deleted. If it is (  y ), the key k is bound to the new value y. let f x = if x == "a" then Just "new a" else Nothing update f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")] update f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] update f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"strict-containers O(\log n). The expression ( f k map) updates the value x at k (if it is in the map). If (f k x) is  %, the element is deleted. If it is (  y ), the key k is bound to the new value y. let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing updateWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")] updateWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] updateWithKey f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"strict-containers O(\log n). Lookup and update. See also . The function returns changed value, if it is updated. Returns the original key value if the map entry is deleted. let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing updateLookupWithKey f 5 (fromList [(5,"a"), (3,"b")]) == (Just "5:new a", fromList [(3, "b"), (5, "5:new a")]) updateLookupWithKey f 7 (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a")]) updateLookupWithKey f 3 (fromList [(5,"a"), (3,"b")]) == (Just "b", singleton 5 "a")strict-containers O(\log n). The expression ( f k map) alters the value x at k, or absence thereof. 7 can be used to insert, delete, or update a value in a . In short :  k ( f k m) = f ( k m). let f _ = Nothing alter f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] alter f 5 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" let f _ = Just "c" alter f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "c")] alter f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "c")] Note that  = alter . fmap.strict-containers O(\log n). The expression ( f k map) alters the value x at k, or absence thereof.  can be used to inspect, insert, delete, or update a value in a  . In short:  k <$>  f k m = f ( k m).Example: interactiveAlter :: Int -> Map Int String -> IO (Map Int String) interactiveAlter k m = alterF f k m where f Nothing = do putStrLn $ show k ++ " was not found in the map. Would you like to add it?" getUserResponse1 :: IO (Maybe String) f (Just old) = do putStrLn $ "The key is currently bound to " ++ show old ++ ". Would you like to change or delete it?" getUserResponse2 :: IO (Maybe String)  is the most general operation for working with an individual key that may or may not be in a given map. When used with trivial functors like  and  , it is often slightly slower than more specialized combinators like  and . However, when the functor is non-trivial and key comparison is not particularly cheap, it is the fastest way.Note on rewrite rules:3This module includes GHC rewrite rules to optimize  for the   and  functors. In general, these rules improve performance. The sole exception is that when using , deleting a key that is already absent takes longer than it would without the rules. If you expect this to occur a very large fraction of the time, you might consider using a private copy of the  type.Note:  is a flipped version of the at combinator from Control.Lens.At.strict-containers O(\log n). Update the element at index. Calls   when an invalid index is used. updateAt (\ _ _ -> Just "x") 0 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "x"), (5, "a")] updateAt (\ _ _ -> Just "x") 1 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "x")] updateAt (\ _ _ -> Just "x") 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range updateAt (\ _ _ -> Just "x") (-1) (fromList [(5,"a"), (3,"b")]) Error: index out of range updateAt (\_ _ -> Nothing) 0 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a" updateAt (\_ _ -> Nothing) 1 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" updateAt (\_ _ -> Nothing) 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range updateAt (\_ _ -> Nothing) (-1) (fromList [(5,"a"), (3,"b")]) Error: index out of rangestrict-containers O(\log n)&. Update the value at the minimal key. updateMin (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "Xb"), (5, "a")] updateMin (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"strict-containers O(\log n)&. Update the value at the maximal key. updateMax (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "Xa")] updateMax (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"strict-containers O(\log n)&. Update the value at the minimal key. updateMinWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"3:b"), (5,"a")] updateMinWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"strict-containers O(\log n)&. Update the value at the maximal key. updateMaxWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"b"), (5,"5:a")] updateMaxWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"strict-containers=The union of a list of maps, with a combining operation: ( f == +- ( f) ). unionsWith (++) [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])] == fromList [(3, "bB3"), (5, "aAA3"), (7, "C")]strict-containers;O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n". Union with a combining function. unionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "aA"), (7, "C")]strict-containers;O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n#. Union with a combining function. let f key left_value right_value = (show key) ++ ":" ++ left_value ++ "|" ++ right_value unionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "5:a|A"), (7, "C")]strict-containersO(n+m). Difference with a combining function. When two equal keys are encountered, the combining function is applied to the values of these keys. If it returns  , the element is discarded (proper set difference). If it returns (  y+), the element is updated with a new value y. let f al ar = if al == "b" then Just (al ++ ":" ++ ar) else Nothing differenceWith f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (7, "C")]) == singleton 3 "b:B"strict-containersO(n+m). Difference with a combining function. When two equal keys are encountered, the combining function is applied to the key and both values. If it returns  , the element is discarded (proper set difference). If it returns (  y+), the element is updated with a new value y. let f k al ar = if al == "b" then Just ((show k) ++ ":" ++ al ++ "|" ++ ar) else Nothing differenceWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (10, "C")]) == singleton 3 "3:b|B"strict-containers;O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n). Intersection with a combining function. intersectionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "aA"strict-containers;O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n). Intersection with a combining function. let f k al ar = (show k) ++ ":" ++ al ++ "|" ++ ar intersectionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "5:a|A"strict-containersMap covariantly over a  f k x.strict-containersMap covariantly over a  f k x y.strict-containersWhen a key is found in both maps, apply a function to the key and values and maybe use the result in the merged map. zipWithMaybeMatched :: (k -> x -> y -> Maybe z) -> SimpleWhenMatched k x y z strict-containersWhen a key is found in both maps, apply a function to the key and values, perform the resulting action, and maybe use the result in the merged map.This is the fundamental  tactic.strict-containersWhen a key is found in both maps, apply a function to the key and values to produce an action and use its result in the merged map.strict-containersWhen a key is found in both maps, apply a function to the key and values and use the result in the merged map. zipWithMatched :: (k -> x -> y -> z) -> SimpleWhenMatched k x y z strict-containersMap over the entries whose keys are missing from the other map, optionally removing some. This is the most powerful 0 tactic, but others are usually more efficient. mapMaybeMissing :: (k -> x -> Maybe y) -> SimpleWhenMissing k x y ?mapMaybeMissing f = traverseMaybeMissing (\k x -> pure (f k x))but mapMaybeMissing uses fewer unnecessary   operations.strict-containers?Map over the entries whose keys are missing from the other map. 7mapMissing :: (k -> x -> y) -> SimpleWhenMissing k x y 5mapMissing f = mapMaybeMissing (\k x -> Just $ f k x)but  mapMissing is somewhat faster.strict-containersTraverse over the entries whose keys are missing from the other map, optionally producing values to put in the result. This is the most powerful 0 tactic, but others are usually more efficient.strict-containersTraverse over the entries whose keys are missing from the other map.strict-containersO(n+m)). An unsafe universal combining function.WARNING: This function can produce corrupt maps and its results may depend on the internal structures of its inputs. Users should prefer 9 or :.When  is given three arguments, it is inlined to the call site. You should therefore use  only to define custom combining functions. For example, you could define ,  and  as myUnionWithKey f m1 m2 = mergeWithKey (\k x1 x2 -> Just (f k x1 x2)) id id m1 m2 myDifferenceWithKey f m1 m2 = mergeWithKey f id (const empty) m1 m2 myIntersectionWithKey f m1 m2 = mergeWithKey (\k x1 x2 -> Just (f k x1 x2)) (const empty) (const empty) m1 m2 When calling  combine only1 only2, a function combining two s is created, such thatif a key is present in both maps, it is passed with both corresponding values to the combine function. Depending on the result, the key is either present in the result with specified value, or is left out;>a nonempty subtree present only in the first map is passed to only1* and the output is added to the result;?a nonempty subtree present only in the second map is passed to only2* and the output is added to the result.The only1 and only2 methods must return a map with a subset (possibly empty) of the keys of the given map. The values can be modified arbitrarily. Most common variants of only1 and only2 are   and   , but for example  f or  f could be used for any f.strict-containersO(n). Map values and collect the   results. let f x = if x == "a" then Just "new a" else Nothing mapMaybe f (fromList [(5,"a"), (3,"b")]) == singleton 5 "new a"strict-containersO(n)". Map keys/values and collect the   results. let f k _ = if k < 5 then Just ("key : " ++ (show k)) else Nothing mapMaybeWithKey f (fromList [(5,"a"), (3,"b")]) == singleton 3 "key : 3"strict-containersO(n)'. Traverse keys/values and collect the   results.strict-containersO(n). Map values and separate the   and   results. let f a = if a < "c" then Left a else Right a mapEither f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (fromList [(3,"b"), (5,"a")], fromList [(1,"x"), (7,"z")]) mapEither (\ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (empty, fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])strict-containersO(n)#. Map keys/values and separate the   and   results. let f k a = if k < 5 then Left (k * 2) else Right (a ++ a) mapEitherWithKey f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (fromList [(1,2), (3,6)], fromList [(5,"aa"), (7,"zz")]) mapEitherWithKey (\_ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) == (empty, fromList [(1,"x"), (3,"b"), (5,"a"), (7,"z")])strict-containersO(n),. Map a function over all values in the map. map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]strict-containersO(n),. Map a function over all values in the map. let f key x = (show key) ++ ":" ++ x mapWithKey f (fromList [(5,"a"), (3,"b")]) == fromList [(3, "3:b"), (5, "5:a")]strict-containersO(n).  f m ==   $  $ ((k, v) -> (v' -> v' `seq` (k,v'))  $ f k v) ( m)* That is, it behaves much like a regular   except that the traversing function also has access to the key associated with a value and the values are forced before they are installed in the result map. traverseWithKey (\k v -> if odd k then Just (succ v) else Nothing) (fromList [(1, 'a'), (5, 'e')]) == Just (fromList [(1, 'b'), (5, 'f')]) traverseWithKey (\k v -> if odd k then Just (succ v) else Nothing) (fromList [(2, 'c')]) == Nothingstrict-containersO(n). The function  threads an accumulating argument through the map in ascending order of keys. let f a b = (a ++ b, b ++ "X") mapAccum f "Everything: " (fromList [(5,"a"), (3,"b")]) == ("Everything: ba", fromList [(3, "bX"), (5, "aX")])strict-containersO(n). The function  threads an accumulating argument through the map in ascending order of keys. let f a k b = (a ++ " " ++ (show k) ++ "-" ++ b, b ++ "X") mapAccumWithKey f "Everything:" (fromList [(5,"a"), (3,"b")]) == ("Everything: 3-b 5-a", fromList [(3, "bX"), (5, "aX")]) strict-containersO(n). The function   threads an accumulating argument through the map in ascending order of keys.strict-containersO(n). The function  threads an accumulating argument through the map in descending order of keys.strict-containers O(n \log n).  c f s! is the map obtained by applying f to each key of s.)The size of the result may be smaller if f maps two or more distinct keys to the same new key. In this case the associated values will be combined using c. The value at the greater of the two original keys is used as the first argument to c. mapKeysWith (++) (\ _ -> 1) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 1 "cdab" mapKeysWith (++) (\ _ -> 3) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 3 "cdab"strict-containersO(n). Build a map from a set of keys and a function which for each key computes its value. fromSet (\k -> replicate k 'a') (Data.Set.fromList [3, 5]) == fromList [(5,"aaaaa"), (3,"aaa")] fromSet undefined Data.Set.empty == emptystrict-containersO(n)6. Build a map from a set of elements contained inside  s. fromArgSet (Data.Set.fromList [Arg 3 "aaa", Arg 5 "aaaaa"]) == fromList [(5,"aaaaa"), (3,"aaa")] fromArgSet Data.Set.empty == emptystrict-containers O(n \log n)7. Build a map from a list of key/value pairs. See also . If the list contains more than one value for the same key, the last value for the key is retained.If the keys of the list are ordered, linear-time implementation is used, with the performance equal to . fromList [] == empty fromList [(5,"a"), (3,"b"), (5, "c")] == fromList [(5,"c"), (3,"b")] fromList [(5,"c"), (3,"b"), (5, "a")] == fromList [(5,"a"), (3,"b")]strict-containers O(n \log n). Build a map from a list of key/value pairs with a combining function. See also . fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "ab"), (5, "aba")] fromListWith (++) [] == emptystrict-containers O(n \log n). Build a map from a list of key/value pairs with a combining function. See also . let f k a1 a2 = (show k) ++ a1 ++ a2 fromListWithKey f [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "3ab"), (5, "5a5ba")] fromListWithKey f [] == emptystrict-containersO(n)6. Build a map from an ascending list in linear time. :The precondition (input list is ascending) is not checked. fromAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")] fromAscList [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "b")] valid (fromAscList [(3,"b"), (5,"a"), (5,"b")]) == True valid (fromAscList [(5,"a"), (3,"b"), (5,"b")]) == Falsestrict-containersO(n)6. Build a map from a descending list in linear time. ;The precondition (input list is descending) is not checked. fromDescList [(5,"a"), (3,"b")] == fromList [(3, "b"), (5, "a")] fromDescList [(5,"a"), (5,"b"), (3,"a")] == fromList [(3, "b"), (5, "b")] valid (fromDescList [(5,"a"), (5,"b"), (3,"b")]) == True valid (fromDescList [(5,"a"), (3,"b"), (5,"b")]) == Falsestrict-containersO(n). Build a map from an ascending list in linear time with a combining function for equal keys. :The precondition (input list is ascending) is not checked. fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "ba")] valid (fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")]) == True valid (fromAscListWith (++) [(5,"a"), (3,"b"), (5,"b")]) == Falsestrict-containersO(n). Build a map from a descending list in linear time with a combining function for equal keys. ;The precondition (input list is descending) is not checked. fromDescListWith (++) [(5,"a"), (5,"b"), (3,"b")] == fromList [(3, "b"), (5, "ba")] valid (fromDescListWith (++) [(5,"a"), (5,"b"), (3,"b")]) == True valid (fromDescListWith (++) [(5,"a"), (3,"b"), (5,"b")]) == Falsestrict-containersO(n). Build a map from an ascending list in linear time with a combining function for equal keys. :The precondition (input list is ascending) is not checked. let f k a1 a2 = (show k) ++ ":" ++ a1 ++ a2 fromAscListWithKey f [(3,"b"), (5,"a"), (5,"b"), (5,"b")] == fromList [(3, "b"), (5, "5:b5:ba")] valid (fromAscListWithKey f [(3,"b"), (5,"a"), (5,"b"), (5,"b")]) == True valid (fromAscListWithKey f [(5,"a"), (3,"b"), (5,"b"), (5,"b")]) == Falsestrict-containersO(n). Build a map from a descending list in linear time with a combining function for equal keys. ;The precondition (input list is descending) is not checked. let f k a1 a2 = (show k) ++ ":" ++ a1 ++ a2 fromDescListWithKey f [(5,"a"), (5,"b"), (5,"b"), (3,"b")] == fromList [(3, "b"), (5, "5:b5:ba")] valid (fromDescListWithKey f [(5,"a"), (5,"b"), (5,"b"), (3,"b")]) == True valid (fromDescListWithKey f [(5,"a"), (3,"b"), (5,"b"), (5,"b")]) == Falsestrict-containersO(n). Build a map from an ascending list of distinct elements in linear time.  The precondition is not checked. fromDistinctAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")] valid (fromDistinctAscList [(3,"b"), (5,"a")]) == True valid (fromDistinctAscList [(3,"b"), (5,"a"), (5,"b")]) == Falsestrict-containersO(n). Build a map from a descending list of distinct elements in linear time.  The precondition is not checked. fromDistinctDescList [(5,"a"), (3,"b")] == fromList [(3, "b"), (5, "a")] valid (fromDistinctDescList [(5,"a"), (3,"b")]) == True valid (fromDistinctDescList [(5,"a"), (3,"b"), (3,"a")]) == False(c) Daan Leijen 2002 (c) Andriy Palamarchuk 2008 BSD-stylelibraries@haskell.orgportableSafek(c) David Feuer 2016 BSD-stylelibraries@haskell.orgportableSafe Safe-InferredW; Safe-Inferred}(c) Ross Paterson 2005 (c) Louis Wasserman 2009 (c) Bertram Felgenhauer, David Feuer, Ross Paterson, and Milan Straka 2014 BSD-stylelibraries@haskell.orgportable Trustworthy(56;>WVstrict-containers$View of the right end of a sequence.strict-containersempty sequencestrict-containersthe sequence minus the rightmost element, and the rightmost elementstrict-containers#View of the left end of a sequence.strict-containersempty sequencestrict-containers-leftmost element and the rest of the sequence strict-containersSometimes, we want to emphasize that we are viewing a node as a top-level digit of a   tree. strict-containers0A finger tree whose digits are all ones and twos strict-containersA finger tree whose top level has only Two and/or Three digits, and whose other levels have only One and Two digits. A Rigid tree is precisely what one gets by unzipping/inverting a 2-3 tree, so it is precisely what we need to turn a finger tree into in order to transform it into a 2-3 tree.strict-containers!General-purpose finite sequences.strict-containersA bidirectional pattern synonym viewing the rear of a non-empty sequence.strict-containersA bidirectional pattern synonym viewing the front of a non-empty sequence.strict-containers;A bidirectional pattern synonym matching an empty sequence. strict-containersWe use this to help the types work out for splices in the Lift instance. Things get a bit yucky otherwise. strict-containers ) does most of the hard work of computing liftA2 f xs ys. It produces the center part of a finger tree, with a prefix corresponding to the first element of xs and a suffix corresponding to its last element omitted; the missing suffix and prefix are added by the caller. For the recursive call, it squashes the prefix and the suffix into the center tree. Once it gets to the bottom, it turns the tree into a 2-3 tree, applies  > to produce the main body, and glues all the pieces together.f itself is a bit horrifying because of the nested types involved. Its job is to map over the *elements* of a 2-3 tree, rather than the subtrees. If we used a higher-order nested type with MPTC, we could probably use a class, but as it is we have to build up f# explicitly through the recursion.Description of parametersTypesa2 remains constant through recursive calls (in the DeepTh case), while b and c do not:  liftAMiddle calls itself at types Node b and Node c.Values  is used when the original xs :: Sequence a has at least two elements, so it can be decomposed by taking off the first and last elements: xs = firstx <: midxs :> lastxthe first two arguments ffirstx, flastx :: b -> c are equal to f firstx and f lastx, where f :: a -> b -> c5 is the third argument. This ensures sharing when f computes some data upon being partially applied to its first argument. The way f gets accumulated also ensures sharing for the middle section.'the fourth argument is the middle part midxs, always constant.#the last argument, a tuple of type Rigid b, holds all the elements of ys, in three parts: a middle part around which the recursion is structured, surrounded by a prefix and a suffix that accumulate elements on the side as we walk down the middle. Invariants 1. Viewing the various trees as the lists they represent (the types of the toList functions are given a few paragraphs below): toListFTN result = (ffirstx <$> (toListThinN m ++ toListD sf)) ++ (f <$> toListFTE midxs <*> (toListD pr ++ toListThinN m ++ toListD sf)) ++ (flastx <$> (toListD pr ++ toListThinN m)) 2. s = size m + size pr + size sf 3. size (ffirstx y) = size (flastx y) = size (f x y) = size y for any (x :: a) (y :: b)Projecting invariant 1 on sizes, using 2 and 3 to simplify, we have the following corollary. It is weaker than invariant 1, but it may be easier to keep track of. /1a. size result = s * (size midxs + 1) + size mIn invariant 1, the types of the auxiliary functions are as follows for reference: toListFTE :: FingerTree (Elem a) -> [a] toListFTN :: FingerTree (Node c) -> [c] toListThinN :: Thin (Node b) -> [b] toListD :: Digit12 b -> [b] strict-containersO(mn) (incremental) Takes an O(m)% function and a finger tree of size n> and maps the function over the tree leaves. Unlike the usual  2, the function is applied to the "leaves" of the  (i.e., given a FingerTree (Elem a)., it applies the function to elements of type Elem a), replacing the leaves with subtrees of at least the same height, e.g., Node(Node(Elem y)). The multiplier argument serves to make the annotations match up properly. strict-containers O(\log n)4 (incremental) Takes the extra flexibility out of a 6 to make it a genuine 2-3 finger tree. The result of   will have only two and three digits at the top level and only one and two digits elsewhere. If the tree has fewer than four elements,  6 will simply extract them, and will not build a tree. strict-containers O(\log n) (incremental) Takes a tree whose left side has been rigidified and finishes the job. strict-containers O(\log n) (incremental) Rejigger a finger tree so the digits are all ones and twos.strict-containers O(n) <. Intersperse an element between the elements of a sequence. intersperse a empty = empty intersperse a (singleton x) = singleton x intersperse a (fromList [x,y]) = fromList [x,a,y] intersperse a (fromList [x,y,z]) = fromList [x,a,y,a,z] strict-containersGiven the size of a digit and the digit itself, efficiently converts it to a FingerTree. strict-containers  takes an Applicative-wrapped construction of a piece of a FingerTree, assumed to always have the same size (which is put in the second argument), and replicates it as many times as specified. This is a generalization of , which itself is a generalization of many Data.Strict.Sequence.Autogen methods. strict-containers?Replicate each element of a sequence the given number of times.%replicateEach 3 [1,2] = [1,1,1,2,2,2] 'replicateEach n xs = xs >>= replicate nstrict-containers O(1) . The empty sequence.strict-containers O(1) . A singleton sequence.strict-containers O(\log n) .  replicate n x is a sequence consisting of n copies of x.strict-containers is an   version of  , and makes  O(\log n)  calls to   and  . *replicateA n x = sequenceA (replicate n x)strict-containers is a sequence counterpart of <=. )replicateM n x = sequence (replicate n x)For  base >= 4.8.0 and containers >= 0.5.11,  is a synonym for .strict-containers O(\log k).  k xs forms a sequence of length k by repeatedly concatenating xs with itself. xs may only be empty if k is 0.2cycleTaking k = fromList . take k . cycle . toListstrict-containers O(1) . Add an element to the left end of a sequence. Mnemonic: a triangle with the single element at the pointy end.strict-containers O(1) . Add an element to the right end of a sequence. Mnemonic: a triangle with the single element at the pointy end.strict-containers O(\log(\min(n_1,n_2))) . Concatenate two sequences.strict-containersBuilds a sequence from a seed value. Takes time linear in the number of generated elements. WARNING: If the number of generated elements is infinite, this method will not terminate.strict-containers f x is equivalent to  ( (  swap . f) x).strict-containers O(n) . Constructs a sequence by repeated application of a function to a seed value. iterateN n f x = fromList (Prelude.take n (Prelude.iterate f x))strict-containers O(1) . Is this the empty sequence?strict-containers O(1) ). The number of elements in the sequence.strict-containers O(1) %. Analyse the left end of a sequence.strict-containers O(1) &. Analyse the right end of a sequence.strict-containers is similar to  :, but returns a sequence of reduced values from the left: scanl f z (fromList [x1, x2, ...]) = fromList [z, z `f` x1, (z `f` x1) `f` x2, ...]strict-containers is a variant of % that has no starting value argument: scanl1 f (fromList [x1, x2, ...]) = fromList [x1, x1 `f` x2, ...]strict-containers is the right-to-left dual of .strict-containers is a variant of % that has no starting value argument.strict-containers O(\log(\min(i,n-i))) . The element at the specified position, counting from 0. The argument should thus be a non-negative integer less than the size of the sequence. If the position is out of range,  fails with an error.xs `index` i = toList xs !! i Caution:  necessarily delays retrieving the requested element until the result is forced. It can therefore lead to a space leak if the result is stored, unforced, in another structure. To retrieve an element immediately without forcing it, use  or .strict-containers O(\log(\min(i,n-i))) . The element at the specified position, counting from 0. If the specified position is negative or at least the length of the sequence,  returns  .;0 <= i < length xs ==> lookup i xs == Just (toList xs !! i)1i < 0 || i >= length xs ==> lookup i xs = NothingUnlike , this can be used to retrieve an element without forcing it. For example, to insert the fifth element of a sequence xs into a >* m at key k, you could use /case lookup 5 xs of Nothing -> m Just x -> >? k x m strict-containers O(\log(\min(i,n-i))) . A flipped, infix version of .strict-containers O(\log(\min(i,n-i))) . Replace the element at the specified position. If the position is out of range, the original sequence is returned.strict-containers O(\log(\min(i,n-i))) . Update the element at the specified position. If the position is out of range, the original sequence is returned. The new value is forced before it is installed in the sequence. adjust f i xs = case xs !? i of Nothing -> xs Just x -> let !x' = f x in update i x' xs strict-containers O(\log(\min(i,n-i))) .  i x xs inserts x into xs at the index i), shifting the rest of the sequence over. insertAt 2 x (fromList [a,b,c,d]) = fromList [a,b,x,c,d] insertAt 4 x (fromList [a,b,c,d]) = insertAt 10 x (fromList [a,b,c,d]) = fromList [a,b,c,d,x] 7insertAt i x xs = take i xs >< singleton x >< drop i xsstrict-containers O(\log(\min(i,n-i))) . Delete the element of a sequence at a given index. Return the original sequence if the index is out of range. deleteAt 2 [a,b,c,d] = [a,b,d] deleteAt 4 [a,b,c,d] = deleteAt (-1) [a,b,c,d] = [a,b,c,d] strict-containersA generalization of  ,  takes a mapping function that also depends on the element's index, and applies it to every element in the sequence.strict-containers is a version of  7 that also offers access to the index of each element.strict-containers O(n) . Convert a given sequence length and a function representing that sequence into a sequence.strict-containers O(n) 5. Create a sequence consisting of the elements of an  . Note that the resulting sequence elements may be evaluated lazily (as on GHC), so you must force the entire structure to be sure that the original array can be garbage-collected.strict-containers O(\log(\min(i,n-i)))  . The first i elements of a sequence. If i is negative,  i s yields the empty sequence. If the sequence contains fewer than i+ elements, the whole sequence is returned.strict-containers O(\log(\min(i,n-i))) ). Elements of a sequence after the first i. If i is negative,  i s yields the whole sequence. If the sequence contains fewer than i+ elements, the empty sequence is returned.strict-containers O(\log(\min(i,n-i))) ). Split a sequence at a given position.  i s = ( i s,  i s). strict-containers O(\log(\min(i,n-i)))  A version of  that does not attempt to enhance sharing when the split point is less than or equal to 0, and that gives completely wrong answers when the split point is at least the length of the sequence, unless the sequence is a singleton. This is used to implement zipWith and chunksOf, which are extremely sensitive to the cost of splitting very short sequences. There is just enough of a speed increase to make this worth the trouble.strict-containers,O \Bigl(\bigl(\frac{n}{c}\bigr) \log c\Bigr).  chunksOf c xs splits xs into chunks of size c>0. If c does not divide the length of xs< evenly, then the last element of the result will be short.Side note: the given performance bound is missing some messy terms that only really affect edge cases. Performance degrades smoothly from  O(1)  (for  c = n ) to  O(n)  (for  c = 1  ). The true bound is more like  O \Bigl( \bigl(\frac{n}{c} - 1\bigr) (\log (c + 1)) + 1 \Bigr) strict-containers O(n) . Returns a sequence of all suffixes of this sequence, longest first. For example, tails (fromList "abc") = fromList [fromList "abc", fromList "bc", fromList "c", fromList ""]Evaluating the  i th suffix takes  O(\log(\min(i, n-i))) 5, but evaluating every suffix in the sequence takes  O(n)  due to sharing.strict-containers O(n) . Returns a sequence of all prefixes of this sequence, shortest first. For example, inits (fromList "abc") = fromList [fromList "", fromList "a", fromList "ab", fromList "abc"]Evaluating the  i th prefix takes  O(\log(\min(i, n-i))) 5, but evaluating every prefix in the sequence takes  O(n)  due to sharing. strict-containersGiven a function to apply to tails of a tree, applies that function to every tail of the specified tree. strict-containersGiven a function to apply to inits of a tree, applies that function to every init of the specified tree.strict-containers is a version of  9 that also provides access to the index of each element.strict-containers is a version of  9 that also provides access to the index of each element.strict-containers O(i)  where  i  is the prefix length. , applied to a predicate p and a sequence xs2, returns the longest prefix (possibly empty) of xs of elements that satisfy p.strict-containers O(i)  where  i  is the suffix length. , applied to a predicate p and a sequence xs2, returns the longest suffix (possibly empty) of xs of elements that satisfy p. p xs is equivalent to  ( p ( xs)).strict-containers O(i)  where  i  is the prefix length.  p xs% returns the suffix remaining after  p xs.strict-containers O(i)  where  i  is the suffix length.  p xs% returns the prefix remaining after  p xs. p xs is equivalent to  ( p ( xs)).strict-containers O(i)  where  i  is the prefix length. , applied to a predicate p and a sequence xs, returns a pair whose first element is the longest prefix (possibly empty) of xs of elements that satisfy p9 and the second element is the remainder of the sequence.strict-containers O(i)  where  i  is the suffix length. , applied to a predicate p and a sequence xs, returns a pair whose first element is the longest suffix (possibly empty) of xs of elements that satisfy p9 and the second element is the remainder of the sequence.strict-containers O(i)  where  i  is the breakpoint index. , applied to a predicate p and a sequence xs, returns a pair whose first element is the longest prefix (possibly empty) of xs of elements that do not satisfy p: and the second element is the remainder of the sequence. p is equivalent to  (not . p).strict-containers p is equivalent to  (not . p).strict-containers O(n) . The  function takes a predicate p and a sequence xs and returns sequences of those elements which do and do not satisfy the predicate.strict-containers O(n) . The  function takes a predicate p and a sequence xs and returns a sequence of those elements which satisfy the predicate.strict-containers finds the leftmost index of the specified element, if it is present, and otherwise  .strict-containers finds the rightmost index of the specified element, if it is present, and otherwise  .strict-containers finds the indices of the specified element, from left to right (i.e. in ascending order).strict-containers finds the indices of the specified element, from right to left (i.e. in descending order).strict-containers p xs9 finds the index of the leftmost element that satisfies p, if any exist.strict-containers p xs: finds the index of the rightmost element that satisfies p, if any exist.strict-containers p, finds all indices of elements that satisfy p, in ascending order.strict-containers p, finds all indices of elements that satisfy p, in descending order.strict-containers O(n) . Create a sequence from a finite list of elements. There is a function  5 in the opposite direction for all instances of the   class, including .strict-containers O(n) . The reverse of a sequence. strict-containers O(n) . Reverse a sequence while mapping over it. This is not currently exported, but is used in rewrite rules. strict-containers O(n) . Constructs a new sequence with the same structure as an existing sequence using a user-supplied mapping function along with a splittable value and a way to split it. The value is split up lazily according to the structure of the sequence, so one piece of the value is distributed to each element of the sequence. The caller should provide a splitter function that takes a number, n5, and a splittable value, breaks off a chunk of size n from the value, and returns that chunk and the remainder as a pair. The following examples will hopefully make the usage clear: zipWith :: (a -> b -> c) -> Seq a -> Seq b -> Seq c zipWith f s1 s2 = splitMap splitAt (\b a -> f a (b `index` 0)) s2' s1' where minLen = min (length s1) (length s2) s1' = take minLen s1 s2' = take minLen s2 mapWithIndex :: (Int -> a -> b) -> Seq a -> Seq b mapWithIndex f = splitMap (\n i -> (i, n+i)) f 0 strict-containersUnzip a sequence of pairs. unzip ps = ps   (    ps) (    ps) Example: unzip $ fromList [(1,"a"), (2,"b"), (3,"c")] = (fromList [1,2,3], fromList ["a", "b", "c"]) !See the note about efficiency at . strict-containers O(n) 7. Unzip a sequence using a function to divide elements.  unzipWith f xs ==  (  f xs)Efficiency note: unzipWith9 produces its two results in lockstep. If you calculate  unzipWith f xs  and fully force either3 of the results, then the entire structure of the other one will be built as well. This behavior allows the garbage collector to collect each calculated pair component as soon as it dies, without having to wait for its mate to die. If you do not need this behavior, you may be better off simply calculating the sequence of pairs and using  % to extract each component sequence.strict-containers O(\min(n_1,n_2)) .  takes two sequences and returns a sequence of corresponding pairs. If one input is short, excess elements are discarded from the right end of the longer sequence.strict-containers O(\min(n_1,n_2)) .  generalizes  by zipping with the function given as the first argument, instead of a tupling function. For example,  zipWith (+) is applied to two sequences to take the sequence of corresponding sums. strict-containersA version of zipWith that assumes the sequences have the same length.strict-containers O(\min(n_1,n_2,n_3)) .  takes three sequences and returns a sequence of triples, analogous to .strict-containers O(\min(n_1,n_2,n_3)) .  takes a function which combines three elements, as well as three sequences and returns a sequence of their point-wise combinations, analogous to .strict-containers O(\min(n_1,n_2,n_3,n_4)) .  takes four sequences and returns a sequence of quadruples, analogous to .strict-containers O(\min(n_1,n_2,n_3,n_4)) .  takes a function which combines four elements, as well as four sequences and returns a sequence of their point-wise combinations, analogous to . strict-containersfromList2, given a list and its length, constructs a completely balanced Seq whose elements are that list using the replicateA generalization.strict-containers    =     = strict-containersstrict-containers strict-containers strict-containers strict-containers strict-containersstrict-containersstrict-containers strict-containersstrict-containers @since FIXMEstrict-containers @since FIXMEstrict-containers @since FIXME strict-containers strict-containers strict-containers strict-containers strict-containers strict-containers strict-containers strict-containers strict-containers strict-containers strict-containers strict-containers strict-containers ffirstxstrict-containers flastxstrict-containers fstrict-containers midxsstrict-containersRigid s pr m sf (pr : prefix, sf : suffix) 5555 6 05 55 55 5 Safe-Inferredk#strict-containersA pairing heap tagged with both a key and the original position of its elements, for use in .strict-containersA pairing heap tagged with some key for sorting elements, for use in .strict-containersA pairing heap tagged with the original position of elements, to allow for stable sorting.strict-containersA simple pairing heap.strict-containers O(n \log n) .  sorts the specified  by the natural ordering of its elements. The sort is stable. If stability is not required,  can be slightly faster.strict-containers O(n \log n) .  sorts the specified  according to the specified comparator. The sort is stable. If stability is not required,  can be slightly faster. strict-containers O(n \log n) .  sorts the specified  by comparing the results of a key function applied to each element.  f is equivalent to  (  @A f)8, but has the performance advantage of only evaluating f once for each element in the input list. This is called the decorate-sort-undecorate paradigm, or Schwartzian transform.An example of using  might be to sort a ' of strings according to their length: sortOn length (fromList ["alligator", "monkey", "zebra"]) == fromList ["zebra", "monkey", "alligator"] If, instead,  had been used,  1 would be evaluated on every comparison, giving  O(n \log n)  evaluations, rather than  O(n) .If f2 is very cheap (for example a record selector, or  ),  (  @A f) will be faster than  f.strict-containers O(n \log n) .  sorts the specified  by the natural ordering of its elements, but the sort is not stable. This algorithm is frequently faster and uses less memory than .strict-containers O(n \log n) . A generalization of ,  takes an arbitrary comparator and sorts the specified sequence. The sort is not stable. This algorithm is frequently faster and uses less memory than . strict-containers O(n \log n) .  sorts the specified  by comparing the results of a key function applied to each element.  f is equivalent to  (  @A f)8, but has the performance advantage of only evaluating f once for each element in the input list. This is called the decorate-sort-undecorate paradigm, or Schwartzian transform.An example of using  might be to sort a ' of strings according to their length: unstableSortOn length (fromList ["alligator", "monkey", "zebra"]) == fromList ["zebra", "monkey", "alligator"] If, instead,  had been used,  1 would be evaluated on every comparison, giving  O(n \log n)  evaluations, rather than  O(n) .If f2 is very cheap (for example a record selector, or  ),  (  @A f) will be faster than  f.strict-containers merges two s.strict-containers merges two s, based on the tag value.strict-containers merges two >s, taking into account the original position of the elements.strict-containers merges two s, based on the tag value, taking into account the original position of the elements.strict-containersPop the smallest element from the queue, using the supplied comparator.strict-containersPop the smallest element from the queue, using the supplied comparator, deferring to the item's original position when the comparator returns  .strict-containersPop the smallest element from the queue, using the supplied comparator on the tag.strict-containersPop the smallest element from the queue, using the supplied comparator on the tag, deferring to the item's original position when the comparator returns  .strict-containersA  $-like function, specialized to the BC= monoid, which takes advantage of the internal structure of  to avoid wrapping in   at certain points.strict-containersA D$-like function, specialized to the BC= monoid, which takes advantage of the internal structure of  to avoid wrapping in   at certain points.((8888(c) Ross Paterson 2005 (c) Louis Wasserman 2009 (c) Bertram Felgenhauer, David Feuer, Ross Paterson, and Milan Straka 2014 BSD-stylelibraries@haskell.orgportable Safe-Inferredl Safe-Inferrednstrict-containersThe position in the  is available as the index.E Safe-InferrednF Safe-Inferredo G(c) Roman Leshchinskiy 2009 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portable Safe-Inferredqe  3 2(c) Roman Leshchinskiy 2008-2010 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portable Safe-Inferred 6Kstrict-containers7Mutable boxed vectors keyed on the monad they live in (  or ST s). strict-containersOffset in underlying array strict-containers Size of slice strict-containersUnderlying arraystrict-containersLength of the mutable vector.strict-containers"Check whether the vector is empty.strict-containersYield a part of the mutable vector without copying it. The vector must contain at least i+n elements.strict-containers Take the n first elements of the mutable vector without making a copy. For negative n#, the empty vector is returned. If n is larger than the vector's length, the vector is returned unchanged.strict-containers Drop the n first element of the mutable vector without making a copy. For negative n', the vector is returned unchanged. If n is larger than the vector's length, the empty vector is returned.strict-containersO(1)) Split the mutable vector into the first n. elements and the remainder, without copying. Note that  n v is equivalent to ( n v,  n v), but slightly more efficient.strict-containersDrop the last element of the mutable vector without making a copy. If the vector is empty, an exception is thrown.strict-containersDrop the first element of the mutable vector without making a copy. If the vector is empty, an exception is thrown.strict-containersYield a part of the mutable vector without copying it. No bounds checks are performed.strict-containersUnsafe variant of . If n is out of range, it will simply create an invalid slice that likely violate memory safety.strict-containersUnsafe variant of . If n is out of range, it will simply create an invalid slice that likely violate memory safety.strict-containersSame as , but doesn't do range checks.strict-containersSame as , but doesn't do range checks.strict-containers"Check whether two vectors overlap.strict-containers,Create a mutable vector of the given length.strict-containersCreate a mutable vector of the given length. The vector elements are set to bottom, so accessing them will cause an exception.strict-containersCreate a mutable vector of the given length (0 if the length is negative) and fill it with an initial value.strict-containersCreate a mutable vector of the given length (0 if the length is negative) and fill it with values produced by repeatedly executing the monadic action. strict-containersO(n) Create a mutable vector of the given length (0 if the length is negative) and fill it with the results of applying the function to each index. Iteration starts at index 0. strict-containersO(n) Create a mutable vector of the given length (0 if the length is negative) and fill it with the results of applying the monadic function to each index. Iteration starts at index 0.strict-containers"Create a copy of a mutable vector.strict-containersGrow a boxed vector by the given number of elements. The number must be non-negative. This has the same semantics as  ' for generic vectors. It differs from grow functions for unpacked vectors, however, in that only pointers to values are copied over, therefore the values themselves will be shared between the two vectors. This is an important distinction to know about during memory usage analysis and in case the values themselves are of a mutable type, e.g. HI or another mutable vector.Examples0import qualified Data.Strict.Vector.Autogen as V9import qualified Data.Strict.Vector.Autogen.Mutable as MV5mv <- V.thaw $ V.fromList ([10, 20, 30] :: [Integer])mv' <- MV.grow mv 2The two extra elements at the end of the newly allocated vector will be uninitialized and will result in an error if evaluated, so me must overwrite them with new values first:MV.write mv' 3 999MV.write mv' 4 777 V.freeze mv'[10,20,30,999,777]It is important to note that the source mutable vector is not affected when the newly allocated one is mutated.MV.write mv' 2 888 V.freeze mv'[10,20,888,999,777] V.freeze mv [10,20,30]strict-containersGrow a vector by the given number of elements. The number must be non-negative, but this is not checked. This has the same semantics as   for generic vectors.strict-containersReset all elements of the vector to some undefined value, clearing all references to external objects.strict-containersYield the element at the given position. Will throw an exception if the index is out of range.Examples9import qualified Data.Strict.Vector.Autogen.Mutable as MVv <- MV.generate 10 (\x -> x*x) MV.read v 39 strict-containers1Yield the element at the given position. Returns   if the index is out of range.Examples9import qualified Data.Strict.Vector.Autogen.Mutable as MVv <- MV.generate 10 (\x -> x*x)MV.readMaybe v 3Just 9MV.readMaybe v 13Nothingstrict-containers*Replace the element at the given position.strict-containers)Modify the element at the given position. strict-containersModify the element at the given position using a monadic function.strict-containers)Swap the elements at the given positions.strict-containersReplace the element at the given position and return the old element.strict-containersYield the element at the given position. No bounds checks are performed.strict-containersReplace the element at the given position. No bounds checks are performed.strict-containersModify the element at the given position. No bounds checks are performed. strict-containersModify the element at the given position using a monadic function. No bounds checks are performed.strict-containersSwap the elements at the given positions. No bounds checks are performed.strict-containersReplace the element at the given position and return the old element. No bounds checks are performed.strict-containers2Set all elements of the vector to the given value.strict-containersCopy a vector. The two vectors must have the same length and may not overlap.strict-containersCopy a vector. The two vectors must have the same length and may not overlap, but this is not checked.strict-containersMove the contents of a vector. The two vectors must have the same length.:If the vectors do not overlap, then this is equivalent to . Otherwise, the copying is performed as if the source vector were copied to a temporary vector and then the temporary vector was copied to the target vector.strict-containersMove the contents of a vector. The two vectors must have the same length, but this is not checked.:If the vectors do not overlap, then this is equivalent to . Otherwise, the copying is performed as if the source vector were copied to a temporary vector and then the temporary vector was copied to the target vector.strict-containersCompute the (lexicographically) next permutation of the given vector in-place. Returns False when the input is the last permutation. strict-containersO(n) Apply the monadic action to every element of the vector, discarding the results. strict-containersO(n) Apply the monadic action to every element of the vector and its index, discarding the results. strict-containersO(n) Apply the monadic action to every element of the vector, discarding the results. It's the same as  flip mapM_. strict-containersO(n) Apply the monadic action to every element of the vector and its index, discarding the results. It's the same as  flip imapM_. strict-containersO(n) Pure left fold. strict-containersO(n)( Pure left fold with strict accumulator. strict-containersO(n) Pure left fold using a function applied to each element and its index. strict-containersO(n) Pure left fold with strict accumulator using a function applied to each element and its index. strict-containersO(n) Pure right fold. strict-containersO(n)) Pure right fold with strict accumulator. strict-containersO(n) Pure right fold using a function applied to each element and its index. strict-containersO(n) Pure right fold with strict accumulator using a function applied to each element and its index. strict-containersO(n) Monadic fold. strict-containersO(n)& Monadic fold with strict accumulator. strict-containersO(n) Monadic fold using a function applied to each element and its index. strict-containersO(n) Monadic fold with strict accumulator using a function applied to each element and its index. strict-containersO(n) Monadic right fold. strict-containersO(n), Monadic right fold with strict accumulator. strict-containersO(n) Monadic right fold using a function applied to each element and its index. strict-containersO(n) Monadic right fold with strict accumulator using a function applied to each element and its index. strict-containersO(n)8 Make a copy of a mutable array to a new mutable vector. strict-containersO(n): Make a copy of a mutable vector into a new mutable array.strict-containersi starting indexstrict-containersn lengthstrict-containersstarting indexstrict-containerslength of the slicestrict-containerstargetstrict-containerssourcestrict-containerstargetstrict-containerssourcestrict-containerstargetstrict-containerssourcestrict-containerstargetstrict-containerssource(c) Roman Leshchinskiy 2008-2010 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 BSD-style.Haskell Libraries Team  experimental non-portable Safe-Inferred 6'strict-containers,Boxed vectors, supporting efficient slicing.strict-containersO(1) Yield the length of the vector.strict-containersO(1) Test whether a vector is empty.strict-containersO(1) Indexing.strict-containersO(1) Safe indexing.strict-containersO(1) First element.strict-containersO(1) Last element.strict-containersO(1)) Unsafe indexing without bounds checking.strict-containersO(1)8 First element, without checking if the vector is empty.strict-containersO(1)7 Last element, without checking if the vector is empty.strict-containersO(1) Indexing in a monad.The monad allows operations to be strict in the vector when necessary. Suppose vector copying is implemented like this: © mv v = ... write mv i (v ! i) ...For lazy vectors, v ! i) would not be evaluated which means that mv, would unnecessarily retain a reference to v in each element written.With /, copying can be implemented like this instead: copy mv v = ... do x <- indexM v i write mv i xHere, no references to v$ are retained because indexing (but not$ the element) is evaluated eagerly.strict-containersO(1)+ First element of a vector in a monad. See + for an explanation of why this is useful.strict-containersO(1)* Last element of a vector in a monad. See + for an explanation of why this is useful.strict-containersO(1)1 Indexing in a monad, without bounds checks. See + for an explanation of why this is useful.strict-containersO(1) First element in a monad, without checking for empty vectors. See * for an explanation of why this is useful.strict-containersO(1) Last element in a monad, without checking for empty vectors. See * for an explanation of why this is useful.strict-containersO(1) Yield a slice of the vector without copying it. The vector must contain at least i+n elements.strict-containersO(1) Yield all but the last element without copying. The vector may not be empty.strict-containersO(1) Yield all but the first element without copying. The vector may not be empty.strict-containersO(1) Yield at the first n= elements without copying. The vector may contain less than n2 elements, in which case it is returned unchanged.strict-containersO(1) Yield all but the first n= elements without copying. The vector may contain less than n5 elements, in which case an empty vector is returned.strict-containersO(1) Yield the first n5 elements paired with the remainder, without copying. Note that  n v is equivalent to ( n v,  n v), but slightly more efficient. strict-containersO(1) Yield the  and  of the vector, or   if the vector is empty. strict-containersO(1) Yield the  and  of the vector, or   if the vector is empty.strict-containersO(1) Yield a slice of the vector without copying. The vector must contain at least i+n# elements, but this is not checked.strict-containersO(1) Yield all but the last element without copying. The vector may not be empty, but this is not checked.strict-containersO(1) Yield all but the first element without copying. The vector may not be empty, but this is not checked.strict-containersO(1) Yield the first n= elements without copying. The vector must contain at least n# elements, but this is not checked.strict-containersO(1) Yield all but the first n= elements without copying. The vector must contain at least n# elements, but this is not checked.strict-containersO(1) The empty vector.strict-containersO(1)# A vector with exactly one element.strict-containersO(n) A vector of the given length with the same value in each position.strict-containersO(n) Construct a vector of the given length by applying the function to each index.strict-containersO(n) Apply the function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). The 0th element will contain the initial value, which is why there is one less function application than the number of elements in the produced vector. \underbrace{x, f (x), f (f (x)), \ldots}_{\max(0,n)\rm{~elements}} Examples0import qualified Data.Strict.Vector.Autogen as V3V.iterateN 0 undefined undefined :: V.Vector String[] V.iterateN 4 (\x -> x <> x) "Hi"+["Hi","HiHi","HiHiHiHi","HiHiHiHiHiHiHiHi"]strict-containersO(n) Construct a vector by repeatedly applying the generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements. unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10 = <10,9,8,7,6,5,4,3,2,1>strict-containersO(n)! Construct a vector with at most n elements by repeatedly applying the generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements. -unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8> strict-containersO(n)! Construct a vector with exactly n elements by repeatedly applying the generator function to a seed. The generator function yields the next element and the new seed. -unfoldrExactN 3 (\n -> (n,n-1)) 10 = <10,9,8>strict-containersO(n) Construct a vector by repeatedly applying the monadic generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements.strict-containersO(n) Construct a vector by repeatedly applying the monadic generator function to a seed. The generator function yields  ' the next element and the new seed or   if there are no more elements. strict-containersO(n)! Construct a vector with exactly n elements by repeatedly applying the monadic generator function to a seed. The generator function yields the next element and the new seed.strict-containersO(n) Construct a vector with n elements by repeatedly applying the generator function to the already constructed part of the vector. constructN 3 f = let a = f <> ; b = f ; c = f in strict-containersO(n) Construct a vector with n elements from right to left by repeatedly applying the generator function to the already constructed part of the vector. constructrN 3 f = let a = f <> ; b = f ; c = f in strict-containersO(n); Yield a vector of the given length, containing the values x, x+15 etc. This operation is usually more efficient than . enumFromN 5 3 = <5,6,7>strict-containersO(n); Yield a vector of the given length, containing the values x, x+y, x+y+y5 etc. This operations is usually more efficient than . !enumFromStepN 1 2 5 = <1,3,5,7,9>strict-containersO(n) Enumerate values from x to y.WARNING:; This operation can be very inefficient. If possible, use  instead.strict-containersO(n) Enumerate values from x to y with a specific step z.WARNING:; This operation can be very inefficient. If possible, use  instead.strict-containersO(n) Prepend an element.strict-containersO(n) Append an element.strict-containersO(m+n) Concatenate two vectors.strict-containersO(n)% Concatenate all vectors in the list.strict-containersO(n) Execute the monadic action the given number of times and store the results in a vector.strict-containersO(n) Construct a vector of the given length by applying the monadic action to each index. strict-containersO(n) Apply the monadic function \max(n - 1, 0): times to an initial value, producing a vector of length  \max(n, 0). The 0th element will contain the initial value, which is why there is one less function application than the number of elements in the produced vector.For a non-monadic version, see .strict-containers;Execute the monadic action and freeze the resulting vector. create (do { v <- new 2; write v 0 'a'; write v 1 'b'; return v }) = <a,b> strict-containers)Here, the slice retains a reference to the huge vector. Forcing it creates a copy of just the elements that belong to the slice and allows the huge vector to be garbage collected.strict-containersO(m+n) For each pair (i,a) from the list of index/value pairs, replace the vector element at position i by a. ,<5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7>strict-containersO(m+n) For each pair (i,a) from the vector of index/value pairs, replace the vector element at position i by a. 0update <5,9,2,7> <(2,1),(0,3),(2,8)> = <3,9,8,7>strict-containersO(m+min(n1,n2)) For each index i4 from the index vector and the corresponding value a from the value vector, replace the element of the initial vector at position i by a. .update_ <5,9,2,7> <2,0,2> <1,3,8> = <3,9,8,7> The function  provides the same functionality and is usually more convenient. update_ xs is ys =  xs (  is ys) strict-containers Same as (), but without bounds checking.strict-containersSame as , but without bounds checking.strict-containersSame as , but without bounds checking.strict-containersO(m+n) For each pair (i,b), from the list, replace the vector element a at position i by f a b.Examples0import qualified Data.Strict.Vector.Autogen as VV.accum (+) (V.fromList [1000,2000,3000]) [(2,4),(1,6),(0,3),(1,10)][1003,2016,3004]strict-containersO(m+n) For each pair (i,b)7 from the vector of pairs, replace the vector element a at position i by f a b.Examples0import qualified Data.Strict.Vector.Autogen as VV.accumulate (+) (V.fromList [1000,2000,3000]) (V.fromList [(2,4),(1,6),(0,3),(1,10)])[1003,2016,3004]strict-containersO(m+min(n1,n2)) For each index i4 from the index vector and the corresponding value b from the the value vector, replace the element of the initial vector at position i by f a b. ?accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4> The function  provides the same functionality and is usually more convenient. accumulate_ f as is bs =  f as (  is bs) strict-containersSame as , but without bounds checking.strict-containersSame as , but without bounds checking.strict-containersSame as , but without bounds checking.strict-containersO(n) Reverse a vector. strict-containersO(n)5 Yield the vector obtained by replacing each element i of the index vector by xsi. This is equivalent to   (xs) is$, but is often much more efficient. 3backpermute <0,3,2,3,1,0> = strict-containersSame as  , but without bounds checking. strict-containersApply a destructive operation to a vector. The operation will be performed in place if it is safe to do so and will modify a copy of the vector otherwise. modify (\v -> write v 0 'x') ( 3 'a') = <'x','a','a'> strict-containersO(n). Pair each element in a vector with its index. strict-containersO(n) Map a function over a vector. strict-containersO(n)= Apply a function to every element of a vector and its index. strict-containers9Map a function over a vector and concatenate the results. strict-containersO(n) Apply the monadic action to all elements of the vector, yielding a vector of results. strict-containersO(n) Apply the monadic action to every element of a vector and its index, yielding a vector of results. strict-containersO(n) Apply the monadic action to all elements of a vector and ignore the results. strict-containersO(n) Apply the monadic action to every element of a vector and its index, ignoring the results. strict-containersO(n) Apply the monadic action to all elements of the vector, yielding a vector of results. Equivalent to flip  . strict-containersO(n) Apply the monadic action to all elements of a vector and ignore the results. Equivalent to flip  .  strict-containersO(n) Apply the monadic action to all elements of the vector and their indices, yielding a vector of results. Equivalent to    .  strict-containersO(n) Apply the monadic action to all elements of the vector and their indices and ignore the results. Equivalent to    . strict-containers O(min(m,n))) Zip two vectors with the given function. strict-containers*Zip three vectors with the given function. strict-containers O(min(m,n)) Zip two vectors with a function that also takes the elements' indices. strict-containers isUpper a == isUpper b) (V.fromList "Mississippi River")["M","ississippi ","R","iver"] See also 6J,  .  strict-containersO(n): Split a vector into a list of slices of the input vector.The concatenation of this list of slices is equal to the argument vector, and each slice contains only equal elements.Does not fuse.)This is the equivalent of 'groupBy (==)'.0import qualified Data.Strict.Vector.Autogen as V"V.group (V.fromList "Mississippi")$["M","i","ss","i","ss","i","pp","i"] See also 6K. strict-containersO(n)) Check if the vector contains an element. strict-containersO(n)= Check if the vector does not contain an element (inverse of  ). strict-containersO(n) Yield  - the first element matching the predicate or   if no such element exists. strict-containersO(n) Yield  ; the index of the first element matching the predicate or   if no such element exists. strict-containersO(n) Yield the indices of elements satisfying the predicate in ascending order. strict-containersO(n) Yield  < the index of the first occurrence of the given element or   if the vector does not contain the element. This is a specialised version of  . strict-containersO(n) Yield the indices of all occurrences of the given element in ascending order. This is a specialised version of  . strict-containersO(n) Left fold. strict-containersO(n) Left fold on non-empty vectors. strict-containersO(n)# Left fold with strict accumulator. strict-containersO(n)8 Left fold on non-empty vectors with strict accumulator. strict-containersO(n) Right fold. strict-containersO(n)! Right fold on non-empty vectors. strict-containersO(n)& Right fold with a strict accumulator. strict-containersO(n)9 Right fold on non-empty vectors with strict accumulator. strict-containersO(n) Left fold using a function applied to each element and its index. strict-containersO(n) Left fold with strict accumulator using a function applied to each element and its index. strict-containersO(n) Right fold using a function applied to each element and its index. strict-containersO(n) Right fold with strict accumulator using a function applied to each element and its index.  strict-containersO(n) Map each element of the structure to a monoid and combine the results. It uses the same implementation as the corresponding method of the  4 type class. Note that it's implemented in terms of   and won't fuse with functions that traverse the vector from left to right ( , , etc.).  strict-containersO(n) Like  , but strict in the accumulator. It uses the same implementation as the corresponding method of the  5 type class. Note that it's implemented in terms of   , so it fuses in most contexts. strict-containersO(n)- Check if all elements satisfy the predicate.Examples0import qualified Data.Strict.Vector.Autogen as V"V.all even $ V.fromList [2, 4, 12]True"V.all even $ V.fromList [2, 4, 13]False$V.all even (V.empty :: V.Vector Int)True strict-containersO(n). Check if any element satisfies the predicate.Examples0import qualified Data.Strict.Vector.Autogen as V!V.any even $ V.fromList [1, 3, 7]False"V.any even $ V.fromList [3, 2, 13]True$V.any even (V.empty :: V.Vector Int)False strict-containersO(n) Check if all elements are  .Examples0import qualified Data.Strict.Vector.Autogen as V V.and $ V.fromList [True, False]False V.and V.emptyTrue strict-containersO(n) Check if any element is  .Examples0import qualified Data.Strict.Vector.Autogen as VV.or $ V.fromList [True, False]True V.or V.emptyFalse strict-containersO(n)! Compute the sum of the elements.Examples0import qualified Data.Strict.Vector.Autogen as VV.sum $ V.fromList [300,20,1]321V.sum (V.empty :: V.Vector Int)0 strict-containersO(n)% Compute the product of the elements.Examples0import qualified Data.Strict.Vector.Autogen as V V.product $ V.fromList [1,2,3,4]24#V.product (V.empty :: V.Vector Int)1 strict-containersO(n) Yield the maximum element of the vector. The vector may not be empty. In case of a tie, the first occurrence wins.Examples0import qualified Data.Strict.Vector.Autogen as VV.maximum $ V.fromList [2, 1]2import Data.Semigroup-V.maximum $ V.fromList [Arg 1 'a', Arg 2 'b'] Arg 2 'b'-V.maximum $ V.fromList [Arg 1 'a', Arg 1 'b'] Arg 1 'a' strict-containersO(n) Yield the maximum element of the vector according to the given comparison function. The vector may not be empty. In case of a tie, the first occurrence wins. This behavior is different from 6L which returns the last tie.Examplesimport Data.Ord0import qualified Data.Strict.Vector.Autogen as V;V.maximumBy (comparing fst) $ V.fromList [(2,'a'), (1,'b')](2,'a');V.maximumBy (comparing fst) $ V.fromList [(1,'a'), (1,'b')](1,'a')  strict-containersO(n) Yield the maximum element of the vector by comparing the results of a key function on each element. In case of a tie, the first occurrence wins. The vector may not be empty.Examples0import qualified Data.Strict.Vector.Autogen as V/V.maximumOn fst $ V.fromList [(2,'a'), (1,'b')](2,'a')/V.maximumOn fst $ V.fromList [(1,'a'), (1,'b')](1,'a') strict-containersO(n) Yield the minimum element of the vector. The vector may not be empty. In case of a tie, the first occurrence wins.Examples0import qualified Data.Strict.Vector.Autogen as VV.minimum $ V.fromList [2, 1]1import Data.Semigroup-V.minimum $ V.fromList [Arg 2 'a', Arg 1 'b'] Arg 1 'b'-V.minimum $ V.fromList [Arg 1 'a', Arg 1 'b'] Arg 1 'a' strict-containersO(n) Yield the minimum element of the vector according to the given comparison function. The vector may not be empty. In case of a tie, the first occurrence wins.Examplesimport Data.Ord0import qualified Data.Strict.Vector.Autogen as V;V.minimumBy (comparing fst) $ V.fromList [(2,'a'), (1,'b')](1,'b');V.minimumBy (comparing fst) $ V.fromList [(1,'a'), (1,'b')](1,'a')  strict-containersO(n) Yield the minimum element of the vector by comparing the results of a key function on each element. In case of a tie, the first occurrence wins. The vector may not be empty.Examples0import qualified Data.Strict.Vector.Autogen as V/V.minimumOn fst $ V.fromList [(2,'a'), (1,'b')](1,'b')/V.minimumOn fst $ V.fromList [(1,'a'), (1,'b')](1,'a') strict-containersO(n) Yield the index of the maximum element of the vector. The vector may not be empty. strict-containersO(n) Yield the index of the maximum element of the vector according to the given comparison function. The vector may not be empty. In case of a tie, the first occurrence wins.Examplesimport Data.Ord0import qualified Data.Strict.Vector.Autogen as V Monadic fold over non-empty vectors that discards the result. strict-containersO(n)? Monadic fold with strict accumulator that discards the result. strict-containersO(n) Monadic fold with strict accumulator that discards the result using a function applied to each element and its index. strict-containersO(n) Monadic fold over non-empty vectors with strict accumulator that discards the result. strict-containers-Evaluate each action and collect the results. strict-containers-Evaluate each action and discard the results. strict-containersO(n) Left-to-right prescan. prescanl f z =  .   f z Examples0import qualified Data.Strict.Vector.Autogen as V'V.prescanl (+) 0 (V.fromList [1,2,3,4]) [0,1,3,6] strict-containersO(n)/ Left-to-right prescan with strict accumulator. strict-containersO(n) Left-to-right postscan. postscanl f z =  .   f z Examples0import qualified Data.Strict.Vector.Autogen as V(V.postscanl (+) 0 (V.fromList [1,2,3,4]) [1,3,6,10] strict-containersO(n)0 Left-to-right postscan with strict accumulator. strict-containersO(n) Left-to-right scan. scanl f z = where y1 = z yi = f y(i-1) x(i-1)Examples0import qualified Data.Strict.Vector.Autogen as V$V.scanl (+) 0 (V.fromList [1,2,3,4]) [0,1,3,6,10] strict-containersO(n), Left-to-right scan with strict accumulator.  strict-containersO(n)1 Left-to-right scan over a vector with its index.  strict-containersO(n)< Left-to-right scan over a vector (strictly) with its index. strict-containersO(n)5 Initial-value free left-to-right scan over a vector. scanl f = where y1 = x1 yi = f y(i-1) xiNote: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples0import qualified Data.Strict.Vector.Autogen as V(V.scanl1 min $ V.fromListN 5 [4,2,4,1,3] [4,2,2,1,1](V.scanl1 max $ V.fromListN 5 [1,3,2,5,4] [1,3,3,5,5]&V.scanl1 min (V.empty :: V.Vector Int)[] strict-containersO(n) Initial-value free left-to-right scan over a vector with a strict accumulator.Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples0import qualified Data.Strict.Vector.Autogen as V)V.scanl1' min $ V.fromListN 5 [4,2,4,1,3] [4,2,2,1,1])V.scanl1' max $ V.fromListN 5 [1,3,2,5,4] [1,3,3,5,5]'V.scanl1' min (V.empty :: V.Vector Int)[] strict-containersO(n) Right-to-left prescan. prescanr f z =  .   (flip f) z .  strict-containersO(n)/ Right-to-left prescan with strict accumulator. strict-containersO(n) Right-to-left postscan. strict-containersO(n)0 Right-to-left postscan with strict accumulator. strict-containersO(n) Right-to-left scan. strict-containersO(n), Right-to-left scan with strict accumulator.  strict-containersO(n)1 Right-to-left scan over a vector with its index.  strict-containersO(n)< Right-to-left scan over a vector (strictly) with its index. strict-containersO(n)6 Right-to-left, initial-value free scan over a vector.Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples0import qualified Data.Strict.Vector.Autogen as V(V.scanr1 min $ V.fromListN 5 [3,1,4,2,4] [1,1,2,2,4](V.scanr1 max $ V.fromListN 5 [4,5,2,3,1] [5,5,3,3,1]&V.scanr1 min (V.empty :: V.Vector Int)[] strict-containersO(n) Right-to-left, initial-value free scan over a vector with a strict accumulator.Note: Since 0.13, application of this to an empty vector no longer results in an error; instead it produces an empty vector.Examples0import qualified Data.Strict.Vector.Autogen as V)V.scanr1' min $ V.fromListN 5 [3,1,4,2,4] [1,1,2,2,4])V.scanr1' max $ V.fromListN 5 [4,5,2,3,1] [5,5,3,3,1]'V.scanr1' min (V.empty :: V.Vector Int)[]  strict-containersO(n) Check if two vectors are equal using the supplied equality predicate.  strict-containersO(n) Compare two vectors using the supplied comparison function for vector elements. Comparison works the same as for lists. cmpBy compare == compare strict-containersO(n) Convert a vector to a list. strict-containersO(n) Convert a list to a vector. strict-containersO(n) Convert the first n elements of a list to a vector. It's expected that the supplied list will be exactly n elements long. As an optimization, this function allocates a buffer for n elements, which could be used for DoS-attacks by exhausting the memory if an attacker controls that parameter. fromListN n xs =   ( n xs)  strict-containersO(1) Convert an array to a vector.  strict-containersO(n) Convert a vector to an array.  strict-containersO(1) Extract the underlying  , offset where vector starts and the total number of elements in the vector. Below property always holds: let (array, offset, len) = toArraySlice v v === unsafeFromArraySlice len offset array  strict-containersO(1) Convert an array slice to a vector. This function is very unsafe, because constructing an invalid vector can yield almost all other safe functions in this module unsafe. These are equivalent: unsafeFromArraySlice len offset === unsafeTake len . unsafeDrop offset . fromArray strict-containersO(1) Unsafely convert a mutable vector to an immutable one without copying. The mutable vector may not be used after this operation. strict-containersO(n)/ Yield an immutable copy of the mutable vector. strict-containersO(1) Unsafely convert an immutable vector to a mutable one without copying. Note that this is a very dangerous function and generally it's only safe to read from the resulting vector. In this case, the immutable vector could be used safely as well.Problems with mutation happen because GHC has a lot of freedom to introduce sharing. As a result mutable vectors produced by  unsafeThaw? may or may not share the same underlying buffer. For example: foo = do let vec = V.generate 10 id mvec <- V.unsafeThaw vec do_something mvecHere GHC could lift vec/ outside of foo which means that all calls to  do_something will use same buffer with possibly disastrous results. Whether such aliasing happens or not depends on the program in question, optimization levels, and GHC flags.4All in all, attempts to modify a vector produced by  unsafeThaw fall out of domain of software engineering and into realm of black magic, dark rituals, and unspeakable horrors. The only advice that could be given is: "Don't attempt to mutate a vector produced by  unsafeThaw unless you know how to prevent GHC from aliasing buffers accidentally. We don't." strict-containersO(n)- Yield a mutable copy of an immutable vector. strict-containersO(n) Copy an immutable vector into a mutable one. The two vectors must have the same length. This is not checked. strict-containersO(n) Copy an immutable vector into a mutable one. The two vectors must have the same length.  strict-containers:This instance has the same semantics as the one for lists.  strict-containers  strict-containers strict-containersi starting indexstrict-containersn lengthstrict-containersi starting indexstrict-containersn lengthstrict-containersinitial vector (of length m)strict-containers%list of index/value pairs (of length n)strict-containersinitial vector (of length m)strict-containers'vector of index/value pairs (of length n)strict-containersinitial vector (of length m)strict-containersindex vector (of length n1)strict-containersvalue vector (of length n2)strict-containersaccumulating function fstrict-containersinitial vector (of length m)strict-containers%list of index/value pairs (of length n)strict-containersaccumulating function fstrict-containersinitial vector (of length m)strict-containers'vector of index/value pairs (of length n)strict-containersaccumulating function fstrict-containersinitial vector (of length m)strict-containersindex vector (of length n1)strict-containersvalue vector (of length n2) strict-containersImmutable boxed array.strict-containersOffsetstrict-containersLength   5 4 4 Safe-Inferred*M Safe-Inferred* NOPQRSQRTQRTUVWXYZXY[\]^_`abcdefghijkl m m n o!p!q!rstu v w x x y z z { | } ~                    ?       , -                                        (         ?                          $            , -                                                       ""?""""""""""""$""""""(?)9:$,-/0/0?)$*(?)459:$,-/0/0?)$=~(D45h~45=-,~45=78JK-,LQ-!!!NNO      NNQQ Q  Q      NQQQ"""",?QUVUVQQQQQQUVUV0UV/UVUVUVUVUVUVUVUVUV-UVUV,UV.UVUVUVUVUVUVUVUVUVUVUVUVUVUVUVUVUVUVUVUVUVUVUVUV?UVUVUVUVUVUVUVUVUVUVQQUUUQBQQQQzQ,QQNOQQQQNQ~NQUU0U/UUUUUUUUUUUUU5U4UUUUUUUUUUUUUUUUU-UU,U.UUUUUUUUUUUUUUUUUUUU?UUUUUUUUUQGGGGGGGGGGGGGN\\QXz+strict-containers-0.2-wNLN6SH1Ig3uC6wtMh5Gp"Data.Strict.Vector.Autogen.Mutable Data.Strict.Map.Autogen.Internal*Data.Strict.IntMap.Autogen.Strict.InternalData.Strict.Vector.Autogen+Data.Strict.ContainersUtils.Autogen.BitUtil,Data.Strict.ContainersUtils.Autogen.BitQueue%Data.Strict.Sequence.Autogen.Internal.Data.Strict.ContainersUtils.Autogen.StrictPair-Data.Strict.ContainersUtils.Autogen.TypeError*Data.Strict.HashMap.Autogen.Internal.Array)Data.Strict.HashMap.Autogen.Internal.List$Data.Strict.HashMap.Autogen.Internal"Data.Strict.HashMap.Autogen.StrictData.Strict.HashMap.Internal'Data.Strict.IntMap.Autogen.Merge.Strict#Data.Strict.IntMap.Autogen.Internal)Data.Strict.IntMap.Autogen.Internal.Debug3Data.Strict.IntMap.Autogen.Internal.DeprecatedDebugData.Strict.IntMap.Internal$Data.Strict.Map.Autogen.Merge.Strict'Data.Strict.Map.Autogen.Strict.InternalData.Strict.Map.Autogen.Strict&Data.Strict.Map.Autogen.Internal.Debug3Data.Strict.Map.Autogen.Internal.DeprecatedShowTreeData.Strict.Map.InternalData.Strict.Sequence.Autogen-Data.Strict.Sequence.Autogen.Internal.SortingData.Strict.Sequence.InternalData.Strict.Vector.Internal-Data.Strict.ContainersUtils.Autogen.Coercions/Data.Strict.ContainersUtils.Autogen.PtrEquality)Data.Strict.ContainersUtils.Autogen.State/Data.Strict.ContainersUtils.Autogen.StrictMaybe+Data.Strict.HashMap.Autogen.Internal.Strict Data.Strict.HashMap.Autogen.LazytraverseWithKeyData.Strict.HashMapData.Strict.HashSetData.MaplookupupdateLookupWithKeyMapPreludefoldrfoldlfoldshowTree showTreeWith!Data.Strict.IntMap.Autogen.StrictData.Strict.IntMapData.Strict.IntSettakedrop Data.List takeWhile dropWhilemergemergeAData.Strict.Map Control.Monad replicateM Data.Map.Lazyinsert Data.FunctiononData.SemigroupOptionfoldMapWithIndexData.Strict.SequenceData.Strict.Set)Data.Strict.Vector.Autogen.Internal.Check Data.IORefIORefgroupBygroup maximumByData.Strict.Vectorghc-primGHC.Prim RealWorldbaseData.Functor.Identity runIdentityIdentity'containers-0.6.6-FcaZf6fx0xTB4RI0upGEsxData.IntSet.InternalKey'primitive-0.7.4.0-5Mou7sRsTgfjuEOfjOZOzControl.Monad.Primitive PrimState PrimMonad&vector-0.13.0.0-7U8pFThXyYFEKl1vrDAyiEData.Vector.GenericconvertbitcounthighestBitMaskshiftRLshiftLLwordSizeBitQueue BitQueueBemptyQBsnocQBbuildQunconsQtoListQ$fShowBitQueueB$fShowBitQueueStaterunState execStateMaybeSNothingSJustS StrictPair:*:toPairWhoops $fWhoopsaMArrayunMArrayArrayunArrayunsafeSameArray sameArray1lengthlengthMnewnew_shrink singleton singletonMsnocpairreadwriteindexindex#indexM unsafeFreeze unsafeThawruncopycopyMtriminsertMupdate updateWith' unsafeUpdateMfoldl'foldr'foldMapallthawdeletemapmap'fromList fromList'toListtraverse traverse'$fLiftBoxedRepArray$fNFData1Array $fNFDataArray $fShowArrayisPermutationByunorderedComparedeleteBy LookupResAbsentPresentBitmapHashHashMapEmpty BitmapIndexedLeafFull CollisionLhash equalKeys1 equalKeysemptynullsizememberlookup'lookupRecordCollision!?findWithDefault lookupDefault! collisionbitmapIndexedOrFullinsert' insertNewKeyinsertKeyExists unsafeInserttwo insertWithinsertModifyingdelete'deleteKeyExistsadjustadjust#alteralterF isSubmapOf isSubmapOfByunion unionWith unionWithKey unionArrayByunionscompose mapWithKeymapKeys differencedifferenceWith intersectionintersectionWithintersectionWithKeyintersectionWithKey# foldlWithKey' foldrWithKey' foldrWithKey foldlWithKeyfoldMapWithKeymapMaybeWithKeymapMaybe filterWithKey filterMapAuxfilterkeyselems fromListWithfromListWithKeyupdateOrConcatWithKeyupdate32 update32M update32With' bitsPerSubkeymask sparseIndex fullNodeMaskptrEq $fNFData2Leaf $fNFData1Leaf$fLiftBoxedRepLeaf $fNFDataLeaf$fIsListHashMap$fHashableHashMap$fHashable1HashMap$fHashable2HashMap $fOrdHashMap $fOrd1HashMap $fOrd2HashMap $fEqHashMap $fEq1HashMap $fEq2HashMap$fTraversableHashMap $fShowHashMap $fReadHashMap$fRead1HashMap$fShow1HashMap$fShow2HashMap $fDataHashMap$fMonoidHashMap$fSemigroupHashMap$fBifoldableHashMap$fFoldableHashMap$fFunctorHashMap$fNFData2HashMap$fNFData1HashMap$fNFDataHashMap$fEqLeaf$fLiftBoxedRepHashMap$fBinaryHashMap$fTraversableWithIndexkHashMap$fFoldableWithIndexkHashMap$fFunctorWithIndexkHashMap$fStrictHashMapHashMapSimpleWhenMatched WhenMatched matchedKeySimpleWhenMissing WhenMissingmissingSubtree missingKeyMaskPrefixIntMapBinTipNilNat natFromInt intFromNat\\ notMemberlookupLTlookupGTlookupLElookupGEdisjoint insertWithKeyinsertLookupWithKey adjustWithKey updateWithKey unionsWithdifferenceWithKey withoutKeys restrictKeys mergeWithKey mergeWithKey'mapWhenMissingmapGentlyWhenMissingmapGentlyWhenMatchedlmapWhenMissingcontramapFirstWhenMatchedcontramapSecondWhenMatchedrunWhenMatchedrunWhenMissingmapWhenMatchedzipWithMatchedzipWithAMatchedzipWithMaybeMatchedzipWithMaybeAMatched dropMissingpreserveMissing mapMissingmapMaybeMissing filterMissingfilterAMissingtraverseMissingtraverseMaybeMissingtraverseMaybeWithKeyupdateMinWithKeyupdateMaxWithKeymaxViewWithKeyminViewWithKey updateMax updateMinmaxViewminView deleteFindMax deleteFindMin lookupMinfindMin lookupMaxfindMax deleteMin deleteMaxisProperSubmapOfisProperSubmapOfBymapAccummapAccumWithKeymapAccumRWithKey mapKeysWithmapKeysMonotonic partitionpartitionWithKey mapEithermapEitherWithKeysplit splitLookupassocskeysSetfromSet toAscList toDescList fromAscListfromAscListWithfromAscListWithKeyfromDistinctAscListlink linkWithMaskbin binCheckLeft binCheckRightzeronomatchmatchmaskWshorter branchMask splitRoot $fRead1IntMap $fReadIntMap $fShow1IntMap $fShowIntMap$fFunctorIntMap $fOrd1IntMap $fOrdIntMap $fEq1IntMap $fEqIntMap$fIsListIntMap $fDataIntMap$fNFDataIntMap$fTraversableIntMap$fFoldableIntMap$fSemigroupIntMap$fMonoidIntMap$fMonadWhenMissing$fApplicativeWhenMissing$fCategoryTYPEWhenMissing$fFunctorWhenMissing$fMonadWhenMatched$fApplicativeWhenMatched$fCategoryTYPEWhenMatched$fFunctorWhenMatched$fLiftBoxedRepIntMap$fBinaryIntMap$fTraversableWithIndexIntIntMap$fFoldableWithIndexIntIntMap$fFunctorWithIndexIntIntMap$fStrictIntMapIntMap AreWeStrictStrictLazySize atKeyImpl atKeyPlain findIndex lookupIndexelemAtsplitAtupdateAtdeleteAtpreserveMissing'takeWhileAntitonedropWhileAntitone spanAntitoneargSet fromArgSet fromDescListfromDescListWithfromDescListWithKeyfromDistinctDescList insertMaxlink2gluedeltabalancebalanceLbalanceR $fShowMap $fReadMap $fNFDataMap$fBifoldableMap $fFoldableMap$fTraversableMap $fFunctorMap $fRead1Map $fShow1Map $fShow2Map $fOrd1Map $fOrd2Map$fEq1Map$fEq2Map$fOrdMap$fEqMap $fIsListMap $fDataMap$fSemigroupMap $fMonoidMap$fLiftBoxedRepMap showsTree showsTreeHangshowWide showsBarsnodewithBar withEmptyvalidorderedbalanced validsize $fBinaryMap$fTraversableWithIndexkMap$fFoldableWithIndexkMap$fFunctorWithIndexkMap$fStrictMapMapViewREmptyR:>ViewLEmptyL:<ElemgetElemNodeNode2Node3DigitOneTwoThreeFour FingerTreeEmptyTSingleDeepSeq MaybeForceSized:|>:<| liftA2Seq interspersedeep foldDigitfoldNodenode2node3 replicate replicateA cycleTaking<||>><unfoldrunfoldliterateNviewlviewrscanlscanl1scanrscanr1insertAt mapWithIndexfoldWithIndexDigitfoldWithIndexNodetraverseWithIndex fromFunction fromArraychunksOftailsinitsfoldlWithIndexfoldrWithIndex takeWhileL takeWhileR dropWhileL dropWhileRspanlspanrbreaklbreakr elemIndexL elemIndexR elemIndicesL elemIndicesR findIndexL findIndexR findIndicesL findIndicesRreverseunzip unzipWithzipzipWithzip3zipWith3zip4zipWith4$fSizedForceBox$fMaybeForceForceBox $fSizedDigit $fNFDataDigit$fTraversableDigit$fFunctorDigit$fFoldableDigit $fSizedNode $fNFDataNode$fTraversableNode $fFunctorNode$fFoldableNode$fMaybeForceNode$fNFDataFingerTree$fTraversableFingerTree$fFunctorFingerTree$fFoldableFingerTree $fNFDataElem$fTraversableElem$fFoldableElem $fFunctorElem $fSizedElem$fSizedFingerTree$fMaybeForceElem $fMonadZipSeq $fIsStringSeq $fIsListSeq$fSemigroupSeq $fMonoidSeq $fRead1Seq $fReadSeq $fOrd1Seq$fEq1Seq $fShow1Seq $fShowSeq$fOrdSeq$fEqSeq$fAlternativeSeq$fMonadPlusSeq$fApplicativeSeq $fMonadFixSeq $fMonadSeq $fNFDataSeq$fTraversableSeq $fFoldableSeq $fFunctorSeq$fLiftBoxedRepSeq$fTraversableViewL$fFoldableViewL$fFunctorViewL $fDataSeq$fTraversableViewR$fFoldableViewR$fFunctorViewR$fUnzipWithSeq$fUnzipWithFingerTree$fUnzipWithDigit$fUnzipWithNode$fUnzipWithElem $fEqViewR $fOrdViewR $fShowViewR $fReadViewR $fEqViewL $fOrdViewL $fShowViewL $fReadViewL$fLiftBoxedRepViewR$fGenericViewR$fGeneric1TYPEViewR $fDataViewR$fLiftBoxedRepViewL$fGenericViewL$fGeneric1TYPEViewL $fDataViewL $fGenericElem$fGeneric1TYPEElem$fLiftBoxedRepNode $fGenericNode$fGeneric1TYPENode$fLiftBoxedRepDigit$fGenericDigit$fGeneric1TYPEDigit$fLiftBoxedRepFingerTree$fGenericFingerTree$fGeneric1TYPEFingerTreeITQListITQNilITQConsIndexedTaggedQueueITQTQListTQNilTQCons TaggedQueueTQIQListIQNilIQCons IndexedQueueIQQListQConsQueueQsortsortBysortOn unstableSortunstableSortByunstableSortOnmergeQmergeTQmergeIQmergeITQpopMinQpopMinIQpopMinTQ popMinITQbuildIQbuildTQbuildITQfoldToMaybeTreefoldToMaybeWithIndexTree $fBinarySeq$fTraversableWithIndexIntSeq$fFoldableWithIndexIntSeq$fFunctorWithIndexIntSeq$fStrictSeqSeqSTVectorIOVectorMVectorsliceinittail unsafeSlice unsafeTake unsafeDrop unsafeInit unsafeTailoverlaps unsafeNewgenerate generateMclonegrow unsafeGrowclear readMaybemodifymodifyMswapexchange unsafeRead unsafeWrite unsafeModify unsafeModifyM unsafeSwapunsafeExchangeset unsafeCopymove unsafeMovenextPermutationmapM_imapM_forM_iforM_ifoldlifoldl'ifoldrifoldr'foldMfoldM'ifoldMifoldM'foldrMfoldrM'ifoldrMifoldrM'fromMutableArraytoMutableArray$fMVectorMVectoraVectorheadlast unsafeIndex unsafeHead unsafeLastheadMlastM unsafeIndexM unsafeHeadM unsafeLastMunconsunsnocunfoldrN unfoldrExactNunfoldrM unfoldrNMunfoldrExactNM constructN constructrN enumFromN enumFromStepN enumFromToenumFromThenTocons++concat iterateNMcreatecreateTforce//update_ unsafeUpd unsafeUpdate unsafeUpdate_accum accumulate accumulate_ unsafeAccumunsafeAccumulateunsafeAccumulate_ backpermuteunsafeBackpermuteindexedimap concatMapmapMimapMforMiforMzipWith5zipWith6izipWith izipWith3 izipWith4 izipWith5 izipWith6zip5zip6unzip3unzip4unzip5unzip6zipWithM izipWithM zipWithM_ izipWithM_ifilteruniq imapMaybe catMaybesfilterM mapMaybeM imapMaybeM partitionWithunstablePartitionspanbreakelemnotElemfind findIndices elemIndex elemIndicesfoldl1foldl1'foldr1foldr1'foldMap'anyandorsumproductmaximum maximumOnminimum minimumBy minimumOnmaxIndex maxIndexByminIndex minIndexByfold1Mfold1M'foldM_ifoldM_fold1M_foldM'_ifoldM'_fold1M'_sequence sequence_prescanl prescanl' postscanl postscanl'scanl'iscanliscanl'scanl1'prescanr prescanr' postscanr postscanr'scanr'iscanriscanr'scanr1'eqBycmpBy fromListNtoArray toArraySliceunsafeFromArraySlicefreeze$fTraversableVector$fFoldableVector$fAlternativeVector$fApplicativeVector$fMonadFixVector$fMonadZipVector$fMonadPlusVector$fMonadFailVector $fMonadVector$fFunctorVector$fMonoidVector$fSemigroupVector $fOrd1Vector $fEq1Vector $fOrdVector $fEqVector$fVectorVectora $fDataVector$fIsListVector $fRead1Vector $fShow1Vector $fReadVector $fShowVector$fNFData1Vector$fNFDataVector$fBinaryVector$fTraversableWithIndexIntVector$fFoldableWithIndexIntVector$fFunctorWithIndexIntVector$fStrictVectorVector.^# Data.Foldable.#hetPtrEqmaybeStoMaybetoMaybeS GHC.TypesSymbolshrinkSmallMutableArray#updateMdeleteMShift maxChildrenleavesAndCollisionsisLeafOrCollisionTrueFalse GHC.MaybeNothingGHC.ErrerrorunsafeInsertWithJust alterFEagersubmapBitmapIndexedGHC.Base Applicative searchSwaplookupInArrayContindexOf subsetArray subkeyMask GHC.ClassesEqmemptymappend<>updateOrSnocWithupdateOrSnocWithKey4unordered-containers-0.2.19.1-D77pYkyyb3S4dRC8p0crieData.HashSet.Internal isSubsetOffromMaptoMapHashSetconst lookupPrefixidfilterWithKeyAboolMaybeData.Traversable mapAccumL Data.EitherLeftRight Data.TupleuncurryfromMonoListWithKey mapMonotonic splitMemberisProperSubsetOfIntSet Semigroup insertWithRinsertWithKeyRData.Functor.ConstConst lookupMaxSureData.Set.InternalSetArgDigit23RigidThincoerceFT liftA2MiddlemapMulFTfmaprigidify rigidifyRightthin digitToTree'applicativeTree replicateEachliftA2pureGHC.ArruncheckedSplitAt tailsTree initsTreeFoldable fmapReversesplitMapseqfstsndzipWith' fromList2Control.Monad.ZipmzipWithmunzip Rep_ViewR Rep1_ViewR Rep_ViewL Rep1_ViewLRep_Elem Rep1_ElemRep_Node Rep1_Node Rep_Digit Rep1_DigitRep_FingerTreeRep1_FingerTree$!?consTreesnocTree appendTree0compareEQ disjointUnioncartesianProductpowerSetGHC.Stack.Types HasCallStackChecksBoundsUnsafeInternaldoChecks internalErrorcheck checkIndex checkLength checkSliceinRange&&||IO_offset_size_arrayData.Vector.Generic.MutableflipData.Primitive.Array