@@ -238,11 +238,12 @@ class (AllMime list) => AllMimeRender (list :: [*]) a where
238 -> a -- value to serialize
238 -> a -- value to serialize
239 -> [(M.MediaType, ByteString)] -- content-types/response pairs
239 -> [(M.MediaType, ByteString)] -- content-types/response pairs
241−instance ( MimeRender ctyp a ) => AllMimeRender '[ctyp] a where
241+instance OVERLAPPABLE_ ( MimeRender ctyp a ) => AllMimeRender '[ctyp] a where
242 allMimeRender _ a = [(contentType pctyp, mimeRender pctyp a)]
242 allMimeRender _ a = [(contentType pctyp, mimeRender pctyp a)]
243 where pctyp = Proxy :: Proxy ctyp
243 where pctyp = Proxy :: Proxy ctyp
245+instance OVERLAPPABLE_
245−instance ( MimeRender ctyp a
246+ ( MimeRender ctyp a
246 , AllMimeRender (ctyp' ': ctyps) a
247 , AllMimeRender (ctyp' ': ctyps) a
247 ) => AllMimeRender (ctyp ': ctyp' ': ctyps) a where
248 ) => AllMimeRender (ctyp ': ctyp' ': ctyps) a where
248 allMimeRender _ a = (contentType pctyp, mimeRender pctyp a)
249 allMimeRender _ a = (contentType pctyp, mimeRender pctyp a)
@@ -250,6 +251,19 @@ instance ( MimeRender ctyp a
250 where pctyp = Proxy :: Proxy ctyp
251 where pctyp = Proxy :: Proxy ctyp
251 pctyps = Proxy :: Proxy (ctyp' ': ctyps)
252 pctyps = Proxy :: Proxy (ctyp' ': ctyps)
255+-- Ideally we would like to declare a 'MimeRender a NoContent' instance, and
256+-- then this would be taken care of. However there is no more specific instance
257+-- between that and 'MimeRender JSON a', so we do this instead
258+instance OVERLAPPING_ ( Accept ctyp ) => AllMimeRender '[ctyp] NoContent where
259+ allMimeRender _ _ = [(contentType pctyp, "")]
260+ where pctyp = Proxy :: Proxy ctyp
262+instance OVERLAPPING_
263+ ( AllMime (ctyp ': ctyp' ': ctyps)
264+ ) => AllMimeRender (ctyp ': ctyp' ': ctyps) NoContent where
265+ allMimeRender p _ = zip (allMime p) (repeat "")
253--------------------------------------------------------------------------
267--------------------------------------------------------------------------
254-- Check that all elements of list are instances of MimeUnrender
268-- Check that all elements of list are instances of MimeUnrender
255--------------------------------------------------------------------------
269--------------------------------------------------------------------------
@@ -308,24 +322,6 @@ instance MimeRender OctetStream BS.ByteString where
308data NoContent = NoContent
322data NoContent = NoContent
309 deriving (Show, Eq, Read)
323 deriving (Show, Eq, Read)
311−instance FromJSON NoContent where
312− parseJSON _ = return NoContent
314−instance ToJSON NoContent where
318−instance OVERLAPPING_
319− MimeRender JSON NoContent where
322−instance OVERLAPPING_
323− MimeRender PlainText NoContent where
326−instance OVERLAPPING_
327− MimeRender OctetStream NoContent where
330--------------------------------------------------------------------------
326--------------------------------------------------------------------------
331-- * MimeUnrender Instances
327-- * MimeUnrender Instances