@@ -250,6 +250,7 @@ import qualified Data.Foldable as Foldable
250
250
import Control.DeepSeq (NFData (rnf ))
251
251
252
252
import Utils.Containers.Internal.StrictPair
253
+ import Utils.Containers.Internal.StrictTriple
253
254
import Utils.Containers.Internal.PtrEquality
254
255
255
256
#if __GLASGOW_HASKELL__
@@ -1318,16 +1319,20 @@ splitS x (Bin _ y l r)
1318
1319
-- | \(O(\log n)\). Performs a 'split' but also returns whether the pivot
1319
1320
-- element was found in the original set.
1320
1321
splitMember :: Ord a => a -> Set a -> (Set a ,Bool ,Set a )
1321
- splitMember _ Tip = (Tip , False , Tip )
1322
- splitMember x (Bin _ y l r)
1323
- = case compare x y of
1324
- LT -> let (lt, found, gt) = splitMember x l
1325
- ! gt' = link y gt r
1326
- in (lt, found, gt')
1327
- GT -> let (lt, found, gt) = splitMember x r
1328
- ! lt' = link y l lt
1329
- in (lt', found, gt)
1330
- EQ -> (l, True , r)
1322
+ splitMember k0 s = case go k0 s of
1323
+ StrictTriple l b r -> (l, b, r)
1324
+ where
1325
+ go :: Ord a => a -> Set a -> StrictTriple (Set a ) Bool (Set a )
1326
+ go _ Tip = StrictTriple Tip False Tip
1327
+ go x (Bin _ y l r)
1328
+ = case compare x y of
1329
+ LT -> let StrictTriple lt found gt = go x l
1330
+ ! gt' = link y gt r
1331
+ in StrictTriple lt found gt'
1332
+ GT -> let StrictTriple lt found gt = go x r
1333
+ ! lt' = link y l lt
1334
+ in StrictTriple lt' found gt
1335
+ EQ -> StrictTriple l True r
1331
1336
#if __GLASGOW_HASKELL__
1332
1337
{-# INLINABLE splitMember #-}
1333
1338
#endif
0 commit comments