Skip to content

Commit c147670

Browse files
committed
Abstract ByteString out of MIME rendering
1 parent 18b2ef4 commit c147670

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

servant/src/Servant/API/ContentTypes.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ newtype AcceptHeader = AcceptHeader BS.ByteString
167167
-- >
168168
-- > type MyAPI = "path" :> Get '[MyContentType] Int
169169
class Accept ctype => MimeRender ctype a where
170-
mimeRender :: Proxy ctype -> a -> ByteString
170+
type MimeRenderType a :: Type
171+
type MimeRenderType a = ByteString
172+
mimeRender :: Proxy ctype -> a -> MimeRenderType a
171173

172174
class AllMime list => AllCTRender (list :: [Type]) a where
173175
-- If the Accept header can be matched, returns (Just) a tuple of the
@@ -213,7 +215,9 @@ instance
213215
--
214216
-- >>> type MyAPI = "path" :> ReqBody '[MyContentType] Int :> Get '[JSON] Int
215217
class Accept ctype => MimeUnrender ctype a where
216-
mimeUnrender :: Proxy ctype -> ByteString -> Either String a
218+
type MimeUnrenderType a :: Type
219+
type MimeUnrenderType a = ByteString
220+
mimeUnrender :: Proxy ctype -> MimeUnrenderType a -> Either String a
217221
mimeUnrender p = mimeUnrenderWithType p (contentType p)
218222

219223
-- | Variant which is given the actual 'M.MediaType' provided by the other party.

0 commit comments

Comments
 (0)