    {-# LANGUAGE CPP #-}
    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE GeneralizedNewtypeDeriving #-}
    {-# LANGUAGE LambdaCase #-}
    -- |
    -- Module      : Data.Vector.NonEmpty.Internal
    -- Copyright   : (c) 2019-2024 Emily Pillmore
    -- License     : BSD-style
    --
    -- Maintainer  : Emily Pillmore <emilypi@cohomolo.gy>
    -- Stability   : experimental
    -- Portability : non-portable
    --
    -- Internal module exposing the constructors for
    -- 'NonEmptyVector' and 'NonEmptyMVector'.
    --
    -- /Warning/: Since the constructors are exposed here, by using this
    -- module, you take on the risks that you break the non-emptiness
    -- invariants of the main modules. Use at your own risk.
    --
    -- @since 0.2.1.0
    --
    module Data.Vector.NonEmpty.Internal
    ( -- * Immutable boxed vectors
      NonEmptyVector(..)
      -- * Mutable boxed vectors
    , NonEmptyMVector(..)
      -- ** Mutable vector aliases
    , NonEmptyIOVector
    , NonEmptySTVector
    ) where

    import Control.DeepSeq (NFData)
    import Control.Monad.ST
    import Control.Monad.Zip (MonadZip)

    import Data.Data (Data)
    import qualified Data.Foldable as Foldable
    #if MIN_VERSION_base(4,18,0)
    import Data.Foldable1 (Foldable1)
    import qualified Data.Foldable1 as Foldable1
    #endif
    import Data.Functor.Classes (Eq1, Ord1, Show1, Read1(..))
    import qualified Data.Vector as V
    #if __GLASGOW_HASKELL__ < 912
    import Data.Typeable (Typeable)
    #endif
    import Data.Vector.Mutable (MVector)

    import qualified Text.Read as Read

    -- ---------------------------------------------------------------------- --
    -- Non-empty immutable vectors

    -- | 'NonEmptyVector' is a thin wrapper around 'Vector' that
    -- witnesses an API requiring non-empty construction,
    -- initialization, and generation of non-empty vectors by design.
    --
    -- A newtype wrapper was chosen so that no new pointer indirection
    -- is introduced when working with 'Vector's, and all performance
    -- characteristics inherited from the 'Vector' API still apply.
    --
    -- @since 0.2.1.0
    --
    newtype NonEmptyVector a = NonEmptyVector
        { forall a. NonEmptyVector a -> Vector a
    _neVec :: V.Vector a
        } deriving
          ( NonEmptyVector a -> NonEmptyVector a -> Bool
    (NonEmptyVector a -> NonEmptyVector a -> Bool)
    -> (NonEmptyVector a -> NonEmptyVector a -> Bool)
    -> Eq (NonEmptyVector a)
    forall a. Eq a => NonEmptyVector a -> NonEmptyVector a -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: forall a. Eq a => NonEmptyVector a -> NonEmptyVector a -> Bool
    == :: NonEmptyVector a -> NonEmptyVector a -> Bool
    $c/= :: forall a. Eq a => NonEmptyVector a -> NonEmptyVector a -> Bool
    /= :: NonEmptyVector a -> NonEmptyVector a -> Bool
    Eq, Eq (NonEmptyVector a)
    Eq (NonEmptyVector a) =>
    (NonEmptyVector a -> NonEmptyVector a -> Ordering)
    -> (NonEmptyVector a -> NonEmptyVector a -> Bool)
    -> (NonEmptyVector a -> NonEmptyVector a -> Bool)
    -> (NonEmptyVector a -> NonEmptyVector a -> Bool)
    -> (NonEmptyVector a -> NonEmptyVector a -> Bool)
    -> (NonEmptyVector a -> NonEmptyVector a -> NonEmptyVector a)
    -> (NonEmptyVector a -> NonEmptyVector a -> NonEmptyVector a)
    -> Ord (NonEmptyVector a)
    NonEmptyVector a -> NonEmptyVector a -> Bool
    NonEmptyVector a -> NonEmptyVector a -> Ordering
    NonEmptyVector a -> NonEmptyVector a -> NonEmptyVector 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 (NonEmptyVector a)
    forall a. Ord a => NonEmptyVector a -> NonEmptyVector a -> Bool
    forall a. Ord a => NonEmptyVector a -> NonEmptyVector a -> Ordering
    forall a.
    Ord a =>
    NonEmptyVector a -> NonEmptyVector a -> NonEmptyVector a
    $ccompare :: forall a. Ord a => NonEmptyVector a -> NonEmptyVector a -> Ordering
    compare :: NonEmptyVector a -> NonEmptyVector a -> Ordering
    $c< :: forall a. Ord a => NonEmptyVector a -> NonEmptyVector a -> Bool
    < :: NonEmptyVector a -> NonEmptyVector a -> Bool
    $c<= :: forall a. Ord a => NonEmptyVector a -> NonEmptyVector a -> Bool
    <= :: NonEmptyVector a -> NonEmptyVector a -> Bool
    $c> :: forall a. Ord a => NonEmptyVector a -> NonEmptyVector a -> Bool
    > :: NonEmptyVector a -> NonEmptyVector a -> Bool
    $c>= :: forall a. Ord a => NonEmptyVector a -> NonEmptyVector a -> Bool
    >= :: NonEmptyVector a -> NonEmptyVector a -> Bool
    $cmax :: forall a.
    Ord a =>
    NonEmptyVector a -> NonEmptyVector a -> NonEmptyVector a
    max :: NonEmptyVector a -> NonEmptyVector a -> NonEmptyVector a
    $cmin :: forall a.
    Ord a =>
    NonEmptyVector a -> NonEmptyVector a -> NonEmptyVector a
    min :: NonEmptyVector a -> NonEmptyVector a -> NonEmptyVector a
    Ord
          , (forall a. Eq a => Eq (NonEmptyVector a)) =>
    (forall a b.
     (a -> b -> Bool) -> NonEmptyVector a -> NonEmptyVector b -> Bool)
    -> Eq1 NonEmptyVector
    forall a. Eq a => Eq (NonEmptyVector a)
    forall a b.
    (a -> b -> Bool) -> NonEmptyVector a -> NonEmptyVector b -> Bool
    forall (f :: * -> *).
    (forall a. Eq a => Eq (f a)) =>
    (forall a b. (a -> b -> Bool) -> f a -> f b -> Bool) -> Eq1 f
    $cliftEq :: forall a b.
    (a -> b -> Bool) -> NonEmptyVector a -> NonEmptyVector b -> Bool
    liftEq :: forall a b.
    (a -> b -> Bool) -> NonEmptyVector a -> NonEmptyVector b -> Bool
    Eq1, Eq1 NonEmptyVector
    (Eq1 NonEmptyVector, forall a. Ord a => Ord (NonEmptyVector a)) =>
    (forall a b.
     (a -> b -> Ordering)
     -> NonEmptyVector a -> NonEmptyVector b -> Ordering)
    -> Ord1 NonEmptyVector
    forall a. Ord a => Ord (NonEmptyVector a)
    forall a b.
    (a -> b -> Ordering)
    -> NonEmptyVector a -> NonEmptyVector b -> Ordering
    forall (f :: * -> *).
    (Eq1 f, forall a. Ord a => Ord (f a)) =>
    (forall a b. (a -> b -> Ordering) -> f a -> f b -> Ordering)
    -> Ord1 f
    $cliftCompare :: forall a b.
    (a -> b -> Ordering)
    -> NonEmptyVector a -> NonEmptyVector b -> Ordering
    liftCompare :: forall a b.
    (a -> b -> Ordering)
    -> NonEmptyVector a -> NonEmptyVector b -> Ordering
    Ord1, (forall a. Show a => Show (NonEmptyVector a)) =>
    (forall a.
     (Int -> a -> ShowS)
     -> ([a] -> ShowS) -> Int -> NonEmptyVector a -> ShowS)
    -> (forall a.
        (Int -> a -> ShowS)
        -> ([a] -> ShowS) -> [NonEmptyVector a] -> ShowS)
    -> Show1 NonEmptyVector
    forall a. Show a => Show (NonEmptyVector a)
    forall a.
    (Int -> a -> ShowS)
    -> ([a] -> ShowS) -> Int -> NonEmptyVector a -> ShowS
    forall a.
    (Int -> a -> ShowS)
    -> ([a] -> ShowS) -> [NonEmptyVector a] -> ShowS
    forall (f :: * -> *).
    (forall a. Show a => Show (f a)) =>
    (forall a.
     (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS)
    -> (forall a.
        (Int -> a -> ShowS) -> ([a] -> ShowS) -> [f a] -> ShowS)
    -> Show1 f
    $cliftShowsPrec :: forall a.
    (Int -> a -> ShowS)
    -> ([a] -> ShowS) -> Int -> NonEmptyVector a -> ShowS
    liftShowsPrec :: forall a.
    (Int -> a -> ShowS)
    -> ([a] -> ShowS) -> Int -> NonEmptyVector a -> ShowS
    $cliftShowList :: forall a.
    (Int -> a -> ShowS)
    -> ([a] -> ShowS) -> [NonEmptyVector a] -> ShowS
    liftShowList :: forall a.
    (Int -> a -> ShowS)
    -> ([a] -> ShowS) -> [NonEmptyVector a] -> ShowS
    Show1
          , Typeable (NonEmptyVector a)
    Typeable (NonEmptyVector a) =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g)
     -> NonEmptyVector a
     -> c (NonEmptyVector a))
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c (NonEmptyVector a))
    -> (NonEmptyVector a -> Constr)
    -> (NonEmptyVector a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c (NonEmptyVector a)))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c (NonEmptyVector a)))
    -> ((forall b. Data b => b -> b)
        -> NonEmptyVector a -> NonEmptyVector a)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> NonEmptyVector a -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> NonEmptyVector a -> r)
    -> (forall u.
        (forall d. Data d => d -> u) -> NonEmptyVector a -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> NonEmptyVector a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d)
        -> NonEmptyVector a -> m (NonEmptyVector a))
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d)
        -> NonEmptyVector a -> m (NonEmptyVector a))
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d)
        -> NonEmptyVector a -> m (NonEmptyVector a))
    -> Data (NonEmptyVector a)
    NonEmptyVector a -> Constr
    NonEmptyVector a -> DataType
    (forall b. Data b => b -> b)
    -> NonEmptyVector a -> NonEmptyVector a
    forall a. Data a => Typeable (NonEmptyVector a)
    forall a. Data a => NonEmptyVector a -> Constr
    forall a. Data a => NonEmptyVector a -> DataType
    forall a.
    Data a =>
    (forall b. Data b => b -> b)
    -> NonEmptyVector a -> NonEmptyVector a
    forall a u.
    Data a =>
    Int -> (forall d. Data d => d -> u) -> NonEmptyVector a -> u
    forall a u.
    Data a =>
    (forall d. Data d => d -> u) -> NonEmptyVector a -> [u]
    forall a r r'.
    Data a =>
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> NonEmptyVector a -> r
    forall a r r'.
    Data a =>
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> NonEmptyVector a -> r
    forall a (m :: * -> *).
    (Data a, Monad m) =>
    (forall d. Data d => d -> m d)
    -> NonEmptyVector a -> m (NonEmptyVector a)
    forall a (m :: * -> *).
    (Data a, MonadPlus m) =>
    (forall d. Data d => d -> m d)
    -> NonEmptyVector a -> m (NonEmptyVector a)
    forall a (c :: * -> *).
    Data a =>
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (NonEmptyVector a)
    forall a (c :: * -> *).
    Data a =>
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> NonEmptyVector a -> c (NonEmptyVector a)
    forall a (t :: * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d. Data d => c (t d)) -> Maybe (c (NonEmptyVector a))
    forall a (t :: * -> * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (NonEmptyVector 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) -> NonEmptyVector a -> u
    forall u. (forall d. Data d => d -> u) -> NonEmptyVector a -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> NonEmptyVector a -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> NonEmptyVector a -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> NonEmptyVector a -> m (NonEmptyVector a)
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> NonEmptyVector a -> m (NonEmptyVector a)
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (NonEmptyVector a)
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> NonEmptyVector a -> c (NonEmptyVector a)
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (NonEmptyVector a))
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (NonEmptyVector a))
    $cgfoldl :: forall a (c :: * -> *).
    Data a =>
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> NonEmptyVector a -> c (NonEmptyVector a)
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> NonEmptyVector a -> c (NonEmptyVector a)
    $cgunfold :: forall a (c :: * -> *).
    Data a =>
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (NonEmptyVector a)
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (NonEmptyVector a)
    $ctoConstr :: forall a. Data a => NonEmptyVector a -> Constr
    toConstr :: NonEmptyVector a -> Constr
    $cdataTypeOf :: forall a. Data a => NonEmptyVector a -> DataType
    dataTypeOf :: NonEmptyVector a -> DataType
    $cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d. Data d => c (t d)) -> Maybe (c (NonEmptyVector a))
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (NonEmptyVector a))
    $cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
    (Data a, Typeable t) =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (NonEmptyVector a))
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (NonEmptyVector a))
    $cgmapT :: forall a.
    Data a =>
    (forall b. Data b => b -> b)
    -> NonEmptyVector a -> NonEmptyVector a
    gmapT :: (forall b. Data b => b -> b)
    -> NonEmptyVector a -> NonEmptyVector a
    $cgmapQl :: forall a r r'.
    Data a =>
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> NonEmptyVector a -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> NonEmptyVector a -> r
    $cgmapQr :: forall a r r'.
    Data a =>
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> NonEmptyVector a -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> NonEmptyVector a -> r
    $cgmapQ :: forall a u.
    Data a =>
    (forall d. Data d => d -> u) -> NonEmptyVector a -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> NonEmptyVector a -> [u]
    $cgmapQi :: forall a u.
    Data a =>
    Int -> (forall d. Data d => d -> u) -> NonEmptyVector a -> u
    gmapQi :: forall u.
    Int -> (forall d. Data d => d -> u) -> NonEmptyVector a -> u
    $cgmapM :: forall a (m :: * -> *).
    (Data a, Monad m) =>
    (forall d. Data d => d -> m d)
    -> NonEmptyVector a -> m (NonEmptyVector a)
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> NonEmptyVector a -> m (NonEmptyVector a)
    $cgmapMp :: forall a (m :: * -> *).
    (Data a, MonadPlus m) =>
    (forall d. Data d => d -> m d)
    -> NonEmptyVector a -> m (NonEmptyVector a)
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> NonEmptyVector a -> m (NonEmptyVector a)
    $cgmapMo :: forall a (m :: * -> *).
    (Data a, MonadPlus m) =>
    (forall d. Data d => d -> m d)
    -> NonEmptyVector a -> m (NonEmptyVector a)
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> NonEmptyVector a -> m (NonEmptyVector a)
    Data, NonEmptyVector a -> ()
    (NonEmptyVector a -> ()) -> NFData (NonEmptyVector a)
    forall a. NFData a => NonEmptyVector a -> ()
    forall a. (a -> ()) -> NFData a
    $crnf :: forall a. NFData a => NonEmptyVector a -> ()
    rnf :: NonEmptyVector a -> ()
    NFData
    #if __GLASGOW_HASKELL__ < 912
          , Typeable
    #endif
          , (forall a b. (a -> b) -> NonEmptyVector a -> NonEmptyVector b)
    -> (forall a b. a -> NonEmptyVector b -> NonEmptyVector a)
    -> Functor NonEmptyVector
    forall a b. a -> NonEmptyVector b -> NonEmptyVector a
    forall a b. (a -> b) -> NonEmptyVector a -> NonEmptyVector b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    $cfmap :: forall a b. (a -> b) -> NonEmptyVector a -> NonEmptyVector b
    fmap :: forall a b. (a -> b) -> NonEmptyVector a -> NonEmptyVector b
    $c<$ :: forall a b. a -> NonEmptyVector b -> NonEmptyVector a
    <$ :: forall a b. a -> NonEmptyVector b -> NonEmptyVector a
    Functor, Functor NonEmptyVector
    Functor NonEmptyVector =>
    (forall a. a -> NonEmptyVector a)
    -> (forall a b.
        NonEmptyVector (a -> b) -> NonEmptyVector a -> NonEmptyVector b)
    -> (forall a b c.
        (a -> b -> c)
        -> NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector c)
    -> (forall a b.
        NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector b)
    -> (forall a b.
        NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector a)
    -> Applicative NonEmptyVector
    forall a. a -> NonEmptyVector a
    forall a b.
    NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector a
    forall a b.
    NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector b
    forall a b.
    NonEmptyVector (a -> b) -> NonEmptyVector a -> NonEmptyVector b
    forall a b c.
    (a -> b -> c)
    -> NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector c
    forall (f :: * -> *).
    Functor f =>
    (forall a. a -> f a)
    -> (forall a b. f (a -> b) -> f a -> f b)
    -> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
    -> (forall a b. f a -> f b -> f b)
    -> (forall a b. f a -> f b -> f a)
    -> Applicative f
    $cpure :: forall a. a -> NonEmptyVector a
    pure :: forall a. a -> NonEmptyVector a
    $c<*> :: forall a b.
    NonEmptyVector (a -> b) -> NonEmptyVector a -> NonEmptyVector b
    <*> :: forall a b.
    NonEmptyVector (a -> b) -> NonEmptyVector a -> NonEmptyVector b
    $cliftA2 :: forall a b c.
    (a -> b -> c)
    -> NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector c
    liftA2 :: forall a b c.
    (a -> b -> c)
    -> NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector c
    $c*> :: forall a b.
    NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector b
    *> :: forall a b.
    NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector b
    $c<* :: forall a b.
    NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector a
    <* :: forall a b.
    NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector a
    Applicative, Applicative NonEmptyVector
    Applicative NonEmptyVector =>
    (forall a b.
     NonEmptyVector a -> (a -> NonEmptyVector b) -> NonEmptyVector b)
    -> (forall a b.
        NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector b)
    -> (forall a. a -> NonEmptyVector a)
    -> Monad NonEmptyVector
    forall a. a -> NonEmptyVector a
    forall a b.
    NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector b
    forall a b.
    NonEmptyVector a -> (a -> NonEmptyVector b) -> NonEmptyVector b
    forall (m :: * -> *).
    Applicative m =>
    (forall a b. m a -> (a -> m b) -> m b)
    -> (forall a b. m a -> m b -> m b)
    -> (forall a. a -> m a)
    -> Monad m
    $c>>= :: forall a b.
    NonEmptyVector a -> (a -> NonEmptyVector b) -> NonEmptyVector b
    >>= :: forall a b.
    NonEmptyVector a -> (a -> NonEmptyVector b) -> NonEmptyVector b
    $c>> :: forall a b.
    NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector b
    >> :: forall a b.
    NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector b
    $creturn :: forall a. a -> NonEmptyVector a
    return :: forall a. a -> NonEmptyVector a
    Monad
          , Monad NonEmptyVector
    Monad NonEmptyVector =>
    (forall a b.
     NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector (a, b))
    -> (forall a b c.
        (a -> b -> c)
        -> NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector c)
    -> (forall a b.
        NonEmptyVector (a, b) -> (NonEmptyVector a, NonEmptyVector b))
    -> MonadZip NonEmptyVector
    forall a b.
    NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector (a, b)
    forall a b.
    NonEmptyVector (a, b) -> (NonEmptyVector a, NonEmptyVector b)
    forall a b c.
    (a -> b -> c)
    -> NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector c
    forall (m :: * -> *).
    Monad m =>
    (forall a b. m a -> m b -> m (a, b))
    -> (forall a b c. (a -> b -> c) -> m a -> m b -> m c)
    -> (forall a b. m (a, b) -> (m a, m b))
    -> MonadZip m
    $cmzip :: forall a b.
    NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector (a, b)
    mzip :: forall a b.
    NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector (a, b)
    $cmzipWith :: forall a b c.
    (a -> b -> c)
    -> NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector c
    mzipWith :: forall a b c.
    (a -> b -> c)
    -> NonEmptyVector a -> NonEmptyVector b -> NonEmptyVector c
    $cmunzip :: forall a b.
    NonEmptyVector (a, b) -> (NonEmptyVector a, NonEmptyVector b)
    munzip :: forall a b.
    NonEmptyVector (a, b) -> (NonEmptyVector a, NonEmptyVector b)
    MonadZip
          , NonEmpty (NonEmptyVector a) -> NonEmptyVector a
    NonEmptyVector a -> NonEmptyVector a -> NonEmptyVector a
    (NonEmptyVector a -> NonEmptyVector a -> NonEmptyVector a)
    -> (NonEmpty (NonEmptyVector a) -> NonEmptyVector a)
    -> (forall b.
        Integral b =>
        b -> NonEmptyVector a -> NonEmptyVector a)
    -> Semigroup (NonEmptyVector a)
    forall b. Integral b => b -> NonEmptyVector a -> NonEmptyVector a
    forall a. NonEmpty (NonEmptyVector a) -> NonEmptyVector a
    forall a. NonEmptyVector a -> NonEmptyVector a -> NonEmptyVector a
    forall a.
    (a -> a -> a)
    -> (NonEmpty a -> a)
    -> (forall b. Integral b => b -> a -> a)
    -> Semigroup a
    forall a b. Integral b => b -> NonEmptyVector a -> NonEmptyVector a
    $c<> :: forall a. NonEmptyVector a -> NonEmptyVector a -> NonEmptyVector a
    <> :: NonEmptyVector a -> NonEmptyVector a -> NonEmptyVector a
    $csconcat :: forall a. NonEmpty (NonEmptyVector a) -> NonEmptyVector a
    sconcat :: NonEmpty (NonEmptyVector a) -> NonEmptyVector a
    $cstimes :: forall a b. Integral b => b -> NonEmptyVector a -> NonEmptyVector a
    stimes :: forall b. Integral b => b -> NonEmptyVector a -> NonEmptyVector a
    Semigroup
          )

    instance Show a => Show (NonEmptyVector a) where
        show :: NonEmptyVector a -> String
    show (NonEmptyVector Vector a
    v) = Vector a -> String
    forall a. Show a => a -> String
    show Vector a
    v

    instance Read a => Read (NonEmptyVector a) where
        readPrec :: ReadPrec (NonEmptyVector a)
    readPrec = ReadPrec [a]
    forall a. Read a => ReadPrec a
    Read.readPrec ReadPrec [a]
    -> ([a] -> ReadPrec (NonEmptyVector a))
    -> ReadPrec (NonEmptyVector a)
    forall a b. ReadPrec a -> (a -> ReadPrec b) -> ReadPrec b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \case
          [] -> ReadPrec (NonEmptyVector a)
    forall a. ReadPrec a
    Read.pfail
          [a]
    as -> NonEmptyVector a -> ReadPrec (NonEmptyVector a)
    forall a. a -> ReadPrec a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Vector a -> NonEmptyVector a
    forall a. Vector a -> NonEmptyVector a
    NonEmptyVector (Vector a -> NonEmptyVector a) -> Vector a -> NonEmptyVector a
    forall a b. (a -> b) -> a -> b
    $ [a] -> Vector a
    forall a. [a] -> Vector a
    V.fromList [a]
    as)

    instance Read1 NonEmptyVector where
        liftReadPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec (NonEmptyVector a)
    liftReadPrec ReadPrec a
    _ ReadPrec [a]
    rl = ReadPrec [a]
    rl ReadPrec [a]
    -> ([a] -> ReadPrec (NonEmptyVector a))
    -> ReadPrec (NonEmptyVector a)
    forall a b. ReadPrec a -> (a -> ReadPrec b) -> ReadPrec b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \case
          [] -> ReadPrec (NonEmptyVector a)
    forall a. ReadPrec a
    Read.pfail
          [a]
    as -> NonEmptyVector a -> ReadPrec (NonEmptyVector a)
    forall a. a -> ReadPrec a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Vector a -> NonEmptyVector a
    forall a. Vector a -> NonEmptyVector a
    NonEmptyVector (Vector a -> NonEmptyVector a) -> Vector a -> NonEmptyVector a
    forall a b. (a -> b) -> a -> b
    $ [a] -> Vector a
    forall a. [a] -> Vector a
    V.fromList [a]
    as)

    instance Foldable NonEmptyVector where
        foldMap :: forall m a. Monoid m => (a -> m) -> NonEmptyVector a -> m
    foldMap a -> m
    f = (a -> m) -> Vector a -> m
    forall m a. Monoid m => (a -> m) -> Vector a -> m
    forall (t :: * -> *) m a.
    (Foldable t, Monoid m) =>
    (a -> m) -> t a -> m
    Foldable.foldMap a -> m
    f (Vector a -> m)
    -> (NonEmptyVector a -> Vector a) -> NonEmptyVector a -> m
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . NonEmptyVector a -> Vector a
    forall a. NonEmptyVector a -> Vector a
    _neVec

    #if MIN_VERSION_base(4,18,0)
    instance Foldable1 NonEmptyVector where
        foldMap1 :: forall m a. Semigroup m => (a -> m) -> NonEmptyVector a -> m
    foldMap1 a -> m
    f (NonEmptyVector Vector a
    v) =
            let
              h :: a
    h = Vector a -> a
    forall a. Vector a -> a
    V.unsafeHead Vector a
    v -- gauranteed head (nonemptiness)
              t :: Vector a
    t = Vector a -> Vector a
    forall a. Vector a -> Vector a
    V.unsafeTail Vector a
    v -- gauranteed possibly empty tail
            in m -> Vector a -> m
    go (a -> m
    f a
    h) Vector a
    t -- therefore this is a sound call
          where
            go :: m -> Vector a -> m
    go m
    x Vector a
    xs
              -- when xs is empty, vector is exhausted, return x
              | Vector a -> Bool
    forall a. Vector a -> Bool
    V.null Vector a
    xs = m
    x
              | Bool
    otherwise =
              -- if xs is not empty, then there are at least 2 elements in the list. Hence, h and t are sound calls to make.
                let
                  h :: a
    h = Vector a -> a
    forall a. Vector a -> a
    V.unsafeHead Vector a
    xs
                  t :: Vector a
    t = Vector a -> Vector a
    forall a. Vector a -> Vector a
    V.unsafeTail Vector a
    xs
                in m
    x m -> m -> m
    forall a. Semigroup a => a -> a -> a
    <> m -> Vector a -> m
    go (a -> m
    f a
    h) Vector a
    t
    #endif

    instance Traversable NonEmptyVector where
        traverse :: forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> NonEmptyVector a -> f (NonEmptyVector b)
    traverse a -> f b
    f = (Vector b -> NonEmptyVector b)
    -> f (Vector b) -> f (NonEmptyVector b)
    forall a b. (a -> b) -> f a -> f b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Vector b -> NonEmptyVector b
    forall a. Vector a -> NonEmptyVector a
    NonEmptyVector (f (Vector b) -> f (NonEmptyVector b))
    -> (NonEmptyVector a -> f (Vector b))
    -> NonEmptyVector a
    -> f (NonEmptyVector b)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (a -> f b) -> Vector a -> f (Vector b)
    forall (t :: * -> *) (f :: * -> *) a b.
    (Traversable t, Applicative f) =>
    (a -> f b) -> t a -> f (t b)
    forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Vector a -> f (Vector b)
    traverse a -> f b
    f (Vector a -> f (Vector b))
    -> (NonEmptyVector a -> Vector a)
    -> NonEmptyVector a
    -> f (Vector b)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . NonEmptyVector a -> Vector a
    forall a. NonEmptyVector a -> Vector a
    _neVec

    -- ---------------------------------------------------------------------- --
    -- Non-empty mutable vectors

    -- | 'NonEmptyMVector' is a thin wrapper around 'MVector' that
    -- witnesses an API requiring non-empty construction,
    -- initialization, and generation of non-empty vectors by design.
    --
    -- A newtype wrapper was chosen so that no new pointer indirection
    -- is introduced when working with 'MVector's, and all performance
    -- characteristics inherited from the 'MVector' API still apply.
    --
    -- @since 0.2.1.0
    --
    newtype NonEmptyMVector s a = NonEmptyMVector
        { forall s a. NonEmptyMVector s a -> MVector s a
    _nemVec :: MVector s a }
    #if __GLASGOW_HASKELL__ < 912
        deriving (Typeable)
    #endif

    -- | 'NonEmptyMVector' parametrized by 'PrimState'
    --
    -- @since 0.2.1.0
    --
    type NonEmptyIOVector = NonEmptyMVector RealWorld

    -- | 'NonEmptyMVector' parametrized by 'ST'
    --
    -- @since 0.2.1.0
    --
    type NonEmptySTVector s = NonEmptyMVector s