@@ -56,7 +56,9 @@ import Blaze.ByteString.Builder (Builder)
5656import Control.Exception (Exception, SomeException, throwIO)
5757import Data.ByteString (ByteString)
5858import Data.IORef (newIORef, readIORef, writeIORef)
59+#if __GLASGOW_HASKELL__ < 709
5960import Data.Monoid (mempty)
61+#endif
6062import Data.Typeable (Typeable)
6163import qualified Network.HTTP.Types as H
6264
@@ -127,7 +129,7 @@ type PushFunc = PushPromise -> Responder -> IO Bool
127129-- | Create the 'H.RequestHeaders' corresponding to the given 'PushPromise'.
128130--
129131-- This is primarily useful for Wai handlers like Warp, and application
130−-- implementers are unlikely to need it.
132+-- implementers are unlikely to use it directly.
131133promiseHeaders :: PushPromise -> H.RequestHeaders
132134promiseHeaders p =
133135 [ (":method", promisedMethod p)
@@ -198,21 +200,20 @@ streamSimple body write flush = body (write . BuilderChunk) flush
198200-- 'ResponseFile'.
199201responder :: Request -> Response -> Responder
200202responder req response respond = case response of
201− (ResponseBuilder s h b) -> respond s h mempty (streamBuilder b)
202− (ResponseStream s h body) -> respond s h mempty (streamSimple body)
203− (ResponseRaw _ fallback) -> responder req fallback respond
204− (ResponseFile s h path mpart) -> go respond
205− where
206− -- Hooray, forcing things to be universally quantified.
207− go :: Responder
208− go = maybe
209− (respondFile s h path $ requestHeaders req)
210− (respondFilePart s h path)
211− mpart
203+ (ResponseBuilder s h b) -> respond s h mempty (streamBuilder b)
204+ (ResponseStream s h body) -> respond s h mempty (streamSimple body)
205+ (ResponseRaw _ fallback) -> responder req fallback respond
206+ (ResponseFile s h path mpart) -> case mpart of
207+ -- We can't use 'maybe' because the type checker can't instantiate the
208+ -- type variable at 'Responder', which is a universally quantified
209+ -- type.
210+ Nothing -> respondFile s h path (requestHeaders req) respond
211+ Just part -> respondFilePart s h path part respond
212212
213213-- | An 'Network.Wai.Application' we tried to promote neither called its
214214-- respond action nor raised; this is only possible if it imported the
215−-- 'ResponseReceived' and used it to lie about having called the action.
215+-- 'ResponseReceived' constructor and used it to lie about having called the
216+-- action.
216217data RespondNeverCalled = RespondNeverCalled deriving (Show, Typeable)
217218
218219instance Exception RespondNeverCalled