The class ToTypedContentdescribes what content-typedata is. Thus, types that have an associated content type (e.g., UTF 8 for Textor Value(JSON)) can have a natural instance ToTypedContent.
The problem with it ByteStringis that it describes any binary data - yours ByteStringcould be PNG, JPEG or something else, so it is not clear what type of content it should provide.
, octet-stream:
getHomeR :: Handler TypedContent
getHomeR = return $ TypedContent typeOctet $ toContent ("x" :: ByteString)
, (, image/jpeg JPEG).
TypedContent , , ToTypedContent ByteString
newtype Jpeg = Jpeg ByteString deriving (Show, ToContent)
instance ToTypedContent Jpeg where
toTypedContent h = TypedContent "image/jpeg" (toContent h)