@@ -142,12 +142,12 @@ newtype AcceptHeader = AcceptHeader BS.ByteString
142142-- > contentType _ = "example" // "prs.me.mine" /: ("charset", "utf-8")
143143-- >
144144-- > instance Show a => MimeRender MyContentType where
145−-- > toByteString _ val = pack ("This is MINE! " ++ show val)
145+-- > mimeRender _ val = pack ("This is MINE! " ++ show val)
146146-- >
147147-- > type MyAPI = "path" :> Get '[MyContentType] Int
148148--
149149class Accept ctype => MimeRender ctype a where
150− toByteString :: Proxy ctype -> a -> ByteString
150+ mimeRender :: Proxy ctype -> a -> ByteString
151151
152152class AllCTRender (list :: [*]) a where
153153 -- If the Accept header can be matched, returns (Just) a tuple of the
@@ -180,7 +180,7 @@ instance ( AllMimeRender ctyps a, IsNonEmpty ctyps
180180--
181181-- >>> :{
182182--instance Read a => MimeUnrender MyContentType a where
183−-- fromByteString _ bs = case BSC.take 12 bs of
183+-- mimeUnrender _ bs = case BSC.take 12 bs of
184184-- "MyContentType" -> return . read . BSC.unpack $ BSC.drop 12 bs
185185-- _ -> Left "didn't start with the magic incantation"
186186-- :}
@@ -188,7 +188,7 @@ instance ( AllMimeRender ctyps a, IsNonEmpty ctyps
188188-- >>> type MyAPI = "path" :> ReqBody '[MyContentType] Int :> Get '[JSON] Int
189189--
190190class Accept ctype => MimeUnrender ctype a where
191− fromByteString :: Proxy ctype -> ByteString -> Either String a
191+ mimeUnrender :: Proxy ctype -> ByteString -> Either String a
192192
193193class (IsNonEmpty list) => AllCTUnrender (list :: [*]) a where
194194 handleCTypeH :: Proxy list
@@ -214,13 +214,13 @@ class AllMimeRender (list :: [*]) a where
214214 -> [(M.MediaType, ByteString)] -- content-types/response pairs
215215
216216instance ( MimeRender ctyp a ) => AllMimeRender '[ctyp] a where
217− allMimeRender _ a = [(contentType pctyp, toByteString pctyp a)]
217+ allMimeRender _ a = [(contentType pctyp, mimeRender pctyp a)]
218218 where pctyp = Proxy :: Proxy ctyp
219219
220220instance ( MimeRender ctyp a
221221 , AllMimeRender (ctyp' ': ctyps) a
222222 ) => AllMimeRender (ctyp ': ctyp' ': ctyps) a where
223− allMimeRender _ a = (contentType pctyp, toByteString pctyp a)
223+ allMimeRender _ a = (contentType pctyp, mimeRender pctyp a)
224224 :(allMimeRender pctyps a)
225225 where pctyp = Proxy :: Proxy ctyp
226226 pctyps = Proxy :: Proxy (ctyp' ': ctyps)
@@ -243,7 +243,7 @@ instance AllMimeUnrender '[] a where
243243instance ( MimeUnrender ctyp a
244244 , AllMimeUnrender ctyps a
245245 ) => AllMimeUnrender (ctyp ': ctyps) a where
246− allMimeUnrender _ val = (contentType pctyp, fromByteString pctyp val)
246+ allMimeUnrender _ val = (contentType pctyp, mimeUnrender pctyp val)
247247 :(allMimeUnrender pctyps val)
248248 where pctyp = Proxy :: Proxy ctyp
249249 pctyps = Proxy :: Proxy ctyps
@@ -257,29 +257,29 @@ type family IsNonEmpty (list :: [*]) :: Constraint where
257257
258258-- | `encode`
259259instance ToJSON a => MimeRender JSON a where
260− toByteString _ = encode
260+ mimeRender _ = encode
261261
262262-- | @encodeFormUrlEncoded . toFormUrlEncoded@
263−-- Note that the @fromByteString p (toByteString p x) == Right x@ law only
263+-- Note that the @mimeUnrender p (mimeRender p x) == Right x@ law only
264264-- holds if every element of x is non-null (i.e., not @("", "")@)
265265instance ToFormUrlEncoded a => MimeRender FormUrlEncoded a where
266− toByteString _ = encodeFormUrlEncoded . toFormUrlEncoded
266+ mimeRender _ = encodeFormUrlEncoded . toFormUrlEncoded
267267
268268-- | `TextL.encodeUtf8`
269269instance MimeRender PlainText TextL.Text where
270− toByteString _ = TextL.encodeUtf8
270+ mimeRender _ = TextL.encodeUtf8
271271
272272-- | @fromStrict . TextS.encodeUtf8@
273273instance MimeRender PlainText TextS.Text where
274− toByteString _ = fromStrict . TextS.encodeUtf8
274+ mimeRender _ = fromStrict . TextS.encodeUtf8
275275
276276-- | @id@
277277instance MimeRender OctetStream ByteString where
278− toByteString _ = id
278+ mimeRender _ = id
279279
280280-- | `fromStrict`
281281instance MimeRender OctetStream BS.ByteString where
282− toByteString _ = fromStrict
282+ mimeRender _ = fromStrict
283283
284284
285285--------------------------------------------------------------------------
@@ -294,29 +294,29 @@ eitherDecodeLenient input = do
294294
295295-- | `eitherDecode`
296296instance FromJSON a => MimeUnrender JSON a where
297− fromByteString _ = eitherDecodeLenient
297+ mimeUnrender _ = eitherDecodeLenient
298298
299299-- | @decodeFormUrlEncoded >=> fromFormUrlEncoded@
300−-- Note that the @fromByteString p (toByteString p x) == Right x@ law only
300+-- Note that the @mimeUnrender p (mimeRender p x) == Right x@ law only
301301-- holds if every element of x is non-null (i.e., not @("", "")@)
302302instance FromFormUrlEncoded a => MimeUnrender FormUrlEncoded a where
303− fromByteString _ = decodeFormUrlEncoded >=> fromFormUrlEncoded
303+ mimeUnrender _ = decodeFormUrlEncoded >=> fromFormUrlEncoded
304304
305305-- | @left show . TextL.decodeUtf8'@
306306instance MimeUnrender PlainText TextL.Text where
307− fromByteString _ = left show . TextL.decodeUtf8'
307+ mimeUnrender _ = left show . TextL.decodeUtf8'
308308
309309-- | @left show . TextS.decodeUtf8' . toStrict@
310310instance MimeUnrender PlainText TextS.Text where
311− fromByteString _ = left show . TextS.decodeUtf8' . toStrict
311+ mimeUnrender _ = left show . TextS.decodeUtf8' . toStrict
312312
313313-- | @Right . id@
314314instance MimeUnrender OctetStream ByteString where
315− fromByteString _ = Right . id
315+ mimeUnrender _ = Right . id
316316
317317-- | @Right . toStrict@
318318instance MimeUnrender OctetStream BS.ByteString where
319− fromByteString _ = Right . toStrict
319+ mimeUnrender _ = Right . toStrict
320320
321321
322322--------------------------------------------------------------------------