@@ -162,12 +162,14 @@ newtype AcceptHeader = AcceptHeader BS.ByteString
162162-- > instance Accept MyContentType where
163163-- > contentType _ = "example" // "prs.me.mine" /: ("charset", "utf-8")
164164-- >
165- -- > instance Show a => MimeRender MyContentType a where
165+ -- > instance MimeRender MyContentType String where
166166-- > mimeRender _ val = pack ("This is MINE! " ++ show val)
167167-- >
168168-- > type MyAPI = "path" :> Get '[MyContentType] Int
169169class 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
172174class AllMime list => AllCTRender (list :: [Type ]) a where
173175 -- If the Accept header can be matched, returns (Just) a tuple of the
@@ -205,15 +207,17 @@ instance
205207-- :}
206208--
207209-- >>> :{
208- -- instance Read a => MimeUnrender MyContentType a where
210+ -- instance MimeUnrender MyContentType String where
209211-- mimeUnrender _ bs = case BSC.take 12 bs of
210212-- "MyContentType" -> return . read . BSC.unpack $ BSC.drop 12 bs
211213-- _ -> Left "didn't start with the magic incantation"
212214-- :}
213215--
214216-- >>> type MyAPI = "path" :> ReqBody '[MyContentType] Int :> Get '[JSON] Int
215217class 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