{-# 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 { ResponseF a -> Status responseStatusCode :: Status , ResponseF a -> Seq Header responseHeaders :: Seq.Seq Header , ResponseF a -> HttpVersion responseHttpVersion :: HttpVersion , ResponseF a -> a responseBody :: a } deriving (ResponseF a -> ResponseF a -> Bool (ResponseF a -> ResponseF a -> Bool) -> (ResponseF a -> ResponseF a -> Bool) -> Eq (ResponseF a) 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 [ResponseF a] -> ShowS ResponseF a -> String (Int -> ResponseF a -> ShowS) -> (ResponseF a -> String) -> ([ResponseF a] -> ShowS) -> Show (ResponseF a) 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 x. ResponseF a -> Rep (ResponseF a) x) -> (forall x. Rep (ResponseF a) x -> ResponseF a) -> Generic (ResponseF a) forall x. Rep (ResponseF a) x -> ResponseF a forall x. ResponseF a -> Rep (ResponseF a) x 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, a -> ResponseF b -> ResponseF a (a -> b) -> ResponseF a -> ResponseF b (forall a b. (a -> b) -> ResponseF a -> ResponseF b) -> (forall a b. a -> ResponseF b -> ResponseF a) -> Functor ResponseF 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 <$ :: a -> ResponseF b -> ResponseF a $c<$ :: forall a b. a -> ResponseF b -> ResponseF a fmap :: (a -> b) -> ResponseF a -> ResponseF b $cfmap :: forall a b. (a -> b) -> ResponseF a -> ResponseF b Functor, ResponseF a -> Bool (a -> m) -> ResponseF a -> m (a -> b -> b) -> b -> ResponseF a -> b (forall m. Monoid m => ResponseF m -> m) -> (forall m a. Monoid m => (a -> m) -> ResponseF a -> m) -> (forall m a. Monoid m => (a -> m) -> ResponseF a -> m) -> (forall a b. (a -> b -> b) -> b -> ResponseF a -> b) -> (forall a b. (a -> b -> b) -> b -> ResponseF a -> b) -> (forall b a. (b -> a -> b) -> b -> ResponseF a -> b) -> (forall b a. (b -> a -> b) -> b -> ResponseF a -> b) -> (forall a. (a -> a -> a) -> ResponseF a -> a) -> (forall a. (a -> a -> a) -> ResponseF a -> a) -> (forall a. ResponseF a -> [a]) -> (forall a. ResponseF a -> Bool) -> (forall a. ResponseF a -> Int) -> (forall a. Eq a => a -> ResponseF a -> Bool) -> (forall a. Ord a => ResponseF a -> a) -> (forall a. Ord a => ResponseF a -> a) -> (forall a. Num a => ResponseF a -> a) -> (forall a. Num a => ResponseF a -> a) -> Foldable ResponseF 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 :: ResponseF a -> a $cproduct :: forall a. Num a => ResponseF a -> a sum :: ResponseF a -> a $csum :: forall a. Num a => ResponseF a -> a minimum :: ResponseF a -> a $cminimum :: forall a. Ord a => ResponseF a -> a maximum :: ResponseF a -> a $cmaximum :: forall a. Ord a => ResponseF a -> a elem :: a -> ResponseF a -> Bool $celem :: forall a. Eq a => a -> ResponseF a -> Bool length :: ResponseF a -> Int $clength :: forall a. ResponseF a -> Int null :: ResponseF a -> Bool $cnull :: forall a. ResponseF a -> Bool toList :: ResponseF a -> [a] $ctoList :: forall a. ResponseF a -> [a] foldl1 :: (a -> a -> a) -> ResponseF a -> a $cfoldl1 :: forall a. (a -> a -> a) -> ResponseF a -> a foldr1 :: (a -> a -> a) -> ResponseF a -> a $cfoldr1 :: forall a. (a -> a -> a) -> ResponseF a -> a foldl' :: (b -> a -> b) -> b -> ResponseF a -> b $cfoldl' :: forall b a. (b -> a -> b) -> b -> ResponseF a -> b foldl :: (b -> a -> b) -> b -> ResponseF a -> b $cfoldl :: forall b a. (b -> a -> b) -> b -> ResponseF a -> b foldr' :: (a -> b -> b) -> b -> ResponseF a -> b $cfoldr' :: forall a b. (a -> b -> b) -> b -> ResponseF a -> b foldr :: (a -> b -> b) -> b -> ResponseF a -> b $cfoldr :: forall a b. (a -> b -> b) -> b -> ResponseF a -> b foldMap' :: (a -> m) -> ResponseF a -> m $cfoldMap' :: forall m a. Monoid m => (a -> m) -> ResponseF a -> m foldMap :: (a -> m) -> ResponseF a -> m $cfoldMap :: forall m a. Monoid m => (a -> m) -> ResponseF a -> m fold :: ResponseF m -> m $cfold :: forall m. Monoid m => ResponseF m -> m Foldable, Functor ResponseF Foldable ResponseF Functor ResponseF -> Foldable ResponseF -> (forall (f :: * -> *) a b. Applicative f => (a -> f b) -> ResponseF a -> f (ResponseF b)) -> (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 (m :: * -> *) a. Monad m => ResponseF (m a) -> m (ResponseF a)) -> Traversable ResponseF (a -> f b) -> ResponseF a -> f (ResponseF b) 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 :: ResponseF (m a) -> m (ResponseF a) $csequence :: forall (m :: * -> *) a. Monad m => ResponseF (m a) -> m (ResponseF a) mapM :: (a -> m b) -> ResponseF a -> m (ResponseF b) $cmapM :: forall (m :: * -> *) a b. Monad m => (a -> m b) -> ResponseF a -> m (ResponseF b) sequenceA :: ResponseF (f a) -> f (ResponseF a) $csequenceA :: forall (f :: * -> *) a. Applicative f => ResponseF (f a) -> f (ResponseF a) traverse :: (a -> f b) -> ResponseF a -> f (ResponseF b) $ctraverse :: forall (f :: * -> *) a b. Applicative f => (a -> f b) -> ResponseF a -> f (ResponseF b) $cp2Traversable :: Foldable ResponseF $cp1Traversable :: Functor ResponseF 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` Seq Header -> () forall a. NFData a => a -> () rnf Seq Header hs () -> () -> () `seq` HttpVersion -> () rnfHttpVersion HttpVersion hv () -> () -> () `seq` a -> () forall a. NFData a => a -> () rnf a body where rnfStatus :: Status -> () rnfStatus (Status Int code ByteString msg) = Int -> () forall a. NFData a => a -> () rnf Int code () -> () -> () `seq` ByteString -> () forall a. NFData a => a -> () rnf ByteString msg rnfHttpVersion :: HttpVersion -> () rnfHttpVersion (HttpVersion Int _ Int _) = () -- HttpVersion fields are strict type Response = ResponseF LBS.ByteString type StreamingResponse = ResponseF (SourceIO BS.ByteString)