    {-# LANGUAGE CPP                     #-}
    {-# LANGUAGE TypeFamilies            #-}
    {-# OPTIONS_GHC -fno-warn-orphans    #-}
    module Data.MonoTraversable.Instances () where

    import Data.DList.Instances ()
    import           Data.Traversable.Instances ()
    import Data.Functor.Apply (MaybeApply (..), WrappedApplicative)
    import Control.Comonad (Cokleisli, Comonad, extract, extend)
    import Control.Comonad.Store (StoreT)
    import Control.Comonad.Env (EnvT)
    import Control.Comonad.Traced (TracedT)
    import Data.DList (DList)
    import Data.Semigroupoid.Static (Static)
    import qualified Data.DList as DL
    import Data.Vector.Instances ()
    import Data.MonoTraversable
    import Data.Sequences
    #if !MIN_VERSION_base(4,8,0)
    import Control.Monad (liftM)
    #endif
    import Control.Monad.Trans.Identity (IdentityT)
    import Data.Semigroup (Arg)
    import Data.List.NonEmpty (NonEmpty)
    import Data.Functor.Identity (Identity)
    import Data.Tree (Tree)
    import Data.Traversable (traverse)
    import Control.Applicative (Applicative)
    import Data.Monoid (Monoid)

    #if !MIN_VERSION_comonad(5,0,0)
    import Data.Functor.Coproduct (Coproduct)
    #endif

    type instance Element (DList a) = a
    instance MonoFoldable (DList a) where
        otoList :: DList a -> [Element (DList a)]
    otoList = DList a -> [a]
    DList a -> [Element (DList a)]
    forall a. DList a -> [a]
    DL.toList
        headEx :: DList a -> Element (DList a)
    headEx = DList a -> a
    DList a -> Element (DList a)
    forall a. DList a -> a
    DL.head
        {-# INLINE otoList #-}
        {-# INLINE headEx #-}
    instance MonoTraversable (DList a) where
         otraverse :: forall (f :: * -> *).
    Applicative f =>
    (Element (DList a) -> f (Element (DList a)))
    -> DList a -> f (DList a)
    otraverse Element (DList a) -> f (Element (DList a))
    f = ([a] -> DList a) -> f [a] -> f (DList a)
    forall a b. (a -> b) -> f a -> f b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [a] -> DList a
    forall a. [a] -> DList a
    DL.fromList (f [a] -> f (DList a))
    -> (DList a -> f [a]) -> DList a -> f (DList a)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (a -> f a) -> [a] -> f [a]
    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) -> [a] -> f [b]
    Data.Traversable.traverse a -> f a
    Element (DList a) -> f (Element (DList a))
    f ([a] -> f [a]) -> (DList a -> [a]) -> DList a -> f [a]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . DList a -> [a]
    forall a. DList a -> [a]
    DL.toList
    #if !MIN_VERSION_base(4,8,0)
         omapM f = liftM DL.fromList . mapM f . DL.toList
    #endif
    instance MonoFunctor (DList a)
    instance MonoPointed (DList a)
    instance GrowingAppend (DList a)

    instance SemiSequence (DList a) where
        type Index (DList a) = Int
        cons :: Element (DList a) -> DList a -> DList a
    cons = a -> DList a -> DList a
    Element (DList a) -> DList a -> DList a
    forall a. a -> DList a -> DList a
    DL.cons
        snoc :: DList a -> Element (DList a) -> DList a
    snoc = DList a -> a -> DList a
    DList a -> Element (DList a) -> DList a
    forall a. DList a -> a -> DList a
    DL.snoc

        reverse :: DList a -> DList a
    reverse = DList a -> DList a
    forall seq. IsSequence seq => seq -> seq
    defaultReverse
        sortBy :: (Element (DList a) -> Element (DList a) -> Ordering)
    -> DList a -> DList a
    sortBy = (Element (DList a) -> Element (DList a) -> Ordering)
    -> DList a -> DList a
    forall seq.
    IsSequence seq =>
    (Element seq -> Element seq -> Ordering) -> seq -> seq
    defaultSortBy
        intersperse :: Element (DList a) -> DList a -> DList a
    intersperse = Element (DList a) -> DList a -> DList a
    forall seq. IsSequence seq => Element seq -> seq -> seq
    defaultIntersperse
        find :: (Element (DList a) -> Bool) -> DList a -> Maybe (Element (DList a))
    find = (Element (DList a) -> Bool) -> DList a -> Maybe (Element (DList a))
    forall seq.
    MonoFoldable seq =>
    (Element seq -> Bool) -> seq -> Maybe (Element seq)
    defaultFind
        {-# INLINE intersperse #-}
        {-# INLINE reverse #-}
        {-# INLINE find #-}
        {-# INLINE sortBy #-}
        {-# INLINE cons #-}
        {-# INLINE snoc #-}

    instance IsSequence (DList a) where
        fromList :: [Element (DList a)] -> DList a
    fromList = [a] -> DList a
    [Element (DList a)] -> DList a
    forall a. [a] -> DList a
    DL.fromList
        replicate :: Index (DList a) -> Element (DList a) -> DList a
    replicate = Int -> a -> DList a
    Index (DList a) -> Element (DList a) -> DList a
    forall a. Int -> a -> DList a
    DL.replicate
    #if MIN_VERSION_dlist(1,0,0)
        tailEx :: DList a -> DList a
    tailEx = [a] -> DList a
    forall a. [a] -> DList a
    DL.fromList ([a] -> DList a) -> (DList a -> [a]) -> DList a -> DList a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . DList a -> [a]
    forall a. DList a -> [a]
    DL.tail
    #else
        tailEx = DL.tail
    #endif
        {-# INLINE fromList #-}
        {-# INLINE replicate #-}
        {-# INLINE tailEx #-}

    type instance Element (Cokleisli w a b) = b
    instance MonoFunctor (Cokleisli w a b)
    instance MonoPointed (Cokleisli w a b)

    type instance Element (WrappedApplicative f a) = a
    instance Control.Applicative.Applicative f => MonoPointed (WrappedApplicative f a)
    instance Functor f => MonoFunctor (WrappedApplicative f a)

    type instance Element (MaybeApply f a) = a
    instance Functor f => MonoFunctor (MaybeApply f a)
    instance MonoPointed (MaybeApply f a) where
        opoint :: Element (MaybeApply f a) -> MaybeApply f a
    opoint = Either (f a) a -> MaybeApply f a
    forall (f :: * -> *) a. Either (f a) a -> MaybeApply f a
    MaybeApply (Either (f a) a -> MaybeApply f a)
    -> (a -> Either (f a) a) -> a -> MaybeApply f a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . a -> Either (f a) a
    forall a b. b -> Either a b
    Right
        {-# INLINE opoint #-}

    type instance Element (TracedT m w a) = a
    instance (Comonad w, Data.Monoid.Monoid m) => MonoComonad (TracedT m w a) where
        oextract :: TracedT m w a -> Element (TracedT m w a)
    oextract = TracedT m w a -> a
    TracedT m w a -> Element (TracedT m w a)
    forall a. TracedT m w a -> a
    forall (w :: * -> *) a. Comonad w => w a -> a
    extract
        oextend :: (TracedT m w a -> Element (TracedT m w a))
    -> TracedT m w a -> TracedT m w a
    oextend = (TracedT m w a -> a) -> TracedT m w a -> TracedT m w a
    (TracedT m w a -> Element (TracedT m w a))
    -> TracedT m w a -> TracedT m w a
    forall a b. (TracedT m w a -> b) -> TracedT m w a -> TracedT m w b
    forall (w :: * -> *) a b. Comonad w => (w a -> b) -> w a -> w b
    extend
    instance Functor w => MonoFunctor (TracedT m w a)

    type instance Element (StoreT s w a) = a
    instance Comonad w => MonoComonad (StoreT s w a) where
        oextract :: StoreT s w a -> Element (StoreT s w a)
    oextract = StoreT s w a -> a
    StoreT s w a -> Element (StoreT s w a)
    forall a. StoreT s w a -> a
    forall (w :: * -> *) a. Comonad w => w a -> a
    extract
        oextend :: (StoreT s w a -> Element (StoreT s w a))
    -> StoreT s w a -> StoreT s w a
    oextend = (StoreT s w a -> a) -> StoreT s w a -> StoreT s w a
    (StoreT s w a -> Element (StoreT s w a))
    -> StoreT s w a -> StoreT s w a
    forall a b. (StoreT s w a -> b) -> StoreT s w a -> StoreT s w b
    forall (w :: * -> *) a b. Comonad w => (w a -> b) -> w a -> w b
    extend
    instance Functor w => MonoFunctor (StoreT s w a)

    type instance Element (EnvT e w a) = a
    instance Comonad w => MonoComonad (EnvT e w a) where
        oextract :: EnvT e w a -> Element (EnvT e w a)
    oextract = EnvT e w a -> a
    EnvT e w a -> Element (EnvT e w a)
    forall a. EnvT e w a -> a
    forall (w :: * -> *) a. Comonad w => w a -> a
    extract
        oextend :: (EnvT e w a -> Element (EnvT e w a)) -> EnvT e w a -> EnvT e w a
    oextend = (EnvT e w a -> a) -> EnvT e w a -> EnvT e w a
    (EnvT e w a -> Element (EnvT e w a)) -> EnvT e w a -> EnvT e w a
    forall a b. (EnvT e w a -> b) -> EnvT e w a -> EnvT e w b
    forall (w :: * -> *) a b. Comonad w => (w a -> b) -> w a -> w b
    extend
    instance Functor w => MonoFunctor (EnvT e w a)

    #if !MIN_VERSION_comonad(5,0,0)
    type instance Element (Coproduct f g a) = a
    instance (Functor f, Functor g) => MonoFunctor (Coproduct f g a)
    instance (Comonad f, Comonad g) => MonoComonad (Coproduct f g a) where
        oextract = extract
        oextend = extend
    #endif

    type instance Element (Static f a b) = b
    instance Applicative f => MonoPointed (Static f a b)
    instance Functor f => MonoFunctor (Static f a b)

    instance Comonad w => MonoComonad (IdentityT w a) where
        oextract :: IdentityT w a -> Element (IdentityT w a)
    oextract = IdentityT w a -> a
    IdentityT w a -> Element (IdentityT w a)
    forall a. IdentityT w a -> a
    forall (w :: * -> *) a. Comonad w => w a -> a
    extract
        oextend :: (IdentityT w a -> Element (IdentityT w a))
    -> IdentityT w a -> IdentityT w a
    oextend = (IdentityT w a -> a) -> IdentityT w a -> IdentityT w a
    (IdentityT w a -> Element (IdentityT w a))
    -> IdentityT w a -> IdentityT w a
    forall a b. (IdentityT w a -> b) -> IdentityT w a -> IdentityT w b
    forall (w :: * -> *) a b. Comonad w => (w a -> b) -> w a -> w b
    extend

    -- Comonad
    instance MonoComonad (Tree a) where
        oextract :: Tree a -> Element (Tree a)
    oextract = Tree a -> a
    Tree a -> Element (Tree a)
    forall a. Tree a -> a
    forall (w :: * -> *) a. Comonad w => w a -> a
    extract
        oextend :: (Tree a -> Element (Tree a)) -> Tree a -> Tree a
    oextend = (Tree a -> a) -> Tree a -> Tree a
    (Tree a -> Element (Tree a)) -> Tree a -> Tree a
    forall a b. (Tree a -> b) -> Tree a -> Tree b
    forall (w :: * -> *) a b. Comonad w => (w a -> b) -> w a -> w b
    extend
    instance MonoComonad (NonEmpty a) where
        oextract :: NonEmpty a -> Element (NonEmpty a)
    oextract = NonEmpty a -> a
    NonEmpty a -> Element (NonEmpty a)
    forall a. NonEmpty a -> a
    forall (w :: * -> *) a. Comonad w => w a -> a
    extract
        oextend :: (NonEmpty a -> Element (NonEmpty a)) -> NonEmpty a -> NonEmpty a
    oextend = (NonEmpty a -> a) -> NonEmpty a -> NonEmpty a
    (NonEmpty a -> Element (NonEmpty a)) -> NonEmpty a -> NonEmpty a
    forall a b. (NonEmpty a -> b) -> NonEmpty a -> NonEmpty b
    forall (w :: * -> *) a b. Comonad w => (w a -> b) -> w a -> w b
    extend
    instance MonoComonad (Identity a) where
        oextract :: Identity a -> Element (Identity a)
    oextract = Identity a -> a
    Identity a -> Element (Identity a)
    forall a. Identity a -> a
    forall (w :: * -> *) a. Comonad w => w a -> a
    extract
        oextend :: (Identity a -> Element (Identity a)) -> Identity a -> Identity a
    oextend = (Identity a -> a) -> Identity a -> Identity a
    (Identity a -> Element (Identity a)) -> Identity a -> Identity a
    forall a b. (Identity a -> b) -> Identity a -> Identity b
    forall (w :: * -> *) a b. Comonad w => (w a -> b) -> w a -> w b
    extend
    instance Monoid m => MonoComonad (m -> a) where
        oextract :: (m -> a) -> Element (m -> a)
    oextract = (m -> a) -> a
    (m -> a) -> Element (m -> a)
    forall a. (m -> a) -> a
    forall (w :: * -> *) a. Comonad w => w a -> a
    extract
        oextend :: ((m -> a) -> Element (m -> a)) -> (m -> a) -> m -> a
    oextend = ((m -> a) -> a) -> (m -> a) -> m -> a
    ((m -> a) -> Element (m -> a)) -> (m -> a) -> m -> a
    forall a b. ((m -> a) -> b) -> (m -> a) -> m -> b
    forall (w :: * -> *) a b. Comonad w => (w a -> b) -> w a -> w b
    extend
    instance MonoComonad (e, a) where
        oextract :: (e, a) -> Element (e, a)
    oextract = (e, a) -> a
    (e, a) -> Element (e, a)
    forall a. (e, a) -> a
    forall (w :: * -> *) a. Comonad w => w a -> a
    extract
        oextend :: ((e, a) -> Element (e, a)) -> (e, a) -> (e, a)
    oextend = ((e, a) -> a) -> (e, a) -> (e, a)
    ((e, a) -> Element (e, a)) -> (e, a) -> (e, a)
    forall a b. ((e, a) -> b) -> (e, a) -> (e, b)
    forall (w :: * -> *) a b. Comonad w => (w a -> b) -> w a -> w b
    extend
    instance MonoComonad (Arg a b) where
        oextract :: Arg a b -> Element (Arg a b)
    oextract = Arg a b -> b
    Arg a b -> Element (Arg a b)
    forall a. Arg a a -> a
    forall (w :: * -> *) a. Comonad w => w a -> a
    extract
        oextend :: (Arg a b -> Element (Arg a b)) -> Arg a b -> Arg a b
    oextend = (Arg a b -> b) -> Arg a b -> Arg a b
    (Arg a b -> Element (Arg a b)) -> Arg a b -> Arg a b
    forall a b. (Arg a a -> b) -> Arg a a -> Arg a b
    forall (w :: * -> *) a b. Comonad w => (w a -> b) -> w a -> w b
    extend