{-# LANGUAGE DataKinds         #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE KindSignatures    #-}

module GitHub.Data.Actions.Common (
    WithTotalCount(..),
    ) where

import GitHub.Internal.Prelude
import Prelude ()

-------------------------------------------------------------------------------
-- Common
-------------------------------------------------------------------------------

-- | A page of a paginated response.
data WithTotalCount a = WithTotalCount
    { forall a. WithTotalCount a -> Vector a
withTotalCountItems      :: !(Vector a)
        -- ^ A snippet of the answer.
    , forall a. WithTotalCount a -> Int
withTotalCountTotalCount :: !Int
        -- ^ The total size of the answer.
    }
  deriving (Int -> WithTotalCount a -> ShowS
forall a. Show a => Int -> WithTotalCount a -> ShowS
forall a. Show a => [WithTotalCount a] -> ShowS
forall a. Show a => WithTotalCount a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WithTotalCount a] -> ShowS
$cshowList :: forall a. Show a => [WithTotalCount a] -> ShowS
show :: WithTotalCount a -> String
$cshow :: forall a. Show a => WithTotalCount a -> String
showsPrec :: Int -> WithTotalCount a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> WithTotalCount a -> ShowS
Show, WithTotalCount a -> DataType
WithTotalCount a -> Constr
forall {a}. Data a => Typeable (WithTotalCount a)
forall a. Data a => WithTotalCount a -> DataType
forall a. Data a => WithTotalCount a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b)
-> WithTotalCount a -> WithTotalCount a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> WithTotalCount a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> WithTotalCount a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WithTotalCount a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WithTotalCount a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d)
-> WithTotalCount a -> m (WithTotalCount a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> WithTotalCount a -> m (WithTotalCount a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (WithTotalCount a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WithTotalCount a -> c (WithTotalCount a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (WithTotalCount a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (WithTotalCount 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 (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (WithTotalCount a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WithTotalCount a -> c (WithTotalCount a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (WithTotalCount a))
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> WithTotalCount a -> m (WithTotalCount a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> WithTotalCount a -> m (WithTotalCount a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> WithTotalCount a -> m (WithTotalCount a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> WithTotalCount a -> m (WithTotalCount a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> WithTotalCount a -> m (WithTotalCount a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d)
-> WithTotalCount a -> m (WithTotalCount a)
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> WithTotalCount a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> WithTotalCount a -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> WithTotalCount a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> WithTotalCount a -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WithTotalCount a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WithTotalCount a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WithTotalCount a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WithTotalCount a -> r
gmapT :: (forall b. Data b => b -> b)
-> WithTotalCount a -> WithTotalCount a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b)
-> WithTotalCount a -> WithTotalCount a
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (WithTotalCount a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (WithTotalCount a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (WithTotalCount a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (WithTotalCount a))
dataTypeOf :: WithTotalCount a -> DataType
$cdataTypeOf :: forall a. Data a => WithTotalCount a -> DataType
toConstr :: WithTotalCount a -> Constr
$ctoConstr :: forall a. Data a => WithTotalCount a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (WithTotalCount a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (WithTotalCount a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WithTotalCount a -> c (WithTotalCount a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WithTotalCount a -> c (WithTotalCount a)
Data, Typeable, WithTotalCount a -> WithTotalCount a -> Bool
forall a. Eq a => WithTotalCount a -> WithTotalCount a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WithTotalCount a -> WithTotalCount a -> Bool
$c/= :: forall a. Eq a => WithTotalCount a -> WithTotalCount a -> Bool
== :: WithTotalCount a -> WithTotalCount a -> Bool
$c== :: forall a. Eq a => WithTotalCount a -> WithTotalCount a -> Bool
Eq, WithTotalCount a -> WithTotalCount a -> Bool
WithTotalCount a -> WithTotalCount a -> Ordering
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 (WithTotalCount a)
forall a. Ord a => WithTotalCount a -> WithTotalCount a -> Bool
forall a. Ord a => WithTotalCount a -> WithTotalCount a -> Ordering
forall a.
Ord a =>
WithTotalCount a -> WithTotalCount a -> WithTotalCount a
min :: WithTotalCount a -> WithTotalCount a -> WithTotalCount a
$cmin :: forall a.
Ord a =>
WithTotalCount a -> WithTotalCount a -> WithTotalCount a
max :: WithTotalCount a -> WithTotalCount a -> WithTotalCount a
$cmax :: forall a.
Ord a =>
WithTotalCount a -> WithTotalCount a -> WithTotalCount a
>= :: WithTotalCount a -> WithTotalCount a -> Bool
$c>= :: forall a. Ord a => WithTotalCount a -> WithTotalCount a -> Bool
> :: WithTotalCount a -> WithTotalCount a -> Bool
$c> :: forall a. Ord a => WithTotalCount a -> WithTotalCount a -> Bool
<= :: WithTotalCount a -> WithTotalCount a -> Bool
$c<= :: forall a. Ord a => WithTotalCount a -> WithTotalCount a -> Bool
< :: WithTotalCount a -> WithTotalCount a -> Bool
$c< :: forall a. Ord a => WithTotalCount a -> WithTotalCount a -> Bool
compare :: WithTotalCount a -> WithTotalCount a -> Ordering
$ccompare :: forall a. Ord a => WithTotalCount a -> WithTotalCount a -> Ordering
Ord, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (WithTotalCount a) x -> WithTotalCount a
forall a x. WithTotalCount a -> Rep (WithTotalCount a) x
$cto :: forall a x. Rep (WithTotalCount a) x -> WithTotalCount a
$cfrom :: forall a x. WithTotalCount a -> Rep (WithTotalCount a) x
Generic)

-- | Joining two pages of a paginated response.
--   The 'withTotalCountTotalCount' is assumed to be the same in both pages,
--   but this is not checked.
instance Semigroup (WithTotalCount a) where
    WithTotalCount Vector a
items1 Int
count1 <> :: WithTotalCount a -> WithTotalCount a -> WithTotalCount a
<> WithTotalCount Vector a
items2 Int
_ =
        forall a. Vector a -> Int -> WithTotalCount a
WithTotalCount (Vector a
items1 forall a. Semigroup a => a -> a -> a
<> Vector a
items2) Int
count1

instance Foldable WithTotalCount where
    foldMap :: forall m a. Monoid m => (a -> m) -> WithTotalCount a -> m
foldMap a -> m
f (WithTotalCount Vector a
items Int
_) = forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap a -> m
f Vector a
items