Îõ³h${Á      !"#$%&'()*+,-./0123456789:;<=>?@(c) Edward Kmett 2010-2015 BSD-styleekmett@gmail.com experimentalportable Safe-Inferred3Ê·%heapsÌExplicit priority/payload tuples. Useful to build a priority queue using a 7, since the payload is ignored in the Eq/Ord instances.  myHeap =  [ 2 "World",  1 "Hello",  3 "!"] ==> A  myHeap áD "HelloWorld!" heapsA min-heap of values of type a.heapsO(1). The empty heap  áD  [] size empty0heapsO(1). A heap with a single element  x áD  [x]  x áD  x  size (singleton "hello")1heapsO(1)#. Insert a new value into the heap.insert 2 (fromList [1,3])fromList [1,2,3]  x  áD  x  ( x xs) áD 1 +  xs heapsO(1)/. Meld the values from two heaps into one heap.+union (fromList [1,3,5]) (fromList [6,4,2])fromList [1,2,6,4,3,5]+union (fromList [1,1,1]) (fromList [1,2,1])fromList [1,1,1,2,1,1] heapsO(log n)À. Create a heap consisting of multiple copies of the same value.replicate 'a' 10fromList "aaaaaaaaaa" heapsProvides both O(1)# access to the minimum element and O(log n)Å access to the remainder of the heap. This is the same operation as  uncons (fromList [2,1,3])Just (1,fromList [2,3]) heapsSame as  heapsO(1) . Assumes the argument is a non- heap.minimum (fromList [3,1,2])1 heapsO(log n)Å. Delete the minimum key from the heap and return the resulting heap.deleteMin (fromList [3,1,2])fromList [2,3]heapsO(log n)Ã. Adjust the minimum key in the heap and return the resulting heap.!adjustMin (+1) (fromList [1,2,3])fromList [2,2,3]heapsO(n)%. Build a heap from a list of values.  B toList áD C toList B  áD  heaps O(n log n). Perform a heap sortheapsO(n)Ò. Returns the elements in the heap in some arbitrary, very likely unsorted, order.!toUnsortedList (fromList [3,1,2])[1,3,2]  B  áD CheapsO(1). Is the heap empty? null emptyTruenull (singleton "hello")FalseheapsO(1)%. The number of elements in the heap. size empty0size (singleton "hello")1size (fromList [4,1,2])3heapsO(n)á. Map a function over the heap, returning a new heap ordered appropriately for its fresh contentsmap negate (fromList [3,1,2])fromList [-3,-1,-2]heapsO(n)ì. Map a monotone increasing function over the heap. Provides a better constant factor for performance than ˜, but no checking is performed that the function provided is monotone increasing. Misuse of this function can cause a Heap to violate the heap property.$mapMonotonic (+1) (fromList [1,2,3])fromList [2,3,4]$mapMonotonic (*2) (fromList [1,2,3])fromList [2,4,6]heapsO(n)Ä. Filter the heap, retaining only values that satisfy the predicate.filter (>'a') (fromList "ab") fromList "b"filter (>'x') (fromList "ab") fromList []filter (<'a') (fromList "ab") fromList []heapsO(n)ª. Partition the heap according to a predicate. The first heap contains all elements that satisfy the predicate, the second all elements that fail the predicate. See also . partition (>'a') (fromList "ab")(fromList "b",fromList "a")heapsO(n)í. Partition the heap into heaps of the elements that are less than, equal to, and greater than a given value.split 'h' (fromList "hello")*(fromList "e",fromList "h",fromList "llo")heaps O(n log n)(. Return a heap consisting of the least n elements of a given heap."take 3 (fromList [10,2,4,1,9,8,2])fromList [1,2,2]heaps O(n log n)Ç. Return a heap consisting of all members of given heap except for the n least elements.heaps O(n log n)8. Split a heap into two heaps, the first containing the nÜ least elements, the latter consisting of all members of the heap except for those elements.heaps O(n log n).  applied to a predicate p and a heap xsë returns a tuple where the first element is a heap consisting of the longest prefix the least elements of xs that do not satisfyÇ p and the second element is the remainder of the elements in the heap.8break (\x -> x `mod` 4 == 0) (fromList [3,5,7,12,13,16])&(fromList [3,5,7],fromList [12,13,16]) p is equivalent to  (D . p).heaps O(n log n).  applied to a predicate p and a heap xsû returns a tuple where the first element is a heap consisting of the longest prefix the least elements of xs that satisfy pÅ and the second element is the remainder of the elements in the heap.5span (\x -> x `mod` 4 == 0) (fromList [4,8,12,14,16])$(fromList [4,8,12],fromList [14,16]) p xs is equivalent to ( p xs,  p xs)heaps O(n log n).  applied to a predicate p and a heap xsÈ returns a heap consisting of the longest prefix the least elements of xs that satisfy p.:takeWhile (\x -> x `mod` 4 == 0) (fromList [4,8,12,14,16])fromList [4,8,12]heaps O(n log n).  p xs0 returns the suffix of the heap remaining after  p xs.:dropWhile (\x -> x `mod` 4 == 0) (fromList [4,8,12,14,16])fromList [14,16] heaps O(n log n)). Remove duplicate entries from the heap.nub (fromList [1,1,2,6,6])fromList [1,2,6]!heapsO(n)Í. Construct heaps from each element in another heap, and union them together.3concatMap (\a -> fromList [a,a+1]) (fromList [1,4])fromList [1,4,5,2]"heaps O(n log n)Å. Group a heap into a heap of heaps, by unioning together duplicates.group (fromList "hello")?fromList [fromList "e",fromList "h",fromList "ll",fromList "o"]#heaps O(n log n)'. Group using a user supplied function.$heapsO(n log n + m log m)à. Intersect the values in two heaps, returning the value in the left heap that compares as equal%heapsO(n log n + m log m)à. Intersect the values in two heaps using a function to generate the elements in the right heap.&heaps O(n log n)Ñ. Traverse the elements of the heap in sorted order and produce a new heap using E side-effects.'heaps O(n log n)Ñ. Traverse the elements of the heap in sorted order and produce a new heap using Fic side-effects.(  !"#$%&'(  &'!"# $% G5È      !"#$%&'()*+,-./0123456789:;<=>?@ABCDBEFBEGHIJBEKBELMÎ heaps-0.4-50MzWopeGAz8Qgc4olzEfa Data.HeapEntryprioritypayloadHeapempty singletoninsertunion replicateunconsviewMinminimum deleteMin adjustMinfromListsorttoUnsortedListnullsizemap mapMonotonicfilter partitionsplittakedropsplitAtbreakspan takeWhile dropWhilenub concatMapgroupgroupBy intersect intersectWithtraversemapM$fFoldableForest$fFoldableTree$fFunctorForest $fFunctorTree$fFoldableHeap $fMonoidHeap$fSemigroupHeap $fOrdHeap$fEqHeap $fDataHeap $fReadHeap $fShowHeap $fOrdEntry $fEqEntry$fTraversableEntry$fFoldableEntry$fBifunctorEntry$fFunctorEntry $fReadEntry $fShowEntry $fDataEntry $fShowForest $fReadForest $fShowTree $fReadTreebase Data.FoldablefoldMapGHC.Base.idghc-prim GHC.Classesnot ApplicativeMonadCons