|vD3      !"#$%&'()*+,-./012 Safe-Inferred?EOptimized and CPS'd version of 5, where all lefts are known to come before all rights33 Trustworthy!"+13;>?EHJKMT 4; equipped with a compatible stable unordered discriminator. For every surjection f, 5 f   "a    Discriminator 2Perform stable unordered discrimination by bucket.This reuses arrays unlike the more obvious ST implementation, so it wins by a huge margin in a race, especially when we have a large keyspace, sparsely used, with low contention. This will leak a number of arrays equal to the maximum concurrent contention for this resource. If this becomes a bottleneck we can make multiple stacks of working pads and index the stack with the hash of the current thread id to reduce contention at the expense of taking more memory.<You should create a thunk that holds the discriminator from  groupingNat n for a known n and then reuse it.$Shared bucket set for small integersValid definition for (6) in terms of .O(n) . Similar to 2, except we do not require groups to be clustered.NThis combinator still operates in linear time, at the expense of productivity.LThe result equivalence classes are _not_ sorted, but the grouping is stable.  =  7 O(n). This is a replacement for   using discrimination.LThe result equivalence classes are _not_ sorted, but the grouping is stable.O(n). This upgrades   from  Data.List from O(n^2) to O(n)$ by using unordered discrimination.  =  7  as = 8    as O(n).  with a Schwartzian transform.  f as = 8    f as Construct an stable unordered discriminator that partitions into equivalence classes based on the equivalence of keys as a multiset.Construct an stable unordered discriminator that partitions into equivalence classes based on the equivalence of keys as a set.3 9 :;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[    /  9 :;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[ Trustworthy +13;>EHJKMT\: equipped with a compatible stable, ordered discriminator.0For every strictly monotone-increasing function f: 5 f  "a  Stable Ordered DiscriminatorValid definition for ] in terms of .~Construct a stable ordered discriminator that sorts a list as multisets of elements from another stable ordered discriminator.The resulting discriminator only cares about the set of keys and their multiplicity, and is sorted as if we'd sorted each key in turn before comparing. yConstruct a stable ordered discriminator that sorts a list as sets of elements from another stable ordered discriminator.The resulting discriminator only cares about the set of keys, and is sorted as if we'd sorted each key in turn before comparing." O(n)#. Sort a list using discrimination. " = # 7 #O(n)I. Sort a list with a Schwartzian transformation by using discrimination. !This linear time replacement for   and  uses discrimination.$O(n). Construct a ^.,This is an asymptotically faster version of (, which exploits ordered discrimination.toMap [] == emptyTrue)toMap [(5,"a"), (3 :: Int,"b"), (5, "c")]fromList [(5,"c"), (3,"b")])toMap [(5,"c"), (3,"b"), (5 :: Int, "a")]fromList [(5,"a"), (3,"b")]%O(n). Construct a ^, combining values.,This is an asymptotically faster version of (, which exploits ordered discrimination.B(Note: values combine in anti-stable order for compatibility with )CtoMapWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5 :: Int,"c")] fromList [(3, "ab"), (5, "cba")]toMapWith (++) [] == emptyTrue&O(n). Construct a ^*, combining values with access to the key.,This is an asymptotically faster version of (, which exploits ordered discrimination.F(Note: the values combine in anti-stable order for compatibility with )Plet f key new_value old_value = show key ++ ":" ++ new_value ++ "|" ++ old_valueCtoMapWithKey f [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5 :: Int,"c")])fromList [(3, "3:a|b"), (5, "5:c|5:b|a")]toMapWithKey f [] == emptyTrue'O(n). Construct an _.toIntMap [] == emptyTrue%toIntMap [(5,"a"), (3,"b"), (5, "c")]fromList [(5,"c"), (3,"b")]%toIntMap [(5,"c"), (3,"b"), (5, "a")]fromList [(5,"a"), (3,"b")](O(n). Construct an _, combining values.,This is an asymptotically faster version of (, which exploits ordered discrimination.B(Note: values combine in anti-stable order for compatibility with )?toIntMapWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"c")] fromList [(3, "ab"), (5, "cba")]toIntMapWith (++) [] == emptyTrue)O(n). Construct a ^*, combining values with access to the key.,This is an asymptotically faster version of (, which exploits ordered discrimination.F(Note: the values combine in anti-stable order for compatibility with )Plet f key new_value old_value = show key ++ ":" ++ new_value ++ "|" ++ old_value?toIntMapWithKey f [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"c")])fromList [(3, "3:a|b"), (5, "5:c|5:b|a")]toIntMapWithKey f [] == emptyTrue*O(n). Construct a ` in linear time.,This is an asymptotically faster version of (, which exploits ordered discrimination.+O(n). Construct an a in linear time.,This is an asymptotically faster version of (, which exploits ordered discrimination.2 b!"#$%&'()*+cdefghijklmnopqrstuvwxyz{|} !"#$%&'()*+"#!$%&'()*+ . b!"#$%&'()*+cdefghijklmnopqrstuvwxyz{|} Safe-Inferred.O(n)^. Perform a full outer join while explicit merging of the two result tables a table at a time.-The results are grouped by the discriminator./O(n)C. Perform an inner join, with operations defined one row at a time.-The results are grouped by the discriminator.CThis takes operation time linear in both the input and result sets.0O(n)F. Perform a full outer join with operations defined one row at a time.-The results are grouped by the discriminator.CThis takes operation time linear in both the input and result sets.1O(n)F. Perform a left outer join with operations defined one row at a time.-The results are grouped by the discriminator.CThis takes operation time linear in both the input and result sets.2O(n)G. Perform a right outer join with operations defined one row at a time.-The results are grouped by the discriminator.CThis takes operation time linear in both the input and result sets. ,-.the discriminator to usehow to join two tablesselector for the left tableselector for the right table left table right table/the discriminator to usehow to join two rowsselector for the left tableselector for the right table left table right table0the discriminator to usehow to join two rows-row present on the left, missing on the right-row present on the right, missing on the leftselector for the left tableselector for the right table left table right table1the discriminator to usehow to join two rows-row present on the left, missing on the rightselector for the left tableselector for the right table left table right table2the discriminator to usehow to join two rows-row present on the right, missing on the leftselector for the left tableselector for the right table left table right table~,-./012,-./012,-./012~ Safe-Inferred*  !"#$%&'()*+,-./012*,-  !"# $%&'()*+./012 !""#$%&  '()*+,-../0123456789:;<=>?@ABCDEFGHIJKFGLMNOMPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstFGuFGvwxywz{w|}w~discrimination-0Data.Discrimination.InternalData.Discrimination.GroupingData.Discrimination.SortingData.Discrimination.Class Data.EitherpartitionEithers Data.ListgroupGHC.Exts groupWithnubControl.Applicative<$>sortWithsortOnData.MapfromList fromListWithfromListWithKeyData.IntMap.LazyData.Set Data.IntSetData.DiscriminationbdiscNatrunsgroupNum updateBag updateSet spanEither Grouping1 grouping1GroupinggroupingGrouprunGroup groupingNat groupingShort groupingEqnubWith groupingBag groupingSetSorting1sorting1SortingsortingSortrunSortsortingCompare sortingNat sortingBag sortingSetdescsorttoMap toMapWith toMapWithKeytoIntMap toIntMapWithtoIntMapWithKeytoSettoIntSetDiscriminatingdiscjoininginnerouter leftOuter rightOuter fromRightghc-prim GHC.ClassesEqcontravariant-1.3.1.1Data.Functor.Contravariant contramap==baseGHC.BaseidGHC.Listheadmix groupingColl$fGrouping1Complex$fGrouping1Compose$fGrouping1(,,,)$fGrouping1(,,)$fGrouping1(,)$fGrouping1Either$fGrouping1Maybe $fGrouping1[]$fGroupingCompose$fGroupingRatio$fGroupingComplex$fGroupingEither$fGroupingMaybe $fGrouping[]$fGrouping(,,,)$fGrouping(,,) $fGrouping(,)$fGroupingBool $fGroupingInt$fGroupingInt64$fGroupingInt32$fGroupingInt16$fGroupingInt8$fGroupingWord$fGroupingWord64$fGroupingWord32$fGroupingWord16$fGroupingWord8$fGroupingVoid $fMonoidGroup$fDecidableGroup$fDivisibleGroup$fContravariantGroupOrdcomparecontainers-0.5.6.3 Data.Map.BaseMapData.IntMap.BaseIntMap Data.Set.BaseSetData.IntSet.BaseIntSet sortingColl$fSorting1Either$fSorting1Maybe $fSorting1[]$fSorting1Compose$fSortingCompose$fSorting(,,,) $fSorting(,,) $fSorting(,)$fSortingEither$fSortingMaybe $fSorting[] $fSortingBool $fSortingVoid $fSortingInt$fSortingInt64$fSortingInt32$fSortingInt16 $fSortingInt8 $fSortingWord$fSortingWord64$fSortingWord32$fSortingWord16$fSortingWord8 $fMonoidSort$fDecidableSort$fDivisibleSort$fContravariantSort$fDiscriminatingGroup$fDiscriminatingSort