[avoid a comparison in a busy cost centre
Helmut Grohne <grohne@cs.uni-bonn.de>**20140724100835
 Ignore-this: 835757184c64f43db2e3f44fafa48dbc
 
 mergeWith was first checking <= and if that fails ==, so in many cases it was
 invoking compare twice. By invoking compare directly about 5% runtime can be
 saved on some examples.
 
 Note that this patch changes the semantic of GHeap iff the Eq and Ord instances
 for the key do not agree. While this is normally never the case, indeed for
 RatingData these instances do not agree and thus the tree structure changes.
] hunk ./src/Data/GHeap.hs 80
-mergeWith f a@(Node p1 v1 l1 r1) b@(Node p2 v2 l2 r2)
-    | p1 == p2  = mergeWith f (singleton p1 (v1 `f` v2)) 
-                              (mergeWith f (merge l1 r1)(merge l2 r2))
-    | p1 < p2   = linkWith f a b
-    | otherwise = linkWith f b a
-    
--- | Merging two heaps into one heap, maintainig the heap property    
-link :: (Ord p) => (Heap p v) -> (Heap p v) -> (Heap p v)
+mergeWith f a@(Node p1 v1 l1 r1) b@(Node p2 v2 l2 r2) = case compare p1 p2 of
+    EQ -> mergeWith f (singleton p1 (v1 `f` v2))
+                      (mergeWith f (merge l1 r1) (merge l2 r2))
+    LT -> linkWith f a b
+    GT -> linkWith f b a
+
+-- | Merging two heaps into one heap, maintainig the heap property
+link :: (Ord p) => Heap p v -> Heap p v -> Heap p v