2 Module : Gargantext.API..Types
3 Description : Ngrams List Types
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
12 {-# OPTIONS_GHC -fprint-potential-instances #-}
14 module Gargantext.API.Types where
17 import qualified Data.ByteString.Lazy.Char8 as BS8
18 import Data.Either (Either(..))
19 import Data.List.NonEmpty (NonEmpty ((:|)))
20 import Data.Text (Text)
21 import qualified Data.Text.Encoding as E
23 import Network.HTTP.Media ((//), (/:))
25 import qualified Prelude
31 data HTML deriving (Typeable)
32 instance Accept HTML where
33 contentTypes _ = "text" // "html" /: ("charset", "utf-8") :| ["text" // "html"]
34 instance MimeRender HTML BS8.ByteString where
35 mimeRender _ = Prelude.id
36 instance MimeUnrender HTML BS8.ByteString where
37 mimeUnrender _ bs = Right bs
38 instance MimeRender HTML Text where
39 mimeRender _ bs = BS8.fromStrict $ E.encodeUtf8 bs
40 instance MimeUnrender HTML Text where
41 mimeUnrender _ bs = Right $ E.decodeUtf8 $ BS8.toStrict bs
42 instance {-# OVERLAPPABLE #-} ToJSON a => MimeRender HTML a where