on master help sign in
General cleanup, fix build on GHC 7.10

It previously relied on an incorrect behavior of 7.6, namely that unification variables could be instantiated at type aliases whose expansion is universally quantified. Also fix some typos, import lists, warnings, and formatting issues.

commit008c16ee5fa9787775db07d7c2d55b89c0c8ad70 authorAndrew Pritchard <awpr@google.com> dateTue 1 Sep 2015, 20:25 (11 years ago) parent178e0d9
3 files changed+18−26
wai/Network/Wai/HTTP2.hs+14−13 warp/Network/Wai/Handler/Warp/HTTP2/Worker.hs+2−3 warp/Network/Wai/Handler/Warp/Response.hs+2−10
wai/Network/Wai/HTTP2.hs+14−13
@@ -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
warp/Network/Wai/Handler/Warp/HTTP2/Worker.hs+2−3
@@ -15,7 +15,7 @@ import Control.Applicative
1515#endif
1616import Control.Concurrent
1717import Control.Concurrent.STM
18−import Control.Exception (Exception, SomeException(..), AsyncException(..))
18+import Control.Exception (Exception, SomeException(..), AsyncException(..), throwIO)
1919import qualified Control.Exception as E
2020import Control.Monad (void, when)
2121import Data.Typeable
@@ -28,8 +28,7 @@ import Network.Wai.Handler.Warp.HTTP2.Manager
2828import Network.Wai.Handler.Warp.HTTP2.Types
2929import Network.Wai.Handler.Warp.IORef
3030import Network.Wai.HTTP2
31− ( Body
32− , Chunk(..)
31+ ( Chunk(..)
3332 , HTTP2Application
3433 , PushPromise
3534 , Responder
warp/Network/Wai/Handler/Warp/Response.hs+2−10
@@ -83,18 +83,10 @@ fileRangeSized :: H.Status -> H.ResponseHeaders
8383 -> (H.Status, H.ResponseHeaders, Integer, Integer)
8484fileRangeSized s0 hs0 mPart mRange fileSize = (s, hs, beg, len)
8585 where
86− (beg, _end, len, _entire) = checkPartRange fileSize mPart mRange
87− (s, hs) = adjustForFilePart s0 hs0 $ FilePart beg len fileSize
88−
89−checkPartRange :: Integer -> Maybe FilePart -> Maybe HeaderValue
90− -> (Integer, Integer, Integer, Bool)
91−checkPartRange fileSize mpart mrange = (beg, end, len, isEntire)
92− where
93− part = fromMaybe (chooseFilePart fileSize mrange) mpart
86+ part = fromMaybe (chooseFilePart fileSize mRange) mPart
9487 beg = filePartOffset part
9588 len = filePartByteCount part
96− end = beg + len - 1
97− isEntire = beg == 0 && len == fileSize
89+ (s, hs) = adjustForFilePart s0 hs0 $ FilePart beg len fileSize
9890
9991----------------------------------------------------------------
10092