{-# 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
[WithTotalCount a] -> ShowS
WithTotalCount a -> String
(Int -> WithTotalCount a -> ShowS)
-> (WithTotalCount a -> String)
-> ([WithTotalCount a] -> ShowS)
-> Show (WithTotalCount a)
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
$cshowsPrec :: forall a. Show a => Int -> WithTotalCount a -> ShowS
showsPrec :: Int -> WithTotalCount a -> ShowS
$cshow :: forall a. Show a => WithTotalCount a -> String
show :: WithTotalCount a -> String
$cshowList :: forall a. Show a => [WithTotalCount a] -> ShowS
showList :: [WithTotalCount a] -> ShowS
Show, Typeable (WithTotalCount a)
Typeable (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 (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (WithTotalCount a))
-> (WithTotalCount a -> Constr)
-> (WithTotalCount a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (WithTotalCount a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (WithTotalCount a)))
-> ((forall b. Data b => b -> b)
    -> WithTotalCount a -> WithTotalCount a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> WithTotalCount a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> WithTotalCount a -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> WithTotalCount a -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> WithTotalCount a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> WithTotalCount a -> m (WithTotalCount a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> WithTotalCount a -> m (WithTotalCount a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> WithTotalCount a -> m (WithTotalCount a))
-> Data (WithTotalCount a)
WithTotalCount a -> Constr
WithTotalCount a -> DataType
(forall b. Data b => b -> b)
-> WithTotalCount a -> WithTotalCount a
forall a. Data a => Typeable (WithTotalCount a)
forall a. Data a => WithTotalCount a -> Constr
forall a. Data a => WithTotalCount a -> DataType
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 u.
Int -> (forall d. Data d => d -> u) -> WithTotalCount a -> u
forall u. (forall d. Data d => d -> u) -> WithTotalCount a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WithTotalCount a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WithTotalCount a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> WithTotalCount a -> m (WithTotalCount a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> WithTotalCount a -> m (WithTotalCount 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))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (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)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WithTotalCount a -> 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)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (WithTotalCount a)
$ctoConstr :: forall a. Data a => WithTotalCount a -> Constr
toConstr :: WithTotalCount a -> Constr
$cdataTypeOf :: forall a. Data a => WithTotalCount a -> DataType
dataTypeOf :: WithTotalCount a -> DataType
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (WithTotalCount a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> 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))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (WithTotalCount a))
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b)
-> WithTotalCount a -> WithTotalCount a
gmapT :: (forall b. Data b => b -> b)
-> WithTotalCount a -> WithTotalCount a
$cgmapQl :: 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
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WithTotalCount a -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WithTotalCount a -> r
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> WithTotalCount a -> [u]
gmapQ :: forall u. (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
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> WithTotalCount a -> u
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad 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)
$cgmapMp :: 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)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> WithTotalCount a -> m (WithTotalCount a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> WithTotalCount a -> m (WithTotalCount a)
Data, Typeable, WithTotalCount a -> WithTotalCount a -> Bool
(WithTotalCount a -> WithTotalCount a -> Bool)
-> (WithTotalCount a -> WithTotalCount a -> Bool)
-> Eq (WithTotalCount a)
forall a. Eq a => WithTotalCount a -> WithTotalCount a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$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
/= :: WithTotalCount a -> WithTotalCount a -> Bool
Eq, Eq (WithTotalCount a)
Eq (WithTotalCount a) =>
(WithTotalCount a -> WithTotalCount a -> Ordering)
-> (WithTotalCount a -> WithTotalCount a -> Bool)
-> (WithTotalCount a -> WithTotalCount a -> Bool)
-> (WithTotalCount a -> WithTotalCount a -> Bool)
-> (WithTotalCount a -> WithTotalCount a -> Bool)
-> (WithTotalCount a -> WithTotalCount a -> WithTotalCount a)
-> (WithTotalCount a -> WithTotalCount a -> WithTotalCount a)
-> Ord (WithTotalCount a)
WithTotalCount a -> WithTotalCount a -> Bool
WithTotalCount a -> WithTotalCount a -> Ordering
WithTotalCount a -> WithTotalCount a -> WithTotalCount 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 (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
$ccompare :: forall a. Ord a => WithTotalCount a -> WithTotalCount a -> Ordering
compare :: WithTotalCount a -> WithTotalCount a -> Ordering
$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
>= :: WithTotalCount a -> WithTotalCount a -> Bool
$cmax :: forall a.
Ord a =>
WithTotalCount a -> WithTotalCount a -> WithTotalCount a
max :: WithTotalCount a -> WithTotalCount a -> WithTotalCount a
$cmin :: forall a.
Ord a =>
WithTotalCount a -> WithTotalCount a -> WithTotalCount a
min :: WithTotalCount a -> WithTotalCount a -> WithTotalCount a
Ord, (forall x. WithTotalCount a -> Rep (WithTotalCount a) x)
-> (forall x. Rep (WithTotalCount a) x -> WithTotalCount a)
-> Generic (WithTotalCount a)
forall x. Rep (WithTotalCount a) x -> WithTotalCount a
forall x. WithTotalCount a -> Rep (WithTotalCount a) x
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
$cfrom :: forall a x. WithTotalCount a -> Rep (WithTotalCount a) x
from :: forall x. WithTotalCount a -> Rep (WithTotalCount a) x
$cto :: forall a x. Rep (WithTotalCount a) x -> WithTotalCount a
to :: forall x. Rep (WithTotalCount a) x -> WithTotalCount a
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
_ =
        Vector a -> Int -> WithTotalCount a
forall a. Vector a -> Int -> WithTotalCount a
WithTotalCount (Vector a
items1 Vector a -> Vector a -> Vector a
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
_) = (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
foldMap a -> m
f Vector a
items