@@ -11,11 +11,10 @@
1111{-# LANGUAGE TypeFamilies #-}
1212{-# LANGUAGE TypeOperators #-}
1313{-# LANGUAGE UndecidableInstances #-}
14−#if !MIN_VERSION_base(4,8,0)
15−{-# LANGUAGE OverlappingInstances #-}
16−#endif
1714{-# OPTIONS_HADDOCK not-home #-}
1815
16+#include "overlapping-compat.h"
17+
1918-- | A collection of basic Content-Types (also known as Internet Media
2019-- Types, or MIME types). Additionally, this module provides classes that
2120-- encapsulate how to serialize or deserialize values to or from
@@ -57,6 +56,9 @@ module Servant.API.ContentTypes
5756 , MimeRender(..)
5857 , MimeUnrender(..)
5958
59+ -- * NoContent
60+ , NoContent(..)
61+
6062 -- * Internal
6163 , AcceptHeader(..)
6264 , AllCTRender(..)
@@ -75,8 +77,7 @@ import Control.Applicative ((*>), (<*))
7577#endif
7678import Control.Arrow (left)
7779import Control.Monad
78−import Data.Aeson (FromJSON, ToJSON, encode,
79− parseJSON)
80+import Data.Aeson (FromJSON(..), ToJSON(..), encode)
8081import Data.Aeson.Parser (value)
8182import Data.Aeson.Types (parseEither)
8283import Data.Attoparsec.ByteString.Char8 (endOfInput, parseOnly,
@@ -168,10 +169,7 @@ class (AllMime list) => AllCTRender (list :: [*]) a where
168169 -- mimetype).
169170 handleAcceptH :: Proxy list -> AcceptHeader -> a -> Maybe (ByteString, ByteString)
170171
171−instance
172−#if MIN_VERSION_base(4,8,0)
173− {-# OVERLAPPABLE #-}
174−#endif
172+instance OVERLAPPABLE_
175173 (AllMimeRender (ct ': cts) a) => AllCTRender (ct ': cts) a where
176174 handleAcceptH _ (AcceptHeader accept) val = M.mapAcceptMedia lkup accept
177175 where pctyps = Proxy :: Proxy (ct ': cts)
@@ -275,20 +273,14 @@ instance ( MimeUnrender ctyp a
275273-- * MimeRender Instances
276274
277275-- | `encode`
278−instance
279−#if MIN_VERSION_base(4,8,0)
280− {-# OVERLAPPABLE #-}
281−#endif
276+instance OVERLAPPABLE_
282277 ToJSON a => MimeRender JSON a where
283278 mimeRender _ = encode
284279
285280-- | @encodeFormUrlEncoded . toFormUrlEncoded@
286281-- Note that the @mimeUnrender p (mimeRender p x) == Right x@ law only
287282-- holds if every element of x is non-null (i.e., not @("", "")@)
288−instance
289−#if MIN_VERSION_base(4,8,0)
290− {-# OVERLAPPABLE #-}
291−#endif
283+instance OVERLAPPABLE_
292284 ToFormUrlEncoded a => MimeRender FormUrlEncoded a where
293285 mimeRender _ = encodeFormUrlEncoded . toFormUrlEncoded
294286
@@ -312,25 +304,27 @@ instance MimeRender OctetStream ByteString where
312304instance MimeRender OctetStream BS.ByteString where
313305 mimeRender _ = fromStrict
314306
315−instance
316−#if MIN_VERSION_base(4,8,0)
317− {-# OVERLAPPING #-}
318−#endif
319− MimeRender JSON () where
307+-- | A type for responses with content-body.
308+data NoContent = NoContent
309+ deriving (Show, Eq, Read)
310+
311+instance FromJSON NoContent where
312+ parseJSON _ = return NoContent
313+
314+instance ToJSON NoContent where
315+ toJSON _ = ""
316+
317+
318+instance OVERLAPPING_
319+ MimeRender JSON NoContent where
320320 mimeRender _ _ = ""
321321
322−instance
323−#if MIN_VERSION_base(4,8,0)
324− {-# OVERLAPPING #-}
325−#endif
326− MimeRender PlainText () where
322+instance OVERLAPPING_
323+ MimeRender PlainText NoContent where
327324 mimeRender _ _ = ""
328325
329−instance
330−#if MIN_VERSION_base(4,8,0)
331− {-# OVERLAPPING #-}
332−#endif
333− MimeRender OctetStream () where
326+instance OVERLAPPING_
327+ MimeRender OctetStream NoContent where
334328 mimeRender _ _ = ""
335329
336330--------------------------------------------------------------------------