@@ -1,4 +1,3 @@
1−{-# LANGUAGE CPP #-}
21{-# LANGUAGE ConstraintKinds #-}
32{-# LANGUAGE DataKinds #-}
43{-# LANGUAGE DeriveDataTypeable #-}
@@ -14,8 +13,6 @@
1413{-# LANGUAGE UndecidableInstances #-}
1514{-# OPTIONS_HADDOCK not-home #-}
1615
17−#include "overlapping-compat.h"
18−
1916-- | A collection of basic Content-Types (also known as Internet Media
2017-- Types, or MIME types). Additionally, this module provides classes that
2118-- encapsulate how to serialize or deserialize values to or from
@@ -98,16 +95,13 @@ import qualified Data.Text.Lazy.Encoding as TextL
9895import Data.Typeable
9996import GHC.Generics
10097 (Generic)
98+import qualified GHC.TypeLits as TL
10199import qualified Network.HTTP.Media as M
102100import Prelude ()
103101import Prelude.Compat
104102import Web.FormUrlEncoded
105103 (FromForm, ToForm, urlDecodeAsForm, urlEncodeAsForm)
106104
107−#if MIN_VERSION_base(4,9,0)
108−import qualified GHC.TypeLits as TL
109−#endif
110−
111105-- * Provided content types
112106data JSON deriving Typeable
113107data PlainText deriving Typeable
@@ -185,18 +179,16 @@ class (AllMime list) => AllCTRender (list :: [*]) a where
185179 -- mimetype).
186180 handleAcceptH :: Proxy list -> AcceptHeader -> a -> Maybe (ByteString, ByteString)
187181
188−instance OVERLAPPABLE_
182+instance {-# OVERLAPPABLE #-}
189183 (Accept ct, AllMime cts, AllMimeRender (ct ': cts) a) => AllCTRender (ct ': cts) a where
190184 handleAcceptH _ (AcceptHeader accept) val = M.mapAcceptMedia lkup accept
191185 where pctyps = Proxy :: Proxy (ct ': cts)
192186 amrs = allMimeRender pctyps val
193187 lkup = fmap (\(a,b) -> (a, (fromStrict $ M.renderHeader a, b))) amrs
194188
195−#if MIN_VERSION_base(4,9,0)
196189instance TL.TypeError ('TL.Text "No instance for (), use NoContent instead.")
197190 => AllCTRender '[] () where
198191 handleAcceptH _ _ _ = error "unreachable"
199−#endif
200192
201193--------------------------------------------------------------------------
202194-- * Unrender
@@ -277,13 +269,13 @@ class (AllMime list) => AllMimeRender (list :: [*]) a where
277269 -> a -- value to serialize
278270 -> [(M.MediaType, ByteString)] -- content-types/response pairs
279271
280−instance OVERLAPPABLE_ ( MimeRender ctyp a ) => AllMimeRender '[ctyp] a where
272+instance {-# OVERLAPPABLE #-} ( MimeRender ctyp a ) => AllMimeRender '[ctyp] a where
281273 allMimeRender _ a = map (, bs) $ NE.toList $ contentTypes pctyp
282274 where
283275 bs = mimeRender pctyp a
284276 pctyp = Proxy :: Proxy ctyp
285277
286−instance OVERLAPPABLE_
278+instance {-# OVERLAPPABLE #-}
287279 ( MimeRender ctyp a
288280 , AllMimeRender (ctyp' ': ctyps) a
289281 ) => AllMimeRender (ctyp ': ctyp' ': ctyps) a where
@@ -299,12 +291,12 @@ instance OVERLAPPABLE_
299291-- Ideally we would like to declare a 'MimeRender a NoContent' instance, and
300292-- then this would be taken care of. However there is no more specific instance
301293-- between that and 'MimeRender JSON a', so we do this instead
302−instance OVERLAPPING_ ( Accept ctyp ) => AllMimeRender '[ctyp] NoContent where
294+instance {-# OVERLAPPING #-} ( Accept ctyp ) => AllMimeRender '[ctyp] NoContent where
303295 allMimeRender _ _ = map (, "") $ NE.toList $ contentTypes pctyp
304296 where
305297 pctyp = Proxy :: Proxy ctyp
306298
307−instance OVERLAPPING_
299+instance {-# OVERLAPPING #-}
308300 ( AllMime (ctyp ': ctyp' ': ctyps)
309301 ) => AllMimeRender (ctyp ': ctyp' ': ctyps) NoContent where
310302 allMimeRender p _ = zip (allMime p) (repeat "")
@@ -334,14 +326,14 @@ instance ( MimeUnrender ctyp a
334326-- * MimeRender Instances
335327
336328-- | `encode`
337−instance OVERLAPPABLE_
329+instance {-# OVERLAPPABLE #-}
338330 ToJSON a => MimeRender JSON a where
339331 mimeRender _ = encode
340332
341333-- | @urlEncodeAsForm@
342334-- Note that the @mimeUnrender p (mimeRender p x) == Right x@ law only
343335-- holds if every element of x is non-null (i.e., not @("", "")@)
344−instance OVERLAPPABLE_
336+instance {-# OVERLAPPABLE #-}
345337 ToForm a => MimeRender FormUrlEncoded a where
346338 mimeRender _ = urlEncodeAsForm
347339