]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/Implant/PrettyPrint.hs
Code clean-up using convertible-text.
[Lucu.git] / Network / HTTP / Lucu / Implant / PrettyPrint.hs
index 5bbc36d8d470508904ce8247485d9ef0947ce72b..22e3a74538c3a3342a74979c45d60382a3742c63 100644 (file)
@@ -1,5 +1,7 @@
 {-# LANGUAGE
     DoAndIfThenElse
+  , FlexibleContexts
+  , MultiParamTypeClasses
   , OverloadedStrings
   , RecordWildCards
   , TemplateHaskell
@@ -15,10 +17,10 @@ module Network.HTTP.Lucu.Implant.PrettyPrint
 import Codec.Compression.GZip
 import Control.Monad
 import Data.Ascii (Ascii, CIAscii)
-import qualified Data.Ascii as A
 import qualified Data.ByteString.Lazy as L
 import Data.Char
 import Data.Collections
+import Data.Convertible.Base
 import Data.Convertible.Utils
 import Data.List (intersperse)
 import Data.Monoid
@@ -60,19 +62,16 @@ header i@(Input {..})
                              ]
                     else
                         text "      Compression: disabled"
-                  , text "        MIME Type:" <+> mimeTypeToDoc iType
-                  , text "             ETag:" <+> eTagToDoc iETag
+                  , text "        MIME Type:" <+> toDoc iType
+                  , text "             ETag:" <+> toDoc iETag
                   , text "    Last Modified:" <+> text (show iLastMod)
                   ]
            , text " -}"
            , text "{-# LANGUAGE MagicHash #-}"
            ]
     where
-      eTagToDoc ∷ ETag → Doc
-      eTagToDoc = text ∘ convertSuccessVia ((⊥) ∷ Ascii)
-
-      mimeTypeToDoc ∷ MIMEType → Doc
-      mimeTypeToDoc = text ∘ A.toString ∘ A.fromAsciiBuilder ∘ printMIMEType
+      toDoc ∷ ConvertSuccess α Ascii ⇒ α → Doc
+      toDoc = text ∘ convertSuccessVia ((⊥) ∷ Ascii)
 
 moduleDecl ∷ ModName → Name → Doc
 moduleDecl modName symName