    {-# LANGUAGE CPP #-}
    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE DeriveFoldable #-}
    {-# LANGUAGE GeneralizedNewtypeDeriving #-}
    {-# LANGUAGE ScopedTypeVariables #-}
    {-# LANGUAGE TypeApplications #-}

    -----------------------------------------------------------------------------

    -- |

    -- Module      :  Language.Haskell.TH.Desugar.OSet

    -- Copyright   :  (C) 2016-2018 Daniel Wagner, 2019 Ryan Scott

    -- License     :  BSD-style (see LICENSE)

    -- Maintainer  :  Ryan Scott

    -- Stability   :  experimental

    -- Portability :  non-portable

    --

    -- An 'OSet' behaves much like a 'S.Set', with all the same asymptotics, but

    -- also remembers the order that values were inserted.

    --

    -- This module offers a simplified version of the "Data.Set.Ordered" API

    -- that assumes left-biased indices everywhere.

    --

    ----------------------------------------------------------------------------

    module Language.Haskell.TH.Desugar.OSet
        ( OSet
        -- * Trivial sets

        , empty, singleton
        -- * Insertion

        , insertPre, insertPost, union
        -- * Query

        , null, size, member, notMember
        -- * Deletion

        , delete, filter, (\\), intersection
        -- * Indexing

        , Index, lookupIndex, lookupAt
        -- * List conversions

        , fromList, toAscList
        -- * 'Set' conversion

        , toSet
        ) where

    import Data.Coerce
    import Data.Data
    import qualified Data.Set as S (Set)
    import Data.Set.Ordered (Bias(..), Index, L)
    import qualified Data.Set.Ordered as OS
    import Language.Haskell.TH.Desugar.OMap ()
    import Prelude hiding (filter, null)

    #if !(MIN_VERSION_base(4,11,0))
    import Data.Semigroup (Semigroup(..))
    #endif

    -- | An ordered set whose 'insertPre', 'insertPost', 'intersection', and 'union'

    -- operations are biased towards leftmost indices when when breaking ties

    -- between keys.

    newtype OSet a = OSet (Bias L (OS.OSet a))
      deriving (Typeable (OSet a)
    Typeable (OSet a) =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> OSet a -> c (OSet a))
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c (OSet a))
    -> (OSet a -> Constr)
    -> (OSet a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c (OSet a)))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (OSet a)))
    -> ((forall b. Data b => b -> b) -> OSet a -> OSet a)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> OSet a -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> OSet a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> OSet a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> OSet a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> OSet a -> m (OSet a))
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> OSet a -> m (OSet a))
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> OSet a -> m (OSet a))
    -> Data (OSet a)
    OSet a -> Constr
    OSet a -> DataType
    (forall b. Data b => b -> b) -> OSet a -> OSet a
    forall a. (Data a, Ord a) => Typeable (OSet a)
    forall a. (Data a, Ord a) => OSet a -> Constr
    forall a. (Data a, Ord a) => OSet a -> DataType
    forall a.
    (Data a, Ord a) =>
    (forall b. Data b => b -> b) -> OSet a -> OSet a
    forall a u.
    (Data a, Ord a) =>
    Int -> (forall d. Data d => d -> u) -> OSet a -> u
    forall a u.
    (Data a, Ord a) =>
    (forall d. Data d => d -> u) -> OSet a -> [u]
    forall a r r'.
    (Data a, Ord a) =>
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OSet a -> r
    forall a r r'.
    (Data a, Ord a) =>
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OSet a -> r
    forall a (m :: * -> *).
    (Data a, Ord a, Monad m) =>
    (forall d. Data d => d -> m d) -> OSet a -> m (OSet a)
    forall a (m :: * -> *).
    (Data a, Ord a, MonadPlus m) =>
    (forall d. Data d => d -> m d) -> OSet a -> m (OSet a)
    forall a (c :: * -> *).
    (Data a, Ord a) =>
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (OSet a)
    forall a (c :: * -> *).
    (Data a, Ord a) =>
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> OSet a -> c (OSet a)
    forall a (t :: * -> *) (c :: * -> *).
    (Data a, Ord a, Typeable t) =>
    (forall d. Data d => c (t d)) -> Maybe (c (OSet a))
    forall a (t :: * -> * -> *) (c :: * -> *).
    (Data a, Ord a, Typeable t) =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (OSet a))
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> OSet a -> u
    forall u. (forall d. Data d => d -> u) -> OSet a -> [u]
    forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OSet a -> r
    forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OSet a -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> OSet a -> m (OSet a)
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OSet a -> m (OSet a)
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (OSet a)
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> OSet a -> c (OSet a)
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (OSet a))
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (OSet a))
    $cgfoldl :: forall a (c :: * -> *).
    (Data a, Ord a) =>
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> OSet a -> c (OSet a)
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> OSet a -> c (OSet a)
    $cgunfold :: forall a (c :: * -> *).
    (Data a, Ord a) =>
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (OSet a)
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (OSet a)
    $ctoConstr :: forall a. (Data a, Ord a) => OSet a -> Constr
    toConstr :: OSet a -> Constr
    $cdataTypeOf :: forall a. (Data a, Ord a) => OSet a -> DataType
    dataTypeOf :: OSet a -> DataType
    $cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
    (Data a, Ord a, Typeable t) =>
    (forall d. Data d => c (t d)) -> Maybe (c (OSet a))
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (OSet a))
    $cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
    (Data a, Ord a, Typeable t) =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (OSet a))
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (OSet a))
    $cgmapT :: forall a.
    (Data a, Ord a) =>
    (forall b. Data b => b -> b) -> OSet a -> OSet a
    gmapT :: (forall b. Data b => b -> b) -> OSet a -> OSet a
    $cgmapQl :: forall a r r'.
    (Data a, Ord a) =>
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OSet a -> r
    gmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OSet a -> r
    $cgmapQr :: forall a r r'.
    (Data a, Ord a) =>
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OSet a -> r
    gmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OSet a -> r
    $cgmapQ :: forall a u.
    (Data a, Ord a) =>
    (forall d. Data d => d -> u) -> OSet a -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> OSet a -> [u]
    $cgmapQi :: forall a u.
    (Data a, Ord a) =>
    Int -> (forall d. Data d => d -> u) -> OSet a -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> OSet a -> u
    $cgmapM :: forall a (m :: * -> *).
    (Data a, Ord a, Monad m) =>
    (forall d. Data d => d -> m d) -> OSet a -> m (OSet a)
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> OSet a -> m (OSet a)
    $cgmapMp :: forall a (m :: * -> *).
    (Data a, Ord a, MonadPlus m) =>
    (forall d. Data d => d -> m d) -> OSet a -> m (OSet a)
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OSet a -> m (OSet a)
    $cgmapMo :: forall a (m :: * -> *).
    (Data a, Ord a, MonadPlus m) =>
    (forall d. Data d => d -> m d) -> OSet a -> m (OSet a)
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OSet a -> m (OSet a)
    Data, (forall m. Monoid m => OSet m -> m)
    -> (forall m a. Monoid m => (a -> m) -> OSet a -> m)
    -> (forall m a. Monoid m => (a -> m) -> OSet a -> m)
    -> (forall a b. (a -> b -> b) -> b -> OSet a -> b)
    -> (forall a b. (a -> b -> b) -> b -> OSet a -> b)
    -> (forall b a. (b -> a -> b) -> b -> OSet a -> b)
    -> (forall b a. (b -> a -> b) -> b -> OSet a -> b)
    -> (forall a. (a -> a -> a) -> OSet a -> a)
    -> (forall a. (a -> a -> a) -> OSet a -> a)
    -> (forall a. OSet a -> [a])
    -> (forall a. OSet a -> Bool)
    -> (forall a. OSet a -> Int)
    -> (forall a. Eq a => a -> OSet a -> Bool)
    -> (forall a. Ord a => OSet a -> a)
    -> (forall a. Ord a => OSet a -> a)
    -> (forall a. Num a => OSet a -> a)
    -> (forall a. Num a => OSet a -> a)
    -> Foldable OSet
    forall a. Eq a => a -> OSet a -> Bool
    forall a. Num a => OSet a -> a
    forall a. Ord a => OSet a -> a
    forall m. Monoid m => OSet m -> m
    forall a. OSet a -> Bool
    forall a. OSet a -> Int
    forall a. OSet a -> [a]
    forall a. (a -> a -> a) -> OSet a -> a
    forall m a. Monoid m => (a -> m) -> OSet a -> m
    forall b a. (b -> a -> b) -> b -> OSet a -> b
    forall a b. (a -> b -> b) -> b -> OSet a -> b
    forall (t :: * -> *).
    (forall m. Monoid m => t m -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. t a -> [a])
    -> (forall a. t a -> Bool)
    -> (forall a. t a -> Int)
    -> (forall a. Eq a => a -> t a -> Bool)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> Foldable t
    $cfold :: forall m. Monoid m => OSet m -> m
    fold :: forall m. Monoid m => OSet m -> m
    $cfoldMap :: forall m a. Monoid m => (a -> m) -> OSet a -> m
    foldMap :: forall m a. Monoid m => (a -> m) -> OSet a -> m
    $cfoldMap' :: forall m a. Monoid m => (a -> m) -> OSet a -> m
    foldMap' :: forall m a. Monoid m => (a -> m) -> OSet a -> m
    $cfoldr :: forall a b. (a -> b -> b) -> b -> OSet a -> b
    foldr :: forall a b. (a -> b -> b) -> b -> OSet a -> b
    $cfoldr' :: forall a b. (a -> b -> b) -> b -> OSet a -> b
    foldr' :: forall a b. (a -> b -> b) -> b -> OSet a -> b
    $cfoldl :: forall b a. (b -> a -> b) -> b -> OSet a -> b
    foldl :: forall b a. (b -> a -> b) -> b -> OSet a -> b
    $cfoldl' :: forall b a. (b -> a -> b) -> b -> OSet a -> b
    foldl' :: forall b a. (b -> a -> b) -> b -> OSet a -> b
    $cfoldr1 :: forall a. (a -> a -> a) -> OSet a -> a
    foldr1 :: forall a. (a -> a -> a) -> OSet a -> a
    $cfoldl1 :: forall a. (a -> a -> a) -> OSet a -> a
    foldl1 :: forall a. (a -> a -> a) -> OSet a -> a
    $ctoList :: forall a. OSet a -> [a]
    toList :: forall a. OSet a -> [a]
    $cnull :: forall a. OSet a -> Bool
    null :: forall a. OSet a -> Bool
    $clength :: forall a. OSet a -> Int
    length :: forall a. OSet a -> Int
    $celem :: forall a. Eq a => a -> OSet a -> Bool
    elem :: forall a. Eq a => a -> OSet a -> Bool
    $cmaximum :: forall a. Ord a => OSet a -> a
    maximum :: forall a. Ord a => OSet a -> a
    $cminimum :: forall a. Ord a => OSet a -> a
    minimum :: forall a. Ord a => OSet a -> a
    $csum :: forall a. Num a => OSet a -> a
    sum :: forall a. Num a => OSet a -> a
    $cproduct :: forall a. Num a => OSet a -> a
    product :: forall a. Num a => OSet a -> a
    Foldable, OSet a -> OSet a -> Bool
    (OSet a -> OSet a -> Bool)
    -> (OSet a -> OSet a -> Bool) -> Eq (OSet a)
    forall a. Eq a => OSet a -> OSet a -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: forall a. Eq a => OSet a -> OSet a -> Bool
    == :: OSet a -> OSet a -> Bool
    $c/= :: forall a. Eq a => OSet a -> OSet a -> Bool
    /= :: OSet a -> OSet a -> Bool
    Eq, Semigroup (OSet a)
    OSet a
    Semigroup (OSet a) =>
    OSet a
    -> (OSet a -> OSet a -> OSet a)
    -> ([OSet a] -> OSet a)
    -> Monoid (OSet a)
    [OSet a] -> OSet a
    OSet a -> OSet a -> OSet a
    forall a. Ord a => Semigroup (OSet a)
    forall a. Ord a => OSet a
    forall a. Ord a => [OSet a] -> OSet a
    forall a. Ord a => OSet a -> OSet a -> OSet a
    forall a.
    Semigroup a =>
    a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
    $cmempty :: forall a. Ord a => OSet a
    mempty :: OSet a
    $cmappend :: forall a. Ord a => OSet a -> OSet a -> OSet a
    mappend :: OSet a -> OSet a -> OSet a
    $cmconcat :: forall a. Ord a => [OSet a] -> OSet a
    mconcat :: [OSet a] -> OSet a
    Monoid, Eq (OSet a)
    Eq (OSet a) =>
    (OSet a -> OSet a -> Ordering)
    -> (OSet a -> OSet a -> Bool)
    -> (OSet a -> OSet a -> Bool)
    -> (OSet a -> OSet a -> Bool)
    -> (OSet a -> OSet a -> Bool)
    -> (OSet a -> OSet a -> OSet a)
    -> (OSet a -> OSet a -> OSet a)
    -> Ord (OSet a)
    OSet a -> OSet a -> Bool
    OSet a -> OSet a -> Ordering
    OSet a -> OSet a -> OSet a
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    forall a. Ord a => Eq (OSet a)
    forall a. Ord a => OSet a -> OSet a -> Bool
    forall a. Ord a => OSet a -> OSet a -> Ordering
    forall a. Ord a => OSet a -> OSet a -> OSet a
    $ccompare :: forall a. Ord a => OSet a -> OSet a -> Ordering
    compare :: OSet a -> OSet a -> Ordering
    $c< :: forall a. Ord a => OSet a -> OSet a -> Bool
    < :: OSet a -> OSet a -> Bool
    $c<= :: forall a. Ord a => OSet a -> OSet a -> Bool
    <= :: OSet a -> OSet a -> Bool
    $c> :: forall a. Ord a => OSet a -> OSet a -> Bool
    > :: OSet a -> OSet a -> Bool
    $c>= :: forall a. Ord a => OSet a -> OSet a -> Bool
    >= :: OSet a -> OSet a -> Bool
    $cmax :: forall a. Ord a => OSet a -> OSet a -> OSet a
    max :: OSet a -> OSet a -> OSet a
    $cmin :: forall a. Ord a => OSet a -> OSet a -> OSet a
    min :: OSet a -> OSet a -> OSet a
    Ord, ReadPrec [OSet a]
    ReadPrec (OSet a)
    Int -> ReadS (OSet a)
    ReadS [OSet a]
    (Int -> ReadS (OSet a))
    -> ReadS [OSet a]
    -> ReadPrec (OSet a)
    -> ReadPrec [OSet a]
    -> Read (OSet a)
    forall a. (Ord a, Read a) => ReadPrec [OSet a]
    forall a. (Ord a, Read a) => ReadPrec (OSet a)
    forall a. (Ord a, Read a) => Int -> ReadS (OSet a)
    forall a. (Ord a, Read a) => ReadS [OSet a]
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: forall a. (Ord a, Read a) => Int -> ReadS (OSet a)
    readsPrec :: Int -> ReadS (OSet a)
    $creadList :: forall a. (Ord a, Read a) => ReadS [OSet a]
    readList :: ReadS [OSet a]
    $creadPrec :: forall a. (Ord a, Read a) => ReadPrec (OSet a)
    readPrec :: ReadPrec (OSet a)
    $creadListPrec :: forall a. (Ord a, Read a) => ReadPrec [OSet a]
    readListPrec :: ReadPrec [OSet a]
    Read, Int -> OSet a -> ShowS
    [OSet a] -> ShowS
    OSet a -> String
    (Int -> OSet a -> ShowS)
    -> (OSet a -> String) -> ([OSet a] -> ShowS) -> Show (OSet a)
    forall a. Show a => Int -> OSet a -> ShowS
    forall a. Show a => [OSet a] -> ShowS
    forall a. Show a => OSet a -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: forall a. Show a => Int -> OSet a -> ShowS
    showsPrec :: Int -> OSet a -> ShowS
    $cshow :: forall a. Show a => OSet a -> String
    show :: OSet a -> String
    $cshowList :: forall a. Show a => [OSet a] -> ShowS
    showList :: [OSet a] -> ShowS
    Show)

    instance Ord a => Semigroup (OSet a) where
      <> :: OSet a -> OSet a -> OSet a
    (<>) = OSet a -> OSet a -> OSet a
    forall a. Ord a => OSet a -> OSet a -> OSet a
    union

    empty :: forall a. OSet a
    empty :: forall a. OSet a
    empty = OSet a -> OSet a
    forall a b. Coercible a b => a -> b
    coerce (forall a. OSet a
    OS.empty @a)

    singleton :: a -> OSet a
    singleton :: forall a. a -> OSet a
    singleton a
    a = OSet a -> OSet a
    forall a b. Coercible a b => a -> b
    coerce (a -> OSet a
    forall a. a -> OSet a
    OS.singleton a
    a)

    -- | The element's index will be lower than the indices of the elements in the

    -- 'OSet'.

    insertPre :: Ord a => a -> OSet a -> OSet a
    insertPre :: forall a. Ord a => a -> OSet a -> OSet a
    insertPre a
    a = (OSet a -> OSet a) -> OSet a -> OSet a
    forall a b. Coercible a b => a -> b
    coerce (a
    a a -> OSet a -> OSet a
    forall a. Ord a => a -> OSet a -> OSet a
    OS.|<)

    -- | The element's index will be higher than the indices of the elements in the

    -- 'OSet'.

    insertPost :: Ord a => OSet a -> a -> OSet a
    insertPost :: forall a. Ord a => OSet a -> a -> OSet a
    insertPost OSet a
    s a
    a = OSet a -> OSet a
    forall a b. Coercible a b => a -> b
    coerce (OSet a -> OSet a
    forall a b. Coercible a b => a -> b
    coerce OSet a
    s OSet a -> a -> OSet a
    forall a. Ord a => OSet a -> a -> OSet a
    OS.|> a
    a)

    union :: forall a. Ord a => OSet a -> OSet a -> OSet a
    union :: forall a. Ord a => OSet a -> OSet a -> OSet a
    union = (OSet a -> OSet a -> OSet a) -> OSet a -> OSet a -> OSet a
    forall a b. Coercible a b => a -> b
    coerce (forall a. Ord a => OSet a -> OSet a -> OSet a
    (OS.|<>) @a)

    null :: forall a. OSet a -> Bool
    null :: forall a. OSet a -> Bool
    null = (OSet a -> Bool) -> OSet a -> Bool
    forall a b. Coercible a b => a -> b
    coerce (forall a. OSet a -> Bool
    OS.null @a)

    size :: forall a. OSet a -> Int
    size :: forall a. OSet a -> Int
    size = (OSet a -> Int) -> OSet a -> Int
    forall a b. Coercible a b => a -> b
    coerce (forall a. OSet a -> Int
    OS.size @a)

    member, notMember :: Ord a => a -> OSet a -> Bool
    member :: forall a. Ord a => a -> OSet a -> Bool
    member    a
    a = (OSet a -> Bool) -> OSet a -> Bool
    forall a b. Coercible a b => a -> b
    coerce (a -> OSet a -> Bool
    forall a. Ord a => a -> OSet a -> Bool
    OS.member a
    a)
    notMember :: forall a. Ord a => a -> OSet a -> Bool
    notMember a
    a = (OSet a -> Bool) -> OSet a -> Bool
    forall a b. Coercible a b => a -> b
    coerce (a -> OSet a -> Bool
    forall a. Ord a => a -> OSet a -> Bool
    OS.notMember a
    a)

    delete :: Ord a => a -> OSet a -> OSet a
    delete :: forall a. Ord a => a -> OSet a -> OSet a
    delete a
    a = (OSet a -> OSet a) -> OSet a -> OSet a
    forall a b. Coercible a b => a -> b
    coerce (a -> OSet a -> OSet a
    forall a. Ord a => a -> OSet a -> OSet a
    OS.delete a
    a)

    filter :: Ord a => (a -> Bool) -> OSet a -> OSet a
    filter :: forall a. Ord a => (a -> Bool) -> OSet a -> OSet a
    filter a -> Bool
    f = (OSet a -> OSet a) -> OSet a -> OSet a
    forall a b. Coercible a b => a -> b
    coerce ((a -> Bool) -> OSet a -> OSet a
    forall a. Ord a => (a -> Bool) -> OSet a -> OSet a
    OS.filter a -> Bool
    f)

    (\\) :: forall a. Ord a => OSet a -> OSet a -> OSet a
    \\ :: forall a. Ord a => OSet a -> OSet a -> OSet a
    (\\) = (OSet a -> OSet a -> OSet a) -> OSet a -> OSet a -> OSet a
    forall a b. Coercible a b => a -> b
    coerce (forall a. Ord a => OSet a -> OSet a -> OSet a
    (OS.\\) @a)

    intersection :: forall a. Ord a => OSet a -> OSet a -> OSet a
    intersection :: forall a. Ord a => OSet a -> OSet a -> OSet a
    intersection = (OSet a -> OSet a -> OSet a) -> OSet a -> OSet a -> OSet a
    forall a b. Coercible a b => a -> b
    coerce (forall a. Ord a => OSet a -> OSet a -> OSet a
    (OS.|/\) @a)

    lookupIndex :: Ord a => a -> OSet a -> Maybe Index
    lookupIndex :: forall a. Ord a => a -> OSet a -> Maybe Int
    lookupIndex a
    a = (OSet a -> Maybe Int) -> OSet a -> Maybe Int
    forall a b. Coercible a b => a -> b
    coerce (a -> OSet a -> Maybe Int
    forall a. Ord a => a -> OSet a -> Maybe Int
    OS.findIndex a
    a)

    lookupAt :: forall a. Index -> OSet a -> Maybe a
    lookupAt :: forall a. Int -> OSet a -> Maybe a
    lookupAt Int
    i OSet a
    s = forall a. OSet a -> Int -> Maybe a
    OS.elemAt @a (OSet a -> OSet a
    forall a b. Coercible a b => a -> b
    coerce OSet a
    s) Int
    i

    fromList :: Ord a => [a] -> OSet a
    fromList :: forall a. Ord a => [a] -> OSet a
    fromList [a]
    l = OSet a -> OSet a
    forall a b. Coercible a b => a -> b
    coerce ([a] -> OSet a
    forall a. Ord a => [a] -> OSet a
    OS.fromList [a]
    l)

    toAscList :: forall a. OSet a -> [a]
    toAscList :: forall a. OSet a -> [a]
    toAscList = (OSet a -> [a]) -> OSet a -> [a]
    forall a b. Coercible a b => a -> b
    coerce (forall a. OSet a -> [a]
    OS.toAscList @a)

    toSet :: forall a. OSet a -> S.Set a
    toSet :: forall a. OSet a -> Set a
    toSet = (OSet a -> Set a) -> OSet a -> Set a
    forall a b. Coercible a b => a -> b
    coerce (forall a. OSet a -> Set a
    OS.toSet @a)