y&H      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFG(c) Edward Kmett 2015 BSD-styleEdward Kmett <ekmett@gmail.com> non-portableNone +<>L=Mutable boxed arrays associated with a primitive state token. Boxed arrayscCreate a new mutable array of the specified size and initialise all elements with the given value./Read a value from the array at the given index..Write a value to the array at the given index.9Read a value from the immutable array at the given index. Monadically read a value from the immutable array at the given index. This allows us to be strict in the array while remaining lazy in the read element which is very useful for collective operations. Suppose we want to copy an array. We could do something like this: copy marr arr ... = do ... writeSmallArray marr i (indexSmallArray arr i) ... ...2But since primitive arrays are lazy, the calls to ! will not be evaluated. Rather, marrG will be filled with thunks each of which would retain a reference to arr&. This is definitely not what we want!With , we can instead write copy marr arr ... = do ... x <- indexSmallArrayM arr i writeSmallArray marr i x ...\Now, indexing is executed immediately although the returned element is still not evaluated. tConvert a mutable array to an immutable one without copying. The array should not be modified after the conversion. {Convert an immutable array to an mutable one without copying. The immutable array should not be used after the conversion. <Check whether the two arrays refer to the same memory block. 6Copy a slice of an immutable array to a mutable array. VCopy a slice of a mutable array to another array. The two arrays may not be the same.Return a newly allocated SmallArray with the specified subrange of the provided SmallArray. The provided SmallArray should contain the full subrange specified by the two Ints, but this is not checked.Return a newly allocated SmallMutableArray. with the specified subrange of the provided SmallMutableArray. The provided SmallMutableArray should contain the full subrange specified by the two Ints, but this is not checked. destination arrayoffset into destination array source arrayoffset into source arraynumber of elements to copy destination arrayoffset into destination array source arrayoffset into source arraynumber of elements to copy source arrayoffset into destination arraynumber of elements to copy source arrayoffset into destination arraynumber of elements to copyHIJKLMNOP   HIJKLMNOP(c) Edward Kmett 2015 BSD-styleEdward Kmett <ekmett@gmail.com> non-portable Trustworthy-./<>ILNVBuild a singleton WordMapQRSTUVWXYZ[\]^_`abcdefQRSTUVWXYZ[\]^_`abcdefSafe@FOptimized and CPS'd version of 5, where all lefts are known to come before all rightsgg Trustworthy!"+14<?@FIKLNU h; equipped with a compatible stable unordered discriminator. For every surjection f, i f   "a   !)Productive Stable Unordered Discriminator$lThis may be useful for pragmatically accelerating a grouping structure by preclassifying by a hash function Semantically, grouping = hashing <> grouping %Valid definition for (j) in terms of .'O(n) . Similar to  2, except we do not require groups to be clustered.QThis combinator still operates in linear time, at the expense of storing history.#The result equivalence classes are not$ sorted, but the grouping is stable. ' = ( k (O(n). This is a replacement for   using discrimination.#The 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 productive unordered discrimination. ) = * k ) as = l  ' as *O(n) . Online ) with a Schwartzian transform. * f as = l  ( f as 2 !"#m$%&'()*nopqrstuvwxyz{|}~ !"#$%&'()*!"# )*'(%&$. !"#m$%&'()*nopqrstuvwxyz{|}~Safe +14<?FIKLNU-: equipped with a compatible stable, ordered discriminator..0For every strictly monotone-increasing function f: i f . "a . /Stable Ordered Discriminator2Valid definition for  in terms of -.4~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.5yConstruct 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.7 O(n)#. Sort a list using discrimination. 7 = 8 k 8O(n)H. Sort a list with a Schwartzian transformation by using discrimination.!This linear time replacement for   and   uses discrimination.9O(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  in linear time.,This is an asymptotically faster version of (, which exploits ordered discrimination.4+,-./0123456789:;<=>?@+,-./0123456789:;<=>?@/01-.+,78629:;<=>?@3450+,-./0123456789:;<=>?@SafeCO(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.DO(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.EO(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.FO(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.GO(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. ABCthe discriminator to usehow to join two tablesselector for the left tableselector for the right table left table right tableDthe discriminator to usehow to join two rowsselector for the left tableselector for the right table left table right tableEthe 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 tableFthe 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 tableGthe 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 tableABCDEFGABCDEFGABCDEFGSafe) !"#%&'()*+,-./012456789:;<=>?@ABCDEFG)AB!"# )*'(&%/01-.+,6784529:;<=>?@CDEFG !"#$%&'()*+,-./01234567889:;<   =>?@ABBCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~yzyzyzdiscr_3CgMbqTsdc393THo18p68c'Data.Discrimination.Internal.SmallArray$Data.Discrimination.Internal.WordMapData.Discrimination.InternalData.Discrimination.GroupingData.Discrimination.SortingData.Discrimination.Class Data.EitherpartitionEithers Data.ListgroupGHC.Exts groupWithnubControl.Applicative<$>sortWithsortOnData.MapfromList fromListWithfromListWithKeyData.IntMap.LazyData.Set Data.IntSetData.DiscriminationSmallMutableArray SmallArray newSmallArrayreadSmallArraywriteSmallArrayindexSmallArrayindexSmallArrayMunsafeFreezeSmallArrayunsafeThawSmallArraysameSmallMutableArraycopySmallArraycopySmallMutableArraycloneSmallArraycloneSmallMutableArrayWordMapinsertlookupmember singletonemptybdiscNatrunsgroupNum updateBag updateSet spanEither Grouping1 grouping1GroupinggroupingGroupgetGrouphashing groupingEqrunGroupnubWithSorting1sorting1SortingsortingSortrunSortsortingCompare sortingNat sortingBag sortingSetdescsorttoMap toMapWith toMapWithKeytoIntMap toIntMapWithtoIntMapWithKeytoSettoIntSetDiscriminatingdiscjoininginnerouter leftOuter rightOuter$fNFDataSmallArray$fEqSmallArray$fOrdSmallArray$fReadSmallArray$fShowSmallArray$fTraversableSmallArray$fFoldableSmallArray$fFunctorSmallArray$fIsListSmallArrayFullNodeTipNilOffsetMaskKeyptrEqptrNeqnodelevelmaskBitmaskforkupdateSmallArrayupdate16insertSmallArrayclone16$fTraversableWordMap$fFoldableWordMap$fFunctorWordMap$fNFDataWordMap fromRightghc-prim GHC.ClassesEqcontr_LxARs66IWzOGQC8CMWQkcDData.Functor.Contravariant contramap==baseGHC.BaseidGHC.ListheadgroupingWord64$fGrouping1Complex$fGrouping1Compose$fGrouping1(,,,)$fGrouping1(,,)$fGrouping1(,)$fGrouping1Either$fGrouping1Maybe $fGrouping1[]$fGroupingCompose$fGroupingRatio$fGroupingComplex$fGroupingEither$fGroupingMaybe $fGrouping[]$fGrouping(,,,)$fGrouping(,,) $fGrouping(,)$fGroupingBool$fGroupingChar $fGroupingInt$fGroupingInt64$fGroupingInt32$fGroupingInt16$fGroupingInt8$fGroupingWord$fGroupingWord64$fGroupingWord32$fGroupingWord16$fGroupingWord8$fGroupingVoid $fMonoidGroup$fSemigroupGroup$fDecidableGroup$fDivisibleGroup$fContravariantGroupOrdcompareconta_LKCPrTJwOTOLk4OU37YmeN Data.Map.BaseMapData.IntMap.BaseIntMap Data.Set.BaseSetData.IntSet.BaseIntSet sortingColl$fSorting1Either$fSorting1Maybe $fSorting1[]$fSorting1Compose$fSortingCompose$fSorting(,,,) $fSorting(,,) $fSorting(,)$fSortingEither$fSortingMaybe $fSorting[] $fSortingBool $fSortingVoid $fSortingChar $fSortingInt$fSortingInt64$fSortingInt32$fSortingInt16 $fSortingInt8 $fSortingWord$fSortingWord64$fSortingWord32$fSortingWord16$fSortingWord8 $fMonoidSort$fSemigroupSort$fDecidableSort$fDivisibleSort$fContravariantSort$fDiscriminatingGroup$fDiscriminatingSort