(1Ǟ      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!@Do you have any idea how unsafe this method is? No, because you'#re STILL SANE ENOUGH TO READ THIS. The ReprF type class denotes that a type can be decomposed to a representation # built out of pieces for which the TrieKey- class defines a generalized trie structure. It is required that, if ( a,  a), and  x, y :: a, then x  y  if and only if  x   y!. It is typically the case that   x y ==  ( x) ( y), as well, but this is not Z strictly required. (It is, however, the case for all instances built into the package.) As an additional note, the Key modifier is used for " bootstrapping"  instances, ' allowing a type to be used in its own  definition when wrapped in a Key modifier.              Given a type with an associated : instance, generates a representation that will cause its TMap 0 implementation to be essentially equivalent to Data.Map. KGiven the name of a type constructor, automatically generates an efficient  instance. L If you have several mutually dependent (or even mutually recursive) types,  will ( construct instances for all of them. R guarantees that any instances it generates are consistent with the ordering that  would be generated by  deriving ()' in the data declaration. That is, if   generates an instance Repr a , then it is guaranteed that if  x, y :: a, and a  has a derived  instance, then *compare x y == compare (toRep x) (toRep y). KGiven the name of a type constructor, automatically generates an efficient  instance. L If you have several mutually dependent (or even mutually recursive) types,  will A construct instances for all of them. The instance generated by  may, in some 9 cases, be more efficient than the instance generated by  -- in particular, ^ arguments common to several constructors may be factored out, reducing the complexity of the  associated TrieKey5 instance, but leaving an ordering inconsistent with .  Therefore, D guarantees that any instances it generates are consistent with the % ordering that would be generated by  deriving ()' in the data declaration. That is, if   generates an instance Repr a , then it is guaranteed that if  x, y :: a, and  a has a derived  instance, then  (x == y) == (toRep x == toRep y).                 DWe embed IntN into WordN, but we have to be careful about overflow.   ( ) =   ( ) =  , by viewing each  as two s.  (  ) =  , by packing multiple   s into each  for space efficiency. ! ( ") =  , by packing multiple " s into each  for space efficiency. # $ = F, by way of a careful translation of their domains to avoid overflow. %   = (, )&  ' = (    = )  " = *   = +  , =  ( ")-  . =  ( ") /0123456789 /0123456789 /0101234534567789:;<=>?@;<=>?@;<=<=>?@?@NA  TrieKey k instance implies that k. is a standardized representation for which a , generalized trie structure can be derived. ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~NABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~N"BCDEFGHIJKLMNOPQRSATUVWXYZ[\]^_`aABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdecdefihgghijklmnopqrstuvwxyz{|}~ k is a handy alias for ( k,  ( k))!. To make a type an instance of ,  create a  instance that will satisfy  ( k)., possibly using the Template Haskell methods  provided by Data.TrieMap.Representation. A set of values a, backed by a trie. A map from keys k to values a, backed by a trie.   5  a is based on  Data.IntMap. A5 ( k) a is based on Data.Map.  () a is implemented as  a.  (k1, k2) a is implemented as a  k1 ( k2 a).       ( k1 k2) a is essentially a (TrieMap k1 a, TrieMap k2 a), but = specialized for the cases where one or both maps are empty.  (  k) a is a wrapper around a TrieMap (Rep k) a.  !"#$%&'()*+,-./012) !"#$%&'()*+3456789:;<=>,-./012 !  "#$%$&'&()*()+,-./012?@ABCDEFGHIJKLMNOP?@ABCDEFGHIJKLMNOP?@ABCDEFGHIJKLMNOPQR ( Word) a: is a traditional radix trie specialized for word arrays. S (T k) a is a traditional radix trie.  UVWXYZ[ (  k) a is a wrapper around a  k a, that reverses the order of the operations. !& The empty . Insert an element into the . Delete an element from the . O(1). Create a singleton set. The union of two !s, preferring the first set when ! equal elements are encountered.  The symmetric difference of two s. Difference of two s. !Intersection of two 4s. Elements of the result come from the first set. "0Filter all elements that satisfy the predicate. #DPartition the set into two sets, one with all elements that satisfy 1 the predicate and one with all elements that don't satisfy the predicate.  See also $. $The expression ($ x set ) is a pair  (set1,set2)  where set1 comprises the elements of set less than x and set2  comprises the elements of set greater than x. % Performs a $$ but also returns whether the pivot ( element was found in the original set. && f s! is the set obtained by applying f to each element of s. It'>s worth noting that the size of the result may be smaller if,  for some (x,y), x /= y && f x == f y '' f s == & f s, but works only when f is monotonic.   The precondition is not checked.  Semi-formally, we have: / and [x < y ==> f x < f y | x <- ls, y <- ls] 5 ==> mapMonotonic f s == map f s  where ls = toList s (Post-order fold. )Pre-order fold. * The minimal element of the set. + The maximal element of the set. ,Delete the minimal element. -Delete the maximal element. .%Delete and find the minimal element. 8 'deleteFindMin' set = ('findMin' set, 'deleteMin' set) /%Delete and find the maximal element. 8 'deleteFindMax' set = ('findMax' set, 'deleteMax' set) 02Retrieves the minimal key of the set, and the set  stripped of that element, or \ if passed an empty set. 12Retrieves the maximal key of the set, and the set  stripped of that element, or \ if passed an empty set. 2See 4. 3See 4. 42Convert the set to an ascending list of elements. 5&Create a set from a list of elements. 63Build a set from an ascending list in linear time.  :The precondition (input list is ascending) is not checked. 7O(n)J. Build a set from an ascending list of distinct elements in linear time.  CThe precondition (input list is strictly ascending) is not checked. 8O(1). Is this the empty set? 9O(1)%. The number of elements in the set. :Is the element in the set? ;Is the element not in the set? <Is this a subset? (s1 < s2) tells whether s1 is a subset of s2. =7Is this a proper subset? (ie. a subset but not equal). >See  . ? Generate a ! by mapping on the elements of a . ' !"#$%&'()*+,-./0123456789:;<=>?'>89:;<=! "#$%&')(*+,-./01?235467& !"#$%&'()*+,-./0123456789:;<=>?b@A @ represents a  with a "hole" at a particular key position. @hs are used for element-wise operations on maps (insertion, deletion and update) in a two-stage process:  A @= (and the value at that position, if any) is obtained from a  by searching or indexing.  2. A new  is made from a @* by either filling the hole with a value () or erasing it (). ]AO(1). The empty map. BO(1). A map with a single element. CO(1). Is the map empty? D&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. EThe expression (E def k map) returns the value at key k or returns default value def ! when the key is not in the map. FFind the value at a key. Calls _$ when the element can not be found. GThe expression (G f k map) alters the value x at k, or absence thereof.  G7 can be used to insert, delete, or update a value in a  . In short:  D k (G f k m) = f (D k m). H'Insert a new key and value in the map. C If the key is already present in the map, the associated value is # replaced with the supplied value. H is equivalent to  I `. M insert 5 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'x')] W insert 7 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'a'), (7, 'x')] ? insert 5 'x' empty == singleton 5 'x' I;Insert with a function, combining new value and old value.  I 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")] d insertWith (++) 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")] L insertWith (++) 5 "xxx" empty == singleton 5 "xxx" J@Insert with a function, combining key, new value and old value.  J 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). 9 Note that the key passed to f is the same key passed to J. T 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")] d insertWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")] L insertWithKey f 5 "xxx" empty == singleton 5 "xxx" K4Combines insert operation with old value retrieval.  The expression (K f k x map) 0 is a pair where the first element is equal to (D k map) " and the second element equal to (J f k x map). T let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value p insertLookupWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "5:xxx|a")]) v 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") L=Delete a key and its value from the map. When the key is not 4 a member of the map, the original map is returned. ; delete 5 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" I delete 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] 1 delete 5 empty == empty MKUpdate a value at a specific key with the result of the provided function. H When the key is not a member of the map, the original map is returned. Y adjust ("new " ++) 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")] U adjust ("new " ++) 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] = adjust ("new " ++) 7 empty == empty N6Adjust a value at a specific key. When the key is not 4 a member of the map, the original map is returned. * let f key x = (show key) ++ ":new " ++ x X adjustWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")] R adjustWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] : adjustWithKey f 7 empty == empty OThe expression (O 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. 6 let f x = if x == "a" then Just "new a" else Nothing O update f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")] K update f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] = update f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a" PThe expression (P 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. G let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing X updateWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")] R updateWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] D updateWithKey f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a" Q?Post-order fold. The function will be applied from the lowest  value to the highest. R?Pre-order fold. The function will be applied from the highest  value to the lowest. S Map each key/_element pair to an action, evaluate these actions from left to right, and collect the results. T+Map a function over all values in the map. O map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")] U+Map a function over all values in the map. & let f key x = (show key) ++ ":" ++ x Q mapWithKey f (fromList [(5,"a"), (3,"b")]) == fromList [(3, "3:b"), (5, "5:a")] VV 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 F keys to the same new key. In this case the value at the smallest of  these keys is retained. e mapKeys (+ 1) (fromList [(5,"a"), (3,"b")]) == fromList [(4, "b"), (6, "a")] W mapKeys (\ _ -> 1) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 1 "c" W mapKeys (\ _ -> 3) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 3 "c" WW 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 G keys to the same new key. In this case the associated values will be  combined using c. c mapKeysWith (++) (\ _ -> 1) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 1 "cdab" c mapKeysWith (++) (\ _ -> 3) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 3 "cdab" XX f s == V f s, but works only when f  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 s This means that f9 maps distinct original keys to distinct resulting keys. + This function has better performance than V. a mapKeysMonotonic (\ k -> k * 2) (fromList [(5,"a"), (3,"b")]) == fromList [(6, "b"), (10, "a")] YThe expression (Y t1 t2!) takes the left-biased union of t1 and t2.  It prefers t1& when duplicate keys are encountered,  i.e. (Y == Z `). ' The implementation uses the efficient  hedge-union algorithm. * Hedge-union is more efficient on (bigset `Y` smallset). r union (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "a"), (7, "C")] ZO(n+m)I. Union with a combining function. The implementation uses the efficient  hedge-union algorithm. | unionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "aA"), (7, "C")] [\GUnion with a combining function. The implementation uses the efficient  hedge-union algorithm. ]GUnion with a combining function. The implementation uses the efficient  hedge-union algorithm. * Hedge-union is more efficient on (bigset `Y` smallset). a let f key left_value right_value = Just ((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")] ^^ is equivalent to \ ( _ _ -> Nothing). _Intersection of two maps. B Return data in the first map for the keys existing in both maps.  (_ m1 m2 == ` ` m1 m2). a intersection (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "a" `(Intersection with a combining function. k intersectionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "aA" a(Intersection with a combining function. + Intersection is more efficient on (bigset `_` smallset). 4 let f k al ar = (show k) ++ ":" ++ al ++ "|" ++ ar n intersectionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "5:a|A" bb f m1 m2 is equivalent to  { a (` f m1 m2). cc f m1 m2 is equivalent to  { a (a f m1 m2). dDifference of two maps. B Return elements of the first map not existing in the second map. & The implementation uses an efficient hedge algorithm comparable with  hedge-union. _ difference (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 3 "b" eSame as d. f'Difference with a combining function.  When two equal keys are M encountered, the combining function is applied to the values of these keys.  If it returns \7, the element is discarded (proper set difference). If  it returns (^ y+), the element is updated with a new value y. & The implementation uses an efficient hedge algorithm comparable with  hedge-union. E 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" g>Difference with a combining function. When two equal keys are L encountered, the combining function is applied to the key and both values.  If it returns \7, the element is discarded (proper set difference). If  it returns (^ y+), the element is updated with a new value y. & The implementation uses an efficient hedge algorithm comparable with  hedge-union. Z 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" h7Retrieves the value associated with minimal key of the / map, and the map stripped of that element, or \ if passed an  empty map. F minView (fromList [(5,"a"), (3,"b")]) == Just ("b", singleton 5 "a")  minView empty == Nothing i7Retrieves the value associated with maximal key of the / map, and the map stripped of that element, or \ if passed an F maxView (fromList [(5,"a"), (3,"b")]) == Just ("a", singleton 3 "b")  maxView empty == Nothing j"The minimal key of the map. Calls _ if the map is empty. 2 findMin (fromList [(5,"a"), (3,"b")]) == (3,"b") R findMin empty Error: empty map has no minimal element k"The maximal key of the map. Calls _ if the map is empty. 2 findMax (fromList [(5,"a"), (3,"b")]) == (5,"a") R findMax empty Error: empty map has no maximal element lBDelete the minimal key. Returns an empty map if the map is empty. Q deleteMin (fromList [(5,"a"), (3,"b"), (7,"c")]) == fromList [(5,"a"), (7,"c")]  deleteMin empty == empty mBDelete the maximal key. Returns an empty map if the map is empty. Q deleteMax (fromList [(5,"a"), (3,"b"), (7,"c")]) == fromList [(3,"b"), (5,"a")]  deleteMax empty == empty n%Update the value at the minimal key. d updateMin (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "Xb"), (5, "a")] U updateMin (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a" o%Update the value at the maximal key. d updateMax (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "Xa")] U updateMax (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" bp%Update the value at the minimal key. x updateMinWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"3:b"), (5,"a")] j updateMinWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a" q%Update the value at the maximal key. x updateMaxWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"b"), (5,"5:a")] j updateMaxWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" r%Delete and find the minimal element. b deleteFindMin (fromList [(5,"a"), (3,"b"), (10,"c")]) == ((3,"b"), fromList[(5,"a"), (10,"c")]) t deleteFindMin Error: can not return the minimal element of an empty map s%Delete and find the minimal element. b deleteFindMin (fromList [(5,"a"), (3,"b"), (10,"c")]) == ((3,"b"), fromList[(5,"a"), (10,"c")]) t deleteFindMin Error: can not return the minimal element of an empty map t7Retrieves the minimal (key,value) pair of the map, and & the map stripped of that element, or \ if passed an empty map. Q minViewWithKey (fromList [(5,"a"), (3,"b")]) == Just ((3,"b"), singleton 5 "a") ! minViewWithKey empty == Nothing uO(log n)9. Retrieves the maximal (key,value) pair of the map, and & the map stripped of that element, or \ if passed an empty map. Q maxViewWithKey (fromList [(5,"a"), (3,"b")]) == Just ((5,"a"), singleton 3 "b") ! maxViewWithKey empty == Nothing vEReturn all elements of the map in the ascending order of their keys. 2 elems (fromList [(5,"a"), (3,"b")]) == ["b","a"]  elems empty == [] w/Return all keys of the map in ascending order. - keys (fromList [(5,"a"), (3,"b")]) == [3,5]  keys empty == [] xReturn all key//value pairs in the map in ascending key order. < assocs (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]  assocs empty == [] yMap values and separate the c and d results. / let f a = if a < "c" then Left a else Right a = mapEither f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) C == (fromList [(3,"b"), (5,"a")], fromList [(1,"x"), (7,"z")])  L mapEither (\ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) ? == (empty, fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) zMap keys/values and separate the c and d results. < let f k a = if k < 5 then Left (k * 2) else Right (a ++ a) D mapEitherWithKey f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) A == (fromList [(1,2), (3,6)], fromList [(5,"aa"), (7,"zz")])  T mapEitherWithKey (\_ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")]) ? == (empty, fromList [(1,"x"), (3,"b"), (5,"a"), (7,"z")]) {O(n). Map values and collect the ^ results. 6 let f x = if x == "a" then Just "new a" else Nothing A mapMaybe f (fromList [(5,"a"), (3,"b")]) == singleton 5 "new a" |Map keys/values and collect the ^ results. D let f k _ = if k < 5 then Just ("key : " ++ (show k)) else Nothing J mapMaybeWithKey f (fromList [(5,"a"), (3,"b")]) == singleton 3 "key : 3" }6Partition the map according to a predicate. The first F map contains all elements that satisfy the predicate, the second all , elements that fail the predicate. See also . W 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")]) ~6Partition the map according to a predicate. The first F map contains all elements that satisfy the predicate, the second all , elements that fail the predicate. See also . W 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")]) .Filter all values that satisfy the predicate. A filter (> "a") (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" 7 filter (> "x") (fromList [(5,"a"), (3,"b")]) == empty 7 filter (< "a") (fromList [(5,"a"), (3,"b")]) == empty Filter all keys/#values that satisfy the predicate. P filterWithKey (\k _ -> k > 4) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a" 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. O split 2 (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3,"b"), (5,"a")]) C split 3 (fromList [(5,"a"), (3,"b")]) == (empty, singleton 5 "a") M split 4 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a") C split 5 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", empty) O split 6 (fromList [(5,"a"), (3,"b")]) == (fromList [(3,"b"), (5,"a")], empty) The expression ( k map) splits a map just  like  but also returns D k map. ^ splitLookup 2 (fromList [(5,"a"), (3,"b")]) == (empty, Nothing, fromList [(3,"b"), (5,"a")]) S 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") S 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) This function is defined as ( =  (==)). The expression ( f t1 t2 ) returns e if  all keys in t1 are in tree t2 , and when f returns e when A applied to their respective values. For example, the following  expressions are all e:  E isSubmapOfBy (==) (fromList [('a',1)]) (fromList [('a',1),('b',2)]) E isSubmapOfBy (<=) (fromList [('a',1)]) (fromList [('a',1),('b',2)]) M isSubmapOfBy (==) (fromList [('a',1),('b',2)]) (fromList [('a',1),('b',2)]) But the following are all f: E isSubmapOfBy (==) (fromList [('a',2)]) (fromList [('a',1),('b',2)]) E isSubmapOfBy (<) (fromList [('a',1)]) (fromList [('a',1),('b',2)]) E isSubmapOfBy (==) (fromList [('a',1),('b',2)]) (fromList [('a',1)]) Build a map from a list of key/value pairs. See also . K If the list contains more than one value for the same key, the last value  for the key is retained.  fromList [] == empty F fromList [(5,"a"), (3,"b"), (5, "c")] == fromList [(5,"c"), (3,"b")] F fromList [(5,"c"), (3,"b"), (5, "a")] == fromList [(5,"a"), (3,"b")] 3Build a map from an ascending list in linear time.  :The precondition (input list is ascending) is not checked. J fromAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")] J fromAscList [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "b")] Build a map from a list of key/0value pairs with a combining function. See also . e fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "ab"), (5, "aba")]  fromListWith (++) [] == empty \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. T fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "ba")] Build a map from a list of key/0value pairs with a combining function. See also . e fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "ab"), (5, "aba")]  fromListWith (++) [] == empty 3Build a map from an ascending list in linear time.  :The precondition (input list is ascending) is not checked. J fromAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")] J fromAscList [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "b")] HBuild a map from an ascending list of distinct elements in linear time.   The precondition is not checked. I fromDistinctAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")] O(1)%. The number of elements in the map. 3 size empty == 0 3 size (singleton 1 'a') == 1 3 size (fromList([(1,'a'), (2,'c'), (3,'b')])) == 3 )Is the key a member of the map? See also . 0 member 5 (fromList [(5,'a'), (3,'b')]) == True 1 member 1 (fromList [(5,'a'), (3,'b')]) == False -Is the key not a member of the map? See also . 4 notMember 5 (fromList [(5,'a'), (3,'b')]) == False 3 notMember 1 (fromList [(5,'a'), (3,'b')]) == True  The set of all keys of the map. F keysSet (fromList [(5,"a"), (3,"b")]) == Data.TrieSet.fromList [3,5] % keysSet empty == Data.TrieSet.empty O(1)'. The key marking the position of the "hole" in the map.  loc# is the submap with keys less than  loc.  loc& is the submap with keys greater than  loc. 0Search the map for the given key, returning the F corresponding value (if any) and an updatable location for that key.  Properties:    case  k m of  (Nothing, loc) ->  loc == k &&  loc == m  (Just v, loc) ->  loc == k &&  v loc == m  D k m == g ( k m)3Return the value and an updatable location for the  ith key in the map. Calls _ if i is out of range.  Properties:    0 <= i && i <  m ==>  let (v, loc) =  i m in   ( loc) == i &&  v loc == m   i m == let (v, loc) =  i m in ( loc, v)hO(log n)5. Return the value and an updatable location for the  least key in the map, or \ if the map is empty.  Properties:     m > 0 ==>  let Just (v, loc) =  i m in   ( loc) == 0 &&  v loc == m  j m == let Just (v, loc) =  i m in ( loc, v)3Return the value and an updatable location for the  greatest key in the map, or \ if the map is empty.  Properties:     m > 0 ==>  let Just (v, loc) =  i m in   ( loc) == 0 &&  v loc == m  k m == let Just (v, loc) =  i m in ( loc, v)1Return a map obtained by placing the given value 8 at the location (replacing an existing value, if any).  v loc ==  loc Y B ( loc) v Y  loc/Return a map obtained by erasing the location.  loc ==  loc Y  loci Return the index& of a key. 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. O findIndex 2 (fromList [(5,"a"), (3,"b")]) Error: element is not in the map 0 findIndex 3 (fromList [(5,"a"), (3,"b")]) == 0 0 findIndex 5 (fromList [(5,"a"), (3,"b")]) == 1 O findIndex 6 (fromList [(5,"a"), (3,"b")]) Error: element is not in the map  Lookup the index& of a key. The index is a number from  0 up to, but not including, the  of the map. 8 lookupIndex 2 (fromList [(5,"a"), (3,"b")]) == Nothing 7 lookupIndex 3 (fromList [(5,"a"), (3,"b")]) == Just 0 7 lookupIndex 5 (fromList [(5,"a"), (3,"b")]) == Just 1 8 lookupIndex 6 (fromList [(5,"a"), (3,"b")]) == Nothing Retrieve an element by index. Calls _ when an  invalid index is used. 3 elemAt 0 (fromList [(5,"a"), (3,"b")]) == (3,"b") 4 elemAt 1 (fromList [(5,"a"), (3,"b")]) == (5, "a") E elemAt 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range Update the element at index. Calls _ when an  invalid index is used. b updateAt (\ _ _ -> Just "x") 0 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "x"), (5, "a")] b 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 T updateAt (\_ _ -> Nothing) 0 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a" T 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 range Delete the element at index.  Defined as ( i map =  (k x -> \) i map). > deleteAt 0 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a" > deleteAt 1 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b" H deleteAt 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range H deleteAt (-1) (fromList [(5,"a"), (3,"b")]) Error: index out of range `@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~`@FeCDEABHIJKLMNOPGYZ[\]^dfg_`abcTUVWXSQRvwx}~{|yzjklmrsnopqhitu^@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~j"#$%&'()*++,-- . / 012344566789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^8;V_`ab9cde:fghijklDmnop<qrst=?uvwx>\yzNOHIJK{|}~LMPA@BSTUWXY       &     (            !"#$%&'()*+,-./01.20334556789:;<  =>>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~-_;Dqbuy@_;DTULM<      !" # $ $ % & & '()*+,-.-/01234356789: TrieMap-3.0.0Data.TrieMap.RepresentationData.TrieMap.ModifiersData.TrieMap.Class Data.TrieSet Data.TrieMapData.TrieMap.RadixTrie.Slice$Data.TrieMap.Representation.TH.Utils!Data.TrieMap.Representation.Class(Data.TrieMap.Representation.TH.ReprMonad-Data.TrieMap.Representation.TH.Representation)Data.TrieMap.Representation.TH.FactorizedData.TrieMap.Representation.TH+Data.TrieMap.Representation.Instances.BasicData.TrieMap.Utils-Data.TrieMap.Representation.Instances.Vectors*Data.TrieMap.Representation.Instances.Prim-Data.TrieMap.Representation.Instances.Foreign0Data.TrieMap.Representation.Instances.ByteStringData.TrieMap.Sized%Data.TrieMap.Representation.InstancesControl.Monad.EndsData.TrieMap.TrieKeyData.TrieMap.WordMapData.TrieMap.OrdMapData.TrieMap.UnitMapData.TrieMap.ProdMapData.TrieMap.UnionMapData.TrieMap.KeyData.TrieMap.RadixTrie.LabelData.TrieMap.RadixTrie.EdgeData.TrieMap.RadixTrieData.TrieMap.ReverseMapData.TrieMap.Class.Instances toRepListtoRepRepListRepReprunOrdOrdOrderedgetRevRevgetKeyKey genOrdReprgenRepr genOptReprTrieKeyTrieMapTKeyTSetgetTSetTMapgetTMapemptyinsertdelete singletonunionsymmetricDifference difference intersectionfilter partitionsplit splitMembermap mapMonotonicfoldrfoldlfindMinfindMax deleteMin deleteMax deleteFindMin deleteFindMaxminViewmaxViewelemstoList toAscListfromList fromAscListfromDistinctAscListnullsizemember notMember isSubsetOfisProperSubsetOf\\mapSet TLocationlookupfindWithDefault!alter insertWith insertWithKeyinsertLookupWithKeyadjust adjustWithKeyupdate updateWithKey foldrWithKey foldlWithKeytraverseWithKey mapWithKeymapKeys mapKeysWithmapKeysMonotonic unionWith unionWithKeyunionMaybeWithunionMaybeWithKeyintersectionWithintersectionWithKeyintersectionMaybeWithintersectionMaybeWithKeydifferenceWithdifferenceWithKey updateMin updateMaxupdateMinWithKeyupdateMaxWithKeyminViewWithKeymaxViewWithKeykeysassocs mapEithermapEitherWithKeymapMaybemapMaybeWithKeypartitionWithKey filterWithKey splitLookup isSubmapOf isSubmapOfBy fromListWithfromAscListWithfromListWithKeyfromAscListWithKeykeysSetkeybeforeaftersearchindex minLocation maxLocationassignclear findIndex lookupIndexelemAtupdateAtdeleteAt splitSlice takeSlice dropSlice unDropSlice matchSlice iMatchSlice!$AlgCon decompose decompose'compose tyVarBndrVar tyVarBndrTypetyProdtySumfstExpsndExpleftNrightNleftExprightExpfstTysndTyisEnumTyalgCon substInAlgCon substInPred mergeWithbase GHC.ClassesEq==compareDRepList dToRepList ReprMonad runReprMonad Instances liftQuasiinsNubrecurseoutputInstance getInstance mustBreak execReprMonadCaseinputoutputRepresentationreprTypecasesunitRepr vectorizeReprfstReprsndReprprodCase unifyProdCase mapCaseInput mapCaseOutputprodReprsumRepr unifySumRepr unifyProdRepr mapReprInputconify mapReprOutput checkEnumReprordRepr caseToClause outputRepr recursiveReprkeyReprFactored factorType fRestTypefCases FactorCaseFCasefInputfFactorfOutput factorRepr otherRepr factorCase otherCase caseFactor combFCase combFactorfactorsdistinctFactors factorWith factorOutunifydistributeManygetDataForNamegetDataForType mustBreakTy recurseTy genReprMainconReprtypeRepr bootstrapRepr toVectorN toVectorFquoPowremPowcompl.<<..: PackStateLastEndunsafeCastStorablewordSizetoHangingVectori2w packStream boolVecToReppackBoolStream $fReprVector3vector-0.7.0.1Data.Vector.StorableVectorghc-prim GHC.TypesCharGHC.WordWord$fReprVector19Word64$fReprVector25Word16$fReprVector28Word8 $fReprIntInt $fReprWord64 $fReprWord32Word32 $fReprWord16 $fReprWord8 $fReprChar$fReprByteStringbytestring-0.9.1.8Data.ByteString.Lazy.Internal ByteString$fReprByteString0Data.ByteString.InternalElemgetElemAssocgetKgetValueSizedgetSize#getSizeunboxunrollgetLastFirstgetFirstHoleemptyM singletonM getSimpleMsizeM#sizeMlookupMfmapM traverseM mapMaybeM mapEitherMunionMisectMdiffM isSubmapM fromListM fromAscListMfromDistAscListM insertWithM singleHoleMbeforeMafterM beforeWithM afterWithMsearchMCindexMindexM# extractHoleM firstHoleM lastHoleMassignMclearMunifierMOptionnonesomeoptionSimple NonSimple SingletonNullLookup SearchContLEq liftMaybetoMaybeonSndonThird foldl1Empty foldr1Empty fillHoleM mapSearchunifyM insertWithM' mapMaybeM' mapEitherM' mapEitherM''unionM'isectM'diffM'beforeMMafterMMclearM'alterM searchMC'nullM guardNullMsidesbothelemsMmapEitherMaybe unionMaybe isectMaybe diffMaybesubMaybe indexFailNatPrefixMaskSizeRootLeftBinRightBinPathnodeszSNodeNilTipBinNodeWHolesNodeholesearchCassign' branchHolesingletonMaybetraversezeronomatchmatchzeroNmaskshorter branchMaskhighestBitMaskjoinnilbinbin'unifier $fTrieKeyWordWordMap getWordMapgetHolecountnCounttiprebuildisSubmap hedgeUnionfilterGtfilterLttrim trimLookupLoisect hedgeDiff joinMaybe insertMax insertMinmergegluebalancerotateLrotateRsingleLsingleRdoubleLdoubleR$fTrieKeyOrderedsingle $fTrieKey() Data.MaybeMaybegNullbreakFst $fTrieKey(,)UViewHole1Hole2HView&^ singletonL singletonRuViewhViewhole1hole2holesonPair partEithers$fTrieKeyEither Data.EitherEitherkeyMap $fTrieKeyKeylocViewpVieweViewlocdeeprootedge'edgeEdgeLocEdgeLabelBHoleBranchEViewLocLocViewDeepPViewMEdge singletonEdge singleLoc getSimpleEdgedropEdge unDropEdgecompactcEdgeSEdgeXSEdgeSDeepXSDeepSRootSLocVEdgeXVEdgeVDeepXVDeepVRootVLoc lookupEdge searchEdgeCmapEdge mapMaybeEdge mapEitherEdge traverseEdge assignEdge clearEdge unionEdge isectEdgediffEdge isSubEdge beforeEdge afterEdgeextractEdgeLoc indexEdge insertEdgeWordVec$fTrieKeyVector$fTrieKeyVector0 Data.Vector runDualPlusDualPlusrunDualDual $fTrieKeyRevNothingTLocJustGHC.ErrerrorGHC.Baseconstid updateHelperLeftRightGHC.BoolTrueFalse Data.TuplefstextractfillHole