@@ -142,12 +142,12 @@ newtype AcceptHeader = AcceptHeader BS.ByteString
142-- > contentType _ = "example" // "prs.me.mine" /: ("charset", "utf-8")
142-- > contentType _ = "example" // "prs.me.mine" /: ("charset", "utf-8")
144-- > instance Show a => MimeRender MyContentType where
144-- > instance Show a => MimeRender MyContentType where
145−-- > toByteString _ val = pack ("This is MINE! " ++ show val)
145+-- > mimeRender _ val = pack ("This is MINE! " ++ show val)
147-- > type MyAPI = "path" :> Get '[MyContentType] Int
147-- > type MyAPI = "path" :> Get '[MyContentType] Int
149class Accept ctype => MimeRender ctype a where
149class Accept ctype => MimeRender ctype a where
150− toByteString :: Proxy ctype -> a -> ByteString
150+ mimeRender :: Proxy ctype -> a -> ByteString
152class AllCTRender (list :: [*]) a where
152class AllCTRender (list :: [*]) a where
153 -- If the Accept header can be matched, returns (Just) a tuple of the
153 -- If the Accept header can be matched, returns (Just) a tuple of the
@@ -180,7 +180,7 @@ instance ( AllMimeRender ctyps a, IsNonEmpty ctyps
182--instance Read a => MimeUnrender MyContentType a where
182--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
184-- "MyContentType" -> return . read . BSC.unpack $ BSC.drop 12 bs
184-- "MyContentType" -> return . read . BSC.unpack $ BSC.drop 12 bs
185-- _ -> Left "didn't start with the magic incantation"
185-- _ -> Left "didn't start with the magic incantation"
@@ -188,7 +188,7 @@ instance ( AllMimeRender ctyps a, IsNonEmpty ctyps
188-- >>> type MyAPI = "path" :> ReqBody '[MyContentType] Int :> Get '[JSON] Int
188-- >>> type MyAPI = "path" :> ReqBody '[MyContentType] Int :> Get '[JSON] Int
190class Accept ctype => MimeUnrender ctype a where
190class Accept ctype => MimeUnrender ctype a where
191− fromByteString :: Proxy ctype -> ByteString -> Either String a
191+ mimeUnrender :: Proxy ctype -> ByteString -> Either String a
193class (IsNonEmpty list) => AllCTUnrender (list :: [*]) a where
193class (IsNonEmpty list) => AllCTUnrender (list :: [*]) a where
194 handleCTypeH :: Proxy list
194 handleCTypeH :: Proxy list
@@ -214,13 +214,13 @@ class AllMimeRender (list :: [*]) a where
214 -> [(M.MediaType, ByteString)] -- content-types/response pairs
214 -> [(M.MediaType, ByteString)] -- content-types/response pairs
216instance ( MimeRender ctyp a ) => AllMimeRender '[ctyp] a where
216instance ( MimeRender ctyp a ) => AllMimeRender '[ctyp] a where
217− allMimeRender _ a = [(contentType pctyp, toByteString pctyp a)]
217+ allMimeRender _ a = [(contentType pctyp, mimeRender pctyp a)]
218 where pctyp = Proxy :: Proxy ctyp
218 where pctyp = Proxy :: Proxy ctyp
220instance ( MimeRender ctyp a
220instance ( MimeRender ctyp a
221 , AllMimeRender (ctyp' ': ctyps) a
221 , AllMimeRender (ctyp' ': ctyps) a
222 ) => AllMimeRender (ctyp ': ctyp' ': ctyps) a where
222 ) => AllMimeRender (ctyp ': ctyp' ': ctyps) a where
223− allMimeRender _ a = (contentType pctyp, toByteString pctyp a)
223+ allMimeRender _ a = (contentType pctyp, mimeRender pctyp a)
224 :(allMimeRender pctyps a)
224 :(allMimeRender pctyps a)
225 where pctyp = Proxy :: Proxy ctyp
225 where pctyp = Proxy :: Proxy ctyp
226 pctyps = Proxy :: Proxy (ctyp' ': ctyps)
226 pctyps = Proxy :: Proxy (ctyp' ': ctyps)
@@ -243,7 +243,7 @@ instance AllMimeUnrender '[] a where
243instance ( MimeUnrender ctyp a
243instance ( MimeUnrender ctyp a
244 , AllMimeUnrender ctyps a
244 , AllMimeUnrender ctyps a
245 ) => AllMimeUnrender (ctyp ': ctyps) a where
245 ) => AllMimeUnrender (ctyp ': ctyps) a where
246− allMimeUnrender _ val = (contentType pctyp, fromByteString pctyp val)
246+ allMimeUnrender _ val = (contentType pctyp, mimeUnrender pctyp val)
247 :(allMimeUnrender pctyps val)
247 :(allMimeUnrender pctyps val)
248 where pctyp = Proxy :: Proxy ctyp
248 where pctyp = Proxy :: Proxy ctyp
249 pctyps = Proxy :: Proxy ctyps
249 pctyps = Proxy :: Proxy ctyps
@@ -257,29 +257,29 @@ type family IsNonEmpty (list :: [*]) :: Constraint where
258-- | `encode`
258-- | `encode`
259instance ToJSON a => MimeRender JSON a where
259instance ToJSON a => MimeRender JSON a where
260− toByteString _ = encode
260+ mimeRender _ = encode
262-- | @encodeFormUrlEncoded . toFormUrlEncoded@
262-- | @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
264-- holds if every element of x is non-null (i.e., not @("", "")@)
264-- holds if every element of x is non-null (i.e., not @("", "")@)
265instance ToFormUrlEncoded a => MimeRender FormUrlEncoded a where
265instance ToFormUrlEncoded a => MimeRender FormUrlEncoded a where
266− toByteString _ = encodeFormUrlEncoded . toFormUrlEncoded
266+ mimeRender _ = encodeFormUrlEncoded . toFormUrlEncoded
268-- | `TextL.encodeUtf8`
268-- | `TextL.encodeUtf8`
269instance MimeRender PlainText TextL.Text where
269instance MimeRender PlainText TextL.Text where
270− toByteString _ = TextL.encodeUtf8
270+ mimeRender _ = TextL.encodeUtf8
272-- | @fromStrict . TextS.encodeUtf8@
272-- | @fromStrict . TextS.encodeUtf8@
273instance MimeRender PlainText TextS.Text where
273instance MimeRender PlainText TextS.Text where
274− toByteString _ = fromStrict . TextS.encodeUtf8
274+ mimeRender _ = fromStrict . TextS.encodeUtf8
277instance MimeRender OctetStream ByteString where
277instance MimeRender OctetStream ByteString where
278− toByteString _ = id
278+ mimeRender _ = id
280-- | `fromStrict`
280-- | `fromStrict`
281instance MimeRender OctetStream BS.ByteString where
281instance MimeRender OctetStream BS.ByteString where
282− toByteString _ = fromStrict
282+ mimeRender _ = fromStrict
285--------------------------------------------------------------------------
285--------------------------------------------------------------------------
@@ -294,29 +294,29 @@ eitherDecodeLenient input = do
295-- | `eitherDecode`
295-- | `eitherDecode`
296instance FromJSON a => MimeUnrender JSON a where
296instance FromJSON a => MimeUnrender JSON a where
297− fromByteString _ = eitherDecodeLenient
297+ mimeUnrender _ = eitherDecodeLenient
299-- | @decodeFormUrlEncoded >=> fromFormUrlEncoded@
299-- | @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
301-- holds if every element of x is non-null (i.e., not @("", "")@)
301-- holds if every element of x is non-null (i.e., not @("", "")@)
302instance FromFormUrlEncoded a => MimeUnrender FormUrlEncoded a where
302instance FromFormUrlEncoded a => MimeUnrender FormUrlEncoded a where
303− fromByteString _ = decodeFormUrlEncoded >=> fromFormUrlEncoded
303+ mimeUnrender _ = decodeFormUrlEncoded >=> fromFormUrlEncoded
305-- | @left show . TextL.decodeUtf8'@
305-- | @left show . TextL.decodeUtf8'@
306instance MimeUnrender PlainText TextL.Text where
306instance MimeUnrender PlainText TextL.Text where
307− fromByteString _ = left show . TextL.decodeUtf8'
307+ mimeUnrender _ = left show . TextL.decodeUtf8'
309-- | @left show . TextS.decodeUtf8' . toStrict@
309-- | @left show . TextS.decodeUtf8' . toStrict@
310instance MimeUnrender PlainText TextS.Text where
310instance MimeUnrender PlainText TextS.Text where
311− fromByteString _ = left show . TextS.decodeUtf8' . toStrict
311+ mimeUnrender _ = left show . TextS.decodeUtf8' . toStrict
313-- | @Right . id@
313-- | @Right . id@
314instance MimeUnrender OctetStream ByteString where
314instance MimeUnrender OctetStream ByteString where
315− fromByteString _ = Right . id
315+ mimeUnrender _ = Right . id
317-- | @Right . toStrict@
317-- | @Right . toStrict@
318instance MimeUnrender OctetStream BS.ByteString where
318instance MimeUnrender OctetStream BS.ByteString where
319− fromByteString _ = Right . toStrict
319+ mimeUnrender _ = Right . toStrict
322--------------------------------------------------------------------------
322--------------------------------------------------------------------------