{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
module Servant.Client.Core.Response (
Response,
StreamingResponse,
ResponseF (..),
) where
import Prelude ()
import Prelude.Compat
import Control.DeepSeq
(NFData (..))
import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as LBS
import qualified Data.Sequence as Seq
import Data.Typeable
(Typeable)
import GHC.Generics
(Generic)
import Network.HTTP.Types
(Header, HttpVersion (..), Status (..))
import Servant.API.Stream
(SourceIO)
data ResponseF a = Response
{ forall a. ResponseF a -> Status
responseStatusCode :: Status
, :: Seq.Seq Header
, forall a. ResponseF a -> HttpVersion
responseHttpVersion :: HttpVersion
, forall a. ResponseF a -> a
responseBody :: a
} deriving (ResponseF a -> ResponseF a -> Bool
forall a. Eq a => ResponseF a -> ResponseF a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResponseF a -> ResponseF a -> Bool
$c/= :: forall a. Eq a => ResponseF a -> ResponseF a -> Bool
== :: ResponseF a -> ResponseF a -> Bool
$c== :: forall a. Eq a => ResponseF a -> ResponseF a -> Bool
Eq, Int -> ResponseF a -> ShowS
forall a. Show a => Int -> ResponseF a -> ShowS
forall a. Show a => [ResponseF a] -> ShowS
forall a. Show a => ResponseF a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResponseF a] -> ShowS
$cshowList :: forall a. Show a => [ResponseF a] -> ShowS
show :: ResponseF a -> String
$cshow :: forall a. Show a => ResponseF a -> String
showsPrec :: Int -> ResponseF a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> ResponseF a -> ShowS
Show, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (ResponseF a) x -> ResponseF a
forall a x. ResponseF a -> Rep (ResponseF a) x
$cto :: forall a x. Rep (ResponseF a) x -> ResponseF a
$cfrom :: forall a x. ResponseF a -> Rep (ResponseF a) x
Generic, Typeable, forall a b. a -> ResponseF b -> ResponseF a
forall a b. (a -> b) -> ResponseF a -> ResponseF b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> ResponseF b -> ResponseF a
$c<$ :: forall a b. a -> ResponseF b -> ResponseF a
fmap :: forall a b. (a -> b) -> ResponseF a -> ResponseF b
$cfmap :: forall a b. (a -> b) -> ResponseF a -> ResponseF b
Functor, forall a. Eq a => a -> ResponseF a -> Bool
forall a. Num a => ResponseF a -> a
forall a. Ord a => ResponseF a -> a
forall m. Monoid m => ResponseF m -> m
forall a. ResponseF a -> Bool
forall a. ResponseF a -> Int
forall a. ResponseF a -> [a]
forall a. (a -> a -> a) -> ResponseF a -> a
forall m a. Monoid m => (a -> m) -> ResponseF a -> m
forall b a. (b -> a -> b) -> b -> ResponseF a -> b
forall a b. (a -> b -> b) -> b -> ResponseF 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
product :: forall a. Num a => ResponseF a -> a
$cproduct :: forall a. Num a => ResponseF a -> a
sum :: forall a. Num a => ResponseF a -> a
$csum :: forall a. Num a => ResponseF a -> a
minimum :: forall a. Ord a => ResponseF a -> a
$cminimum :: forall a. Ord a => ResponseF a -> a
maximum :: forall a. Ord a => ResponseF a -> a
$cmaximum :: forall a. Ord a => ResponseF a -> a
elem :: forall a. Eq a => a -> ResponseF a -> Bool
$celem :: forall a. Eq a => a -> ResponseF a -> Bool
length :: forall a. ResponseF a -> Int
$clength :: forall a. ResponseF a -> Int
null :: forall a. ResponseF a -> Bool
$cnull :: forall a. ResponseF a -> Bool
toList :: forall a. ResponseF a -> [a]
$ctoList :: forall a. ResponseF a -> [a]
foldl1 :: forall a. (a -> a -> a) -> ResponseF a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> ResponseF a -> a
foldr1 :: forall a. (a -> a -> a) -> ResponseF a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> ResponseF a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> ResponseF a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> ResponseF a -> b
foldl :: forall b a. (b -> a -> b) -> b -> ResponseF a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> ResponseF a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> ResponseF a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> ResponseF a -> b
foldr :: forall a b. (a -> b -> b) -> b -> ResponseF a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> ResponseF a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> ResponseF a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> ResponseF a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> ResponseF a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> ResponseF a -> m
fold :: forall m. Monoid m => ResponseF m -> m
$cfold :: forall m. Monoid m => ResponseF m -> m
Foldable, Functor ResponseF
Foldable ResponseF
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
ResponseF (m a) -> m (ResponseF a)
forall (f :: * -> *) a.
Applicative f =>
ResponseF (f a) -> f (ResponseF a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ResponseF a -> m (ResponseF b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ResponseF a -> f (ResponseF b)
sequence :: forall (m :: * -> *) a.
Monad m =>
ResponseF (m a) -> m (ResponseF a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
ResponseF (m a) -> m (ResponseF a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ResponseF a -> m (ResponseF b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ResponseF a -> m (ResponseF b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
ResponseF (f a) -> f (ResponseF a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
ResponseF (f a) -> f (ResponseF a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ResponseF a -> f (ResponseF b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ResponseF a -> f (ResponseF b)
Traversable)
instance NFData a => NFData (ResponseF a) where
rnf :: ResponseF a -> ()
rnf (Response Status
sc Seq Header
hs HttpVersion
hv a
body) =
Status -> ()
rnfStatus Status
sc seq :: forall a b. a -> b -> b
`seq`
forall a. NFData a => a -> ()
rnf Seq Header
hs seq :: forall a b. a -> b -> b
`seq`
HttpVersion -> ()
rnfHttpVersion HttpVersion
hv seq :: forall a b. a -> b -> b
`seq`
forall a. NFData a => a -> ()
rnf a
body
where
rnfStatus :: Status -> ()
rnfStatus (Status Int
code ByteString
msg) = forall a. NFData a => a -> ()
rnf Int
code seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf ByteString
msg
rnfHttpVersion :: HttpVersion -> ()
rnfHttpVersion (HttpVersion Int
_ Int
_) = ()
type Response = ResponseF LBS.ByteString
type StreamingResponse = ResponseF (SourceIO BS.ByteString)