We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9498edf commit 2183a93Copy full SHA for 2183a93
containers/src/Data/Set/Internal.hs
@@ -831,7 +831,8 @@ unions = Foldable.foldl' union empty
831
-- | \(O\bigl(m \log\bigl(\frac{n}{m}+1\bigr)\bigr), \; 0 < m \leq n\). The union of two sets, preferring the first set when
832
-- equal elements are encountered.
833
union :: Ord a => Set a -> Set a -> Set a
834
-union t1 Tip = t1
+union t1 t2 | t1 `ptrEq` t2 = t1
835
+union t1 Tip = t1
836
union t1 (Bin 1 x _ _) = insertR x t1
837
union (Bin 1 x _ _) t2 = insert x t2
838
union Tip t2 = t2
0 commit comments