-- Insert an element to the set only if it is not in the set.
-- Used by `union`.

-- See Note: Type of local 'go' function
insertR :: Ord a => a -> Set a -> Set a
insertR = go
  where
    go :: Ord a => a -> Set a -> Set a
    STRICT_1_OF_2(go)
    go x Tip = singleton x
    go x t@(Bin _ y l r) = case compare x y of
        LT -> balanceL y (go x l) r
        GT -> balanceR y l (go x r)
        EQ -> t
#if __GLASGOW_HASKELL__ >= 700

insertR :: Ord a => a -> Set a -> Set a
insertR = go
  where
    go :: Ord a => a -> Set a -> Set a
    STRICT_1_OF_2(go)
    go x Tip = singleton x
    go x t@(Bin _ y l r) = case compare x y of
        LT -> balanceL y (go x l) r
        GT -> balanceR y l (go x r)
        EQ -> t
#if __GLASGOW_HASKELL__ >= 700

insertR = go
  where
    go :: Ord a => a -> Set a -> Set a
    STRICT_1_OF_2(go)
    go x Tip = singleton x
    go x t@(Bin _ y l r) = case compare x y of
        LT -> balanceL y (go x l) r
        GT -> balanceR y l (go x r)
        EQ -> t
#if __GLASGOW_HASKELL__ >= 700
